Skip to content

Commit 389c635

Browse files
authored
Merge pull request #5315 from JetStarBlues/improveLightFalloffExample
Improve clarity of `lightFalloff()` example
2 parents bb4bb24 + 260e803 commit 389c635

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/webgl/light.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,17 +443,26 @@ p5.prototype.lights = function() {
443443
* noStroke();
444444
* }
445445
* function draw() {
446+
* ortho();
446447
* background(0);
448+
*
447449
* let locX = mouseX - width / 2;
448450
* let locY = mouseY - height / 2;
449-
* translate(-25, 0, 0);
451+
* locX /= 2; // half scale
452+
*
450453
* lightFalloff(1, 0, 0);
451-
* pointLight(250, 250, 250, locX, locY, 50);
454+
* push();
455+
* translate(-25, 0, 0);
456+
* pointLight(250, 250, 250, locX - 25, locY, 50);
452457
* sphere(20);
453-
* translate(50, 0, 0);
454-
* lightFalloff(0.9, 0.01, 0);
455-
* pointLight(250, 250, 250, locX, locY, 50);
458+
* pop();
459+
*
460+
* lightFalloff(0.97, 0.03, 0);
461+
* push();
462+
* translate(25, 0, 0);
463+
* pointLight(250, 250, 250, locX + 25, locY, 50);
456464
* sphere(20);
465+
* pop();
457466
* }
458467
* </code>
459468
* </div>

0 commit comments

Comments
 (0)