Time for action – drawing color circles in the Canvas
First, let's set up the new environment for the example. That is, an HTML file that will contain the
canvas
element, a jQuery library to help us in JavaScript, a JavaScript file containing the actual drawing logic, and a style sheet:index.html js/ js/jquery-2.1.3.js js/untangle.js js/untangle.drawing.js js/untangle.data.js js/untangle.input.js css/ css/untangle.css images/
Put the following HTML code into the
index.html
file. It is a basic HTML document containing thecanvas
element:<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Drawing Circles in Canvas</title> <link rel="stylesheet" href="css/untangle.css"> </head> <body> <header> <h1>Drawing in Canvas</h1> </header> <canvas id="game" width="768" height="400"> This is an interactive game with circles and lines connecting them. </canvas>...