Last active
August 4, 2020 10:16
-
-
Save RshStone/84690dc96f41625d147249b19076eccd to your computer and use it in GitHub Desktop.
Canvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gOPZwBj | |
------- | |
A [Pen](https://codepen.io/rshstone/pen/gOPZwBj) by [Justin](https://codepen.io/rshstone) on [CodePen](https://codepen.io). | |
[License](https://codepen.io/rshstone/pen/gOPZwBj/license). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Qishaoqing</h1> | |
<canvas id = "d1" > | |
</canvas> | |
<canvas id = "d2" > | |
</canvas> | |
<p> | |
<input type = "button" value = "make green" onclick = "doGreen()"> | |
<input type = "button" value = "make yellow" onclick = "doYellow()"> | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doGreen(){ | |
var dd1 = document.getElementById("d1"); | |
dd1.style.backgroundColor = "green"; | |
var context = dd1.getContext("2d"); | |
context.fillStyle = "yellow"; | |
context.fillRect(10,10,60,60); | |
context.fillRect(80,10,60,60); | |
context.fillStyle = "black"; | |
context.font = "20px Arial"; | |
context.fillText("Hello",15,45); | |
} | |
function doYellow(){ | |
var dd2 = document.getElementById("d2"); | |
dd2.style.backgroundColor = "yellow"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.greenback{ | |
background-color: green; | |
} | |
canvas{ | |
width:200pt; | |
height:100pt; | |
margin:10px; | |
border: 1px solid lightgray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Canvas