Clojure2D / clojure2d-examples

Examples for Clojure2d
Eclipse Public License 1.0
88 stars 8 forks source link

Add an example to draw an Archimedean spiral #1

Closed jakeashdown closed 5 years ago

jakeashdown commented 5 years ago

This is my first time using clojure so I decide to have a go creating an example. When I run the script, the spiral appears correct but it only renders once per second. I can't figure out why this is, since I've played around with the FPS. Any advice on how to get this to render smoothly? Cheers, Jake

genmeblog commented 5 years ago

Also, please add a line to the README.md with a name of the example and your nick as an author.

jakeashdown commented 5 years ago

Thanks for the feedback, and so quickly!

I've made the changes suggested here, but the slow rendering is still happening - the spiral re-renders and draws another 90 degree arc, every 1 second exactly. I don't think tStep is an issue, since this should affect the smoothness of of the path itself, but not how quickly it renders.

I have a feeling that something is being cast to an int when we're getting the range of theta, eg frame = 60, range = [ 0, 0.1, ... , 0.9, 1 ] frame = 75, range = [ 0, 0.1, ... , 0.9, 1 ] ... frame = 119, range = [ 0, 0.1, ... , 0.9, 1 ] frame = 120, range = [ 0, 0.1, ... , 0.9, 1, 1.1, ... , 1.9, 2 ] I'll play around with this and see what's up.

Again, thanks :) This is a cool library, and pretty fun as far as learning FP goes!

genmeblog commented 5 years ago

frame and fps have long type , so division is integer. That's why you get one second ticks. Try what I suggested (t (/ frame 60.0)) or (t (/ frame (double fps))) or just set fps as double type. This way you'll get longer rang each frame (still depends on tStep)

jakeashdown commented 5 years ago

I added an oscillation to the radius to make this a bit more fun.