mardi 27 septembre 2016

Making random rectangles w/ random (linewidth,color, and position)

I'm completely new to compute programming I've got an "Intro to JavaScript" class that I'm in and we've been asked to create a very basic HTML code using canvas that has randomly drawn rectangles with linewidths, colors, and positions.

This class uses w3schools as a teaching aid (I've seen it bashed for being outdated), and has referenced us there.

I'm supposed to use;

 function getRandomColor() {   
 var chars = '0123456789ABCDEF'.split('');
 var hex = '#';
 for (var i = 0; i < 6; i++) {
    hex += chars[Math.floor(Math.random() * 16)];
 }
 return hex;
 }

and manipulate this functions properties to make;

 function getRandomlinewidth() 

//this function sets the line width of the rectangles ranging between 1 and 8.

Hoping someone could point me in the right direction? Also any "new to JS" or "JS for beginners" tutorials or similar are VERY appreciated!

Cheers!




1 commentaire:

  1. try w3schools for a tutorial. i'm doing literally the same assignment and am stuck

    RépondreSupprimer