Skip to content

Commit f09741b

Browse files
committed
Fix Loading Images example with local asset, fix Rotate Push Pop lighting
1 parent 50eca59 commit f09741b

5 files changed

Lines changed: 24 additions & 12 deletions

File tree

assets/data/processing-web.png

141 KB
Loading

assets/examples_js/Basics/transform/Rotate_Push_Pop/Rotate_Push_Pop.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
let a = 0;
2-
let offset = PI / 24.0;
2+
let offset;
33
let num = 12;
44

55
function setup() {
66
createCanvas(640, 360, WEBGL);
77
noStroke();
8+
offset = PI / 24.0;
89
}
910

1011
function draw() {
1112
background(0, 0, 26);
13+
ambientLight(150);
14+
directionalLight(255, 255, 255, 0, 0, -1);
15+
directionalLight(100, 100, 100, 0, 0, 1);
16+
1217
for (let i = 0; i < num; i++) {
18+
let gray = map(i, 0, num - 1, 0, 255);
1319
push();
14-
normalMaterial();
20+
fill(gray);
1521
rotateY(a + offset * i);
1622
rotateX(a / 2 + offset * i);
1723
box(90);

assets/examples_js/Basics/web/Loading_Images/Loading_Images.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
let img;
22

3+
function preload() {
4+
img = loadImage('https://processing-cpp.github.io/assets/data/processing-web.png');
5+
}
6+
37
function setup() {
48
createCanvas(640, 360);
5-
6-
img = loadImage("https://processing.org/img/processing-web.png");
7-
89
noLoop();
910
}
1011

1112
function draw() {
1213
background(0);
13-
1414
if (img) {
1515
for (let i = 0; i < 5; i++) {
1616
image(img, 0, img.height * i);

examples/loading-images.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ <h1>Loading Images</h1>
6767
<div class="preview-wrap"><iframe id="sketch-frame" width="640" height="360"></iframe></div>
6868
<script>(function(){const iframe=document.getElementById('sketch-frame');const doc=iframe.contentDocument||iframe.contentWindow.document;doc.open();doc.write(`<!DOCTYPE html><html><head><style>*{margin:0;padding:0;}body{overflow:hidden;}</style><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"><\/script></head><body><script>let img;
6969
70+
function preload() {
71+
img = loadImage("https://processing-cpp.github.io/assets/data/https://processing-cpp.github.io/assets/data/processing-web.png");
72+
}
73+
7074
function setup() {
7175
createCanvas(640, 360);
72-
73-
img = loadImage("https://processing-cpp.github.io/assets/data/https://processing.org/img/processing-web.png");
74-
7576
noLoop();
7677
}
7778
7879
function draw() {
7980
background(0);
80-
8181
if (img) {
8282
for (let i = 0; i < 5; i++) {
8383
image(img, 0, img.height * i);

examples/rotate-push-pop.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,25 @@
6666
<h1>Rotate Push Pop</h1>
6767
<div class="preview-wrap"><iframe id="sketch-frame" width="640" height="360"></iframe></div>
6868
<script>(function(){const iframe=document.getElementById('sketch-frame');const doc=iframe.contentDocument||iframe.contentWindow.document;doc.open();doc.write(`<!DOCTYPE html><html><head><style>*{margin:0;padding:0;}body{overflow:hidden;}</style><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.9.0/p5.min.js"><\/script></head><body><script>let a = 0;
69-
let offset = PI / 24.0;
69+
let offset;
7070
let num = 12;
7171
7272
function setup() {
7373
createCanvas(640, 360, WEBGL);
7474
noStroke();
75+
offset = PI / 24.0;
7576
}
7677
7778
function draw() {
7879
background(0, 0, 26);
80+
ambientLight(150);
81+
directionalLight(255, 255, 255, 0, 0, -1);
82+
directionalLight(100, 100, 100, 0, 0, 1);
83+
7984
for (let i = 0; i < num; i++) {
85+
let gray = map(i, 0, num - 1, 0, 255);
8086
push();
81-
normalMaterial();
87+
fill(gray);
8288
rotateY(a + offset * i);
8389
rotateX(a / 2 + offset * i);
8490
box(90);

0 commit comments

Comments
 (0)