diff options
author | Sigrid <ftrvxmtrx@gmail.com> | 2020-05-23 20:41:20 +0200 |
---|---|---|
committer | Sigrid <ftrvxmtrx@gmail.com> | 2020-05-23 20:41:20 +0200 |
commit | a8e4b50cb21072c4699291cbeb243e074ff000f1 (patch) | |
tree | 87fb3b262a6ad5a7d9b3fa91abdb303fc9dd0b42 /sys/src/cmd/paint.c | |
parent | ec737b6a2e464330946d5800841a1e631cd36acd (diff) |
paint: change colors in the palette with button 3
Diffstat (limited to 'sys/src/cmd/paint.c')
-rw-r--r-- | sys/src/cmd/paint.c | 19 |
1 files changed, 18 insertions, 1 deletions
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; } |