If you are trying to do other kinds of zooming, such as zooming on whatever the current mouse location is, then the basics are the same but it gets a bit more complex. and here is a slightly more complex setup in which mouseWheel() controls the zoom variable: var zoom = 1.00 This program draws a circle wherever the mouse cursor is. p5.js automatically updates these variables, so you can use them in the draw function to get the position of the mouse. One element that changes over time, independently of the mouse. p5.js provides mouseX and mouseY variables that hold the current location of the mouse cursor in the window. There is no user input - it just keeps zooming every time the screen redraws: var zoom = 1.00 Create a sketch that includes (all of these): One element controlled by the mouse. Here is a simple example of a zooming sketch in p5.js - it is almost identical to the Processing (Java) equivalent. One element that is different every time you run the sketch. One element that changes over time, independently of the mouse. This approach works the same in both p5.js and Processing (Java). ANIMATION WITH P5.JS week 2 Create a sketch that includes (all of these): One element controlled by the mouse. draw things based on 0,0 at the middle of the screen. p5.js Beginners Jithin September 27, 2019, 4:46pm 1 When I use applyMatrix in a sketch to transform the coordinates, the mouseX and mouseY is not transformed accordingly. Here is a simple example of a zooming sketch in p5.js - it is almost identical to the Processing(Java) equivalent. use scale (zoom) to set the zoom level, with 1.0 being normal. This approach works the same in both p5.js and Processing(Java). And its steering p5. p5. Lotsa devs are changing its internal behavior as they please. draw things based on 0,0 at the middle of the screen. Framework p5.js is under heavy development right now.use scale(zoom) to set the zoom level, with 1.0 being normal.centering on the sketch / canvas using translate(width/2, height/2).Depending on what you are trying to do, you might approach zooming by:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |