Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d0c9409

Browse files
committed
draws the components on the canvas
1 parent 76e2681 commit d0c9409

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎script.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var canvas = document.getElementById("canvas");
2+
3+
/* Component settings inside the canvas */
4+
var x;
5+
var y;
6+
var width;
7+
var height;
8+
9+
var component1, component2;
10+
11+
function draw_component1(){
12+
x = 50, y = 25, width = 40, height = 40;
13+
component1 = canvas.getContext("2d");
14+
component1.fillRect(x, y, width, height);
15+
canvas.setAttribute("onclick","draw_component2();");
16+
}
17+
18+
function draw_component2(){
19+
x = 50, y = 160, width = 40, height = 40;
20+
component2 = canvas.getContext("2d");
21+
component2.fillStyle = "green";
22+
component2.fillRect(x, y, width, height);
23+
canvas.setAttribute("onclick","clean();");
24+
}
25+
26+
function clean(){
27+
canvas.width = canvas.width;
28+
canvas.setAttribute("onclick","draw_component1();");
29+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /