Graphic JavaScript


Back to index
This pattern was created using SVG. Inspecting the values
used for points in polygon will reveal certain patterns which
will enable you to write an efficient and reusable JavaScript
function to produce a hexagon.
ASSIGNMENT:

Here's a basic embedded for-loop:


  for(x=0;x<3;x++){
    for(y=0;y<2;y++){
       drawHEX(10+x*70,10+y*70);
    }
  }

You can use this (or something very similar to it) to help produce calls to drawHex loaded with appropriate values. Of course, you will have to figure out how to write drawHex! Your assignment is to recreate the design shown to the left, only do it in JavaScript.