Kinrany / vue-p5

Vue component for p5.js
125 stars 16 forks source link

Not able to use rotate() #12

Closed amravazzi closed 5 years ago

amravazzi commented 5 years ago

Hi, I'm trying to use the p5's method rotate() (https://p5js.org/reference/#/p5/rotate) but I'm just not able. I want the canvas to render already rotated. I tried sketch.rotate(45) inside many methods such as setup(), draw() but it does not rotate the canvas. How can I overcome that?

Kinrany commented 5 years ago

Hello, thanks for the report, I'll look into this!

It seems rotate() was available since at least 0.6.0, so it's probably not related to vue-p5 still being on p5@0.7.2.

Have you tried doing the same thing without vue-p5? Can you share a code sample that doesn't work even though it looks like it should?

Kinrany commented 5 years ago

Looks like rotate() is just slightly counterintuitive. You have to call it before drawing the object you want to rotate, not after, because instead of rotating the already drawn image it rotates the matrix used to draw new stuff.

In your case it should be enough to call rotate() in the beginning of the draw() method.

I'll change the example.

Kinrany commented 5 years ago

I updated the example repo.

Closing this for now; I'd love to hear whether you managed to make it work!

amravazzi commented 5 years ago

Thank you very much and sorry for the late reply. The example you posted was very helpful!!

Kinrany commented 5 years ago

You're welcome :)