Skip to content

Changing Stroke Mid-Curve Drawing Changes Entire Curve Colour #2274

@SethGreylyn

Description

@SethGreylyn

Nature of issue?

  • Found a bug

Most appropriate sub-area of p5.js?

  • Color
  • Shape

Which platform were you using when you encountered this?

  • Desktop/Laptop

Details about the bug:

I've been following the Coding Challenge videos, recreating the most interesting ones in P5; tonight I recreated the Lorenz Attractor, and I discovered that changing 'stroke' while adding curveVertex() to a shape causes the entire curve to be coloured with the stroke's argument (i.e., instead of drawing a rainbow, the whole curve changes from one solid colour to another).

The code I'm playing with is here, and the code in question is

translate(width / 2, height / 2);
scale(5);
noFill();
beginShape(points);

var rSeed = 50;
var gSeed = 100;
var bSeed = 198;

points.forEach((pnt) => {
print(rSeed, gSeed, bSeed);
stroke((rSeed++)%256, (gSeed++)%256, (bSeed++)%256);
curveVertex(pnt.x,pnt.y);
});
endShape();

Changing 'curveVertex()' to 'point()' results in differently-coloured points, so the basic logic is correct. (It also matches the Java logic in the Lorenz video.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions