* paint(1) color picker
@ 2019-01-20 7:00 qwx
0 siblings, 0 replies; only message in thread
From: qwx @ 2019-01-20 7:00 UTC (permalink / raw)
To: 9front
Hello,
I wrote a patch for paint(1) allowing one to change a palette color by
clicking on it with mouse button 3.
I know it's sacrilegious to touch the c64 palette, but it's been useful.
I'd like to push this. What do you think?
Thanks,
qwx
diff -r eb26bc92b777 sys/src/cmd/paint.c
--- a/sys/src/cmd/paint.c Sun Jan 13 17:17:11 2019 +0100
+++ b/sys/src/cmd/paint.c Sun Jan 20 07:54:13 2019 +0100
@@ -523,9 +523,12 @@
return 1;
}
if(ptinrect(m.xy, palr)){
+ int i, n;
+ char buf[32];
Image *col;
- col = pal[(m.xy.x - palr.min.x) * nelem(pal) / Dx(palr)];
+ i = (m.xy.x - palr.min.x) * nelem(pal) / Dx(palr);
+ col = pal[i];
switch(m.buttons & 7){
case 1:
ink = col;
@@ -536,6 +539,17 @@
drawpal();
update(nil);
break;
+ case 4:
+ buf[0] = 0;
+ if(eenter("Color", buf, sizeof(buf), &m) <= 0)
+ break;
+ n = strtol(buf, nil, 0);
+ freeimage(pal[i]);
+ pal[i] = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, n << 8 | 0xFF);
+ if(pal[i] == nil)
+ sysfatal("allocimage: %r");
+ drawpal();
+ break;
}
return 1;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-20 7:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-20 7:00 paint(1) color picker qwx
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).