paint: change colors in the palette with button 3
parent
ec737b6a2e
commit
a8e4b50cb2
|
@ -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
|
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
|
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 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
|
.PP
|
||||||
If the optional
|
If the optional
|
||||||
.I file
|
.I file
|
||||||
|
|
|
@ -515,6 +515,10 @@ drawpal(void)
|
||||||
int
|
int
|
||||||
hitpal(Mouse m)
|
hitpal(Mouse m)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
u32int c;
|
||||||
|
char buf[16], *e;
|
||||||
|
|
||||||
if(ptinrect(m.xy, penr)){
|
if(ptinrect(m.xy, penr)){
|
||||||
if(m.buttons & 7){
|
if(m.buttons & 7){
|
||||||
brush = ((m.xy.x - penr.min.x) * NBRUSH) / Dx(penr);
|
brush = ((m.xy.x - penr.min.x) * NBRUSH) / Dx(penr);
|
||||||
|
@ -525,7 +529,8 @@ hitpal(Mouse m)
|
||||||
if(ptinrect(m.xy, palr)){
|
if(ptinrect(m.xy, palr)){
|
||||||
Image *col;
|
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){
|
switch(m.buttons & 7){
|
||||||
case 1:
|
case 1:
|
||||||
ink = col;
|
ink = col;
|
||||||
|
@ -536,6 +541,18 @@ hitpal(Mouse m)
|
||||||
drawpal();
|
drawpal();
|
||||||
update(nil);
|
update(nil);
|
||||||
break;
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue