Detailed explanation of HTML5 basics Canvas
What is Canvas?
In the new HTML standard HTML5, the Canvas element is used to draw graphics on web pages. The power of this element tag is that it can directly perform graphic operations on HTML, which has great Value.
The canvas is a rectangular area that you can control every pixel of.
Canvas has multiple ways to draw paths, rectangles, circles, characters, and add images to create rich graphic references.
Let’s look at a piece of code
<article>
<header>
<meta charset="utf-8">
</header>
<canvas id="canvas" width="150" height="150"></canvas>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(0,0,200)";
ctx.fillRect(10, 10, 50, 50);
</script>
</article>Draw a rectangle through javascript
Let’s look at an example and draw a circle
<article>
<header>
<meta charset="utf-8">
</header>
<canvas id="myCanvas" width="200" height="100"></canvas>
<script>
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.beginPath();
cxt.arc(70,18,15,0,Math.PI*2,true);
cxt.closePath();
cxt.fill();
</script>
</article>
new file
<article>
<header>
<meta charset="utf-8">
</header>
<canvas id="canvas" width="150" height="150"></canvas>
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(0,0,200)";
ctx.fillRect(10, 10, 50, 50);
</script>
</article>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















