Canvas Algorithms | Sololearn: Learn to code for FREE!

+7

Canvas Algorithms

If you are working with the canvas in any lang, feel free to share some algorithms you know NAME DESCRIP ALGO Never tried the canvas, try it ! vanillajs processingjs p5js if you wish

7/30/2017 4:50:18 PM

Abdur-Rahmaan Janhangeer

8 Answers

New Answer

+7

SPIRAL ..draw an spiral .. same as circular motion with the exception of an increasing scalar

+6

BOUNCE ..make an object bounce off a rectangular box .. basic structure: update check edges display .. vars : x y xspeed yspeed .. add speed to position if x>width or x<0 xspeed = xspeed *-1 if y>height or y<0 yspeed = yspeed *-1 .. you can limit velocity if you wish you can include acceleration you can use a custom vector if you wish

+6

I was just trying something and this was the result https://code.sololearn.com/W5ES5DxA1tT0/?ref=app

+5

CIRCULAR MOTION ..make an object move in circle .. x-coord : offset+sin(increasing angle)*scalar y-coord : offset+cos(increasing angle)*scalar vice-versa also works

+5

I'm just leaving a comment so I can find this thread later.

+5

+4

nice you knew spirals b4?

+4

lol canvas i have 4codes b4 arriving to real too fun