@@ -36,19 +36,18 @@ def draw():
36
36
37
37
# black panel
38
38
noStroke ()
39
- fill ('#000000' ); rect (0 , 0 , palette , height )
39
+ fill ('#000000' )
40
+ rect (0 , 0 , palette , height )
40
41
# color swatches
41
- p , p2 = palette , palette / 2
42
- fill (swatches [0 ]); square (0 , 0 , p2 )
43
- fill (swatches [1 ]); square (p2 , 0 , p2 )
44
- fill (swatches [2 ]); square (0 , p2 , p2 )
45
- fill (swatches [3 ]); square (p2 , p2 , p2 )
46
- fill (swatches [4 ]); square (0 , p , p2 )
47
- fill (swatches [5 ]); square (p2 , p , p2 )
42
+ for (i , swatch ) in enumerate (swatches ):
43
+ sx = int (i % 2 ) * palette / 2
44
+ sy = int (i / 2 ) * palette / 2
45
+ fill (swatch )
46
+ square (sx , sy , palette / 2 )
48
47
# brush preview
49
48
fill (brushcolor )
50
49
if brushshape == ROUND :
51
- circle (30 , 123 , brushsize )
50
+ circle (palette / 2 , 123 , brushsize )
52
51
paintmode = 'free'
53
52
# clear button
54
53
fill ('#FFFFFF' )
@@ -98,6 +97,6 @@ def keyPressed():
98
97
99
98
def mouseClicked ():
100
99
# clear canvas
101
- if mouseButton == LEFT and mouseX < 60 and mouseY > height - 30 :
100
+ if mouseButton == LEFT and mouseX < palette and mouseY > height - 30 :
102
101
fill ('#004477' )
103
102
rect (palette , 0 , width , height )
0 commit comments