Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lunarean style somehow interferes with other styles #49

Closed
clauswilke opened this issue Feb 19, 2022 · 8 comments · Fixed by #50
Closed

Lunarean style somehow interferes with other styles #49

clauswilke opened this issue Feb 19, 2022 · 8 comments · Fixed by #50

Comments

@clauswilke
Copy link
Contributor

Easiest way to reproduce: Comment out all styles except Lunarean and Boilerplate, then cycle between styles. After Lunarean has been drawn, Boilerplate turns very dark. Other styles are similarly affected.

@clauswilke
Copy link
Contributor Author

I've narrowed it down to the drawBgTriangles() function. By itself, it is able to cause problems. I don't immediately see why. I have to run now but will continue looking later if nobody else figures it out first.

drawBgTriangles() {
const p5 = this._p5;
const SIZE = this._s;
const points = [[0, 1], [0, 0], [1, 0], [1, 1]];
const triangles = this.triangulateQuad(points, 0.02);
for (let triangle of triangles) {
if (p5.random() < 0.1) {
continue;
}
let [a, b, c, mod] = triangle;
// subdivide triangle - usually produces scribbled lines
if (p5.random() < 0.02) {
triangles.push(...this.triangulateQuad([a, b, c, a], 0.01));
}
// set stroke wider at bottom and top
const [mx, my] = this.centroid([a, b, c]);
const alpha = p5.max(p5.map(my, this.vanY, 1, 0, 0.12), p5.map(my, 0.5, 0, 0, 0.06), 0.04);
p5.stroke(this.modifyAlpha(this.WHITE, alpha));
// warp
[a, b, c] = [a, b, c].map(([x, y]) => {
y = p5.pow(y, 1.5);
return [x * SIZE, y * SIZE];
})
const sw = p5.random() < 0.03 ? 0.0005 : 0.00025;
p5.strokeWeight(sw * SIZE);
p5.line(...b, ...c);
p5.line(...c, ...a);
p5.line(...a, ...b);
}
}

@laurent-h
Copy link
Contributor

some xxxMode() are missing in index.js to restore all defaults.
I'm also trying to figure it out...

@lunarean
Copy link
Collaborator

Sorry about this, investigating it

@laurent-h
Copy link
Contributor

laurent-h commented Feb 19, 2022

Reset strokeWeight in index ?
p5.strokeWeight(1)

Resetting pixelDensity would also be a good idea:
p5.pixelDensity(window.devicePixelRatio)

@camilleroux
Copy link
Owner

Warning: resetting pixelDensity cleans the canvas :)
https://github.com/processing/p5.js/blob/v1.4.1/src/core/environment.js#L598

@lunarean
Copy link
Collaborator

Reset strokeWeight in index ? p5.strokeWeight(1)

Resetting pixelDensity would also be a good idea: p5.pixelDensity(window.devicePixelRatio)

nice! resetting strokeWeight seems to fix it

I can submit a fix adding those two lines to index.js

@clauswilke
Copy link
Contributor Author

clauswilke commented Feb 19, 2022

@lunarean While you're at it, I would also suggest to move this line down to after all the style settings have been reset, just to be safe:

currentStyle = new stylesClasses[styleClassId](gridSizeX, gridSizeY, s, projectionCalculator3d, p5)

@clauswilke
Copy link
Contributor Author

Basically, move to right before here:

currentStyle.beforeDraw()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants