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

this code doesn't work. #192

Closed
robottini opened this issue Jul 6, 2021 · 2 comments
Closed

this code doesn't work. #192

robottini opened this issue Jul 6, 2021 · 2 comments
Assignees

Comments

@robottini
Copy link

Hi, this code doesn't work with p5.js-svg. The code works well without the SVG option.
`
let shapes = [];
let colors = ["#ed3441", "#ffd630", "#329fe3", "#154296", "#ffffff", "#303030"];
let bgCol ;
let nScl = 0.002;
let offset = 100;

function setup() {
createCanvas(1120, 800, SVG);
rectMode(CENTER);

bgCol = colors[2];
background(bgCol);
colors.splice(2, 1);

divideRect(offset, offset, width-(offset * 2), height-(offset * 2));
shuffle(shapes, true);
stroke(bgCol);
strokeWeight(3);
for(let s of shapes){
	push();
	translate(s.x, s.y);
	rotate((noise(s.x*nScl, s.y*nScl)-0.5)*1.25);
	fill(random(colors));
	rect(0, 0, s.w, s.h, 2);
	pop();
}
save();

}

function draw() {

}

function divideRect(x, y, w, h) {
let rnd = int(random(2));
let cc = 5;
let w1 = int(random(1, cc)) * (w / cc);
let w2 = w - w1;
let h1 = int(random(1, cc)) * (h / cc);
let h2 = h - h1;
let min = 35;
if (w > min && h > min) {
if (w >= h) {
let rndw = int(random(1, cc)) * (w / cc);
divideRect(x, y, rndw, h, min);
divideRect(x + rndw, y, w - rndw, h, min);
}
if (w < h) {
let rndh = int(random(1, cc)) * (h / cc);
divideRect(x, y, w, rndh, min);
divideRect(x, y + rndh, w, h - rndh, min);
}
}
else {
shapes.push({x:x+w/2, y:y+h/2, w:w-2, h:h-2});
}
}
`

@zenozeng zenozeng self-assigned this Jul 6, 2021
@zenozeng zenozeng added the bug label Jul 6, 2021
@zenozeng
Copy link
Owner

zenozeng commented Jul 6, 2021

61F21042-ADCB-49CF-B695-6A7D1F911F7F

@robottini Hi, push/pop issue was fixed in [email protected]. Would you like to try the latest version?

<script src="https://unpkg.com/[email protected]"></script>

@robottini
Copy link
Author

robottini commented Jul 6, 2021

Thanks, it works very well!!

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

No branches or pull requests

2 participants