Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to make a rectangle in javascript

const canvas = document.getElementById('pong') // first make a index . html with a canvas height and width and id of pong or whatever
// and then we have to get access to our context to draw on it
const context = canvas.getContext('2d')

// then you do...

context.drawRect(20, 20, 150, 150);
context.fillStyle = '#fff' // thats white!!
 
PREVIOUS NEXT
Tagged: #rectangle #javascript
ADD COMMENT
Topic
Name
5+5 =