basic javascript graphics + sound
Now we get to the fun stuff! In this class we covered basic
graphics operations in javascript, and showed how to coordinate
them with sound-proudcing Tone.js processes.
Links
Class Downloads
- week10-html-files.zip
-- all the html/javascript files we created in class (covered below).
First we did some basic graphics, drawing, mouse-click-collecting,
etc.:
- graphics1.html
-- draw a red rectangle
- graphics1a.html
-- draw a red rectangle, but use browser width/height (try resizing
your browser and reloading the code)
- graphics2.html
-- draw green rectangles where the mouse is clicked
- graphics2a.html
-- draw randomly-colored/sized rectangles on a black background
- graphics3.html
-- animate the drawing of random lines
- graphics4.html
-- animate a moving rectangle, see different clearing methods and effects
use your "view source" browser capability to see the code of these
examples, or reference them from the download archive above
Then we added sound and got progressively more complex. I use an
older style coding approach, so much of this could be done more
'elegantly', plus the logic gets a little tangled because of the
way I am setting flags to cause things to happen. Yes there are
better ways to do this...