Skip to content

Commit 9e378c0

Browse files
committed
P_3_1_2_02: Minor bug fix
1 parent 2ebec66 commit 9e378c0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

01_P/P_3_1_2_02/sketch.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function setup() {
9898
offsetX = 0;
9999
offsetY = 0;
100100
zoom = 0.75;
101+
101102
actRandomSeed = 6;
102103

103104
cursor(HAND);
@@ -125,6 +126,8 @@ function draw() {
125126
translate(centerX, centerY);
126127
scale(zoom);
127128

129+
push();
130+
128131
actColorIndex = 0;
129132
fill(palette[actColorIndex][0], palette[actColorIndex][1], palette[actColorIndex][2]);
130133
rect(0, -25, 10, 35);
@@ -180,7 +183,7 @@ function draw() {
180183
push();
181184
translate(random(-300, 300), random(-300, 300));
182185
rotate(floor(random(8))*QUARTER_PI);
183-
actColorIndex = actColorIndex + 1;
186+
actColorIndex = (actColorIndex + 1) % palette.length;
184187
fill(palette[actColorIndex][0], palette[actColorIndex][1], palette[actColorIndex][2]);
185188
rect(0, -25, 10, 35);
186189
break;
@@ -242,6 +245,8 @@ function draw() {
242245
// blink cursor after text
243246
fill(200, 30, 40);
244247
if (frameCount / 6 % 2 == 0) rect(0, 0, 15, 2);
248+
249+
pop();
245250
}
246251

247252
function mousePressed() {

0 commit comments

Comments
 (0)