Skip to content

Commit 7831cea

Browse files
author
lauren mccarthy
committed
updating examples
1 parent c08e5bd commit 7831cea

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/p5.Vector/NOC_6_09_Flocking/boid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ Boid.prototype.render = function() {
7070
var theta = this.velocity.heading() + radians(90);
7171
fill(127);
7272
stroke(200);
73-
pushMatrix();
73+
push();
7474
translate(this.position.x,this.position.y);
7575
rotate(theta);
7676
beginShape();
7777
vertex(0, -this.r*2);
7878
vertex(-this.r, this.r*2);
7979
vertex(this.r, this.r*2);
8080
endShape(CLOSE);
81-
popMatrix();
81+
pop();
8282
}
8383

8484
// Wraparound

examples/pixel/set-pixels.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function preload() {
1111

1212
function setup() {
1313
createCanvas(256, 256);
14+
loadPixels();
1415
set(width/2, height/2, img);
1516
}
1617

@@ -20,6 +21,7 @@ function draw() {
2021
for (var i=-5; i<5; i++) {
2122
set(mouseX+i, mouseY, [0, 0, 255, 100]);
2223
}
23-
set(mouseX, mouseY, [255, 0, 255]);
24+
set(mouseX, mouseY, [255, 0, 255, 255]);
2425
set(mouseX+10, mouseY+10, 0);
26+
updatePixels();
2527
}

examples/pixel/update-pixels.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ function draw() {
1919
for (var y=0 ; y<height; y++) {
2020
for (var x=0; x<width; x++) {
2121
if (pow((x-mouseX), 2)+ pow((y-mouseY), 2)<pow(radius, 2)) {
22-
pixels[y*width+x] = img.get(x, y);
22+
var c = img.get(x, y);
23+
pixels[4*(y*width+x)] = c[0];
24+
pixels[4*(y*width+x)+1] = c[1];
25+
pixels[4*(y*width+x)+2] = c[2];
26+
pixels[4*(y*width+x)+3] = c[3];
2327
}
2428
}
2529
}

0 commit comments

Comments
 (0)