summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/man/1/paint2
-rw-r--r--sys/src/cmd/paint.c19
2 files changed, 20 insertions, 1 deletions
diff --git a/sys/man/1/paint b/sys/man/1/paint
index 2bcbf245c..b3f1c5410 100644
--- a/sys/man/1/paint
+++ b/sys/man/1/paint
@@ -13,6 +13,8 @@ displays a canvas upon which can be drawn lines using the mouse holding
down buttons 1 or 2 for foreground or background color. The canvas
may be moved with button 3. Colors and brush sizes may be selected by
clicking on the palette at the bottom of the screen with buttons 1 or 2.
+Clicking button 3 on the palette allows changing a color by entering its
+hex value.
.PP
If the optional
.I file
diff --git a/sys/src/cmd/paint.c b/sys/src/cmd/paint.c
index 4b2087de2..4175a4d5d 100644
--- a/sys/src/cmd/paint.c
+++ b/sys/src/cmd/paint.c
@@ -515,6 +515,10 @@ drawpal(void)
int
hitpal(Mouse m)
{
+ int i;
+ u32int c;
+ char buf[16], *e;
+
if(ptinrect(m.xy, penr)){
if(m.buttons & 7){
brush = ((m.xy.x - penr.min.x) * NBRUSH) / Dx(penr);
@@ -525,7 +529,8 @@ hitpal(Mouse m)
if(ptinrect(m.xy, palr)){
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 +541,18 @@ hitpal(Mouse m)
drawpal();
update(nil);
break;
+ case 4:
+ snprint(buf, sizeof(buf), "%06x", c64[i]);
+ if(eenter("Hex", buf, sizeof(buf), &m) == 6){
+ c = strtoll(buf, &e, 16);
+ if(*e == 0){
+ c64[i] = c;
+ freeimage(pal[i]);
+ pal[i] = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, c<<8|0xff);
+ drawpal();
+ }
+ }
+ break;
}
return 1;
}