zenozeng / p5.js-svg

SVG runtime for p5.js.
MIT License
679 stars 75 forks source link

Can't rotate loaded SVG element #221

Open sergiopernas-costa opened 2 years ago

sergiopernas-costa commented 2 years ago

Hi! Thanks for this awesome library. I'm using it and for the most part I don't have any issues, but I'm stuck trying to rotate a loaded SVG. I'm working with both the last versions of pj5s and the library. Here is the code to reproduce:

`function preload() { svgs = [ loadSVG('/img/plantilla_01.svg'), loadSVG('/img/plantilla_02.svg'), loadSVG('/img/plantilla_03.svg') ] }

function setup() { createCanvas(windowWidth, windowHeight, SVG) noLoop() angleMode(DEGREES) imageMode(CENTER)
}

function draw() { let posX = 0 let posY = 0 let imagen for (let index = 0; index < 10; index++) {
let giro = random(-90, 90)
push() translate(width/2, height/2) rotate(giro) imagen = svgs[floor(random(0,3))] image(imagen, posX, posY, width/10, height/10)
posX += width/10 posY += height/10 pop()
} }`

Which can be the issue?

dennykoch commented 1 year ago

I have the same issue!