Skip to content

Instantly share code, notes, and snippets.

@RshStone
Last active August 4, 2020 10:16
Show Gist options
  • Save RshStone/84690dc96f41625d147249b19076eccd to your computer and use it in GitHub Desktop.
Save RshStone/84690dc96f41625d147249b19076eccd to your computer and use it in GitHub Desktop.
Canvas
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).
<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>
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";
}
.greenback{
background-color: green;
}
canvas{
width:200pt;
height:100pt;
margin:10px;
border: 1px solid lightgray;
}
@RshStone
Copy link
Author

RshStone commented Aug 4, 2020

Canvas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment