+ 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

30th Jul 2017, 4:50 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
8 Antworten
+ 7
SPIRAL ..draw an spiral .. same as circular motion with the exception of an increasing scalar
30th Jul 2017, 4:53 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 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
30th Jul 2017, 4:57 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 6
I was just trying something and this was the result https://code.sololearn.com/W5ES5DxA1tT0/?ref=app
30th Jul 2017, 8:44 PM
The Coding Sloth
The Coding Sloth - avatar
+ 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
30th Jul 2017, 4:52 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 5
I'm just leaving a comment so I can find this thread later.
30th Jul 2017, 8:18 PM
The Coding Sloth
The Coding Sloth - avatar
+ 5
ok
30th Jul 2017, 8:19 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 4
nice you knew spirals b4?
30th Jul 2017, 8:51 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 4
lol canvas i have 4codes b4 arriving to real too fun
30th Jul 2017, 8:51 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar