JavaScript

Javascript code to convert light wavelength to color

In the electromagnetic spectrum illustration and light color, frequency and wavelength post, I needed to calculate color from wavelength value. I tried a few different approaches but finally settled on a modified version of some widely cited FORTRAN code for determining RGB values.

Draw an oval in html5 canvas

The JavaScript canvas element does not have a native method for drawing ovals (ellipses).

Drawing regular polygons in javascript canvas

Geometric shapes such as regular polygons are useful building blocks for drawing more complex elements within JavaScript canvas tags. The following block shows 3, 4, 5, 6, 7, 8, 9 and 10 sided regular polygons.
Subscribe to RSS - JavaScript