Canvas knowledge summary and canvas knowledge
1. Basic Knowledge
There are two ways to draw an image by using the canvas element:
Context. fill () // fill in context. stroke () // draw the border
Style: Set the style of the drawing before drawing.
Context. fillStyle // filled style context. strokeStyle // border style context. lineWidth // graphic Border Width
Co
Canvas label, Canvas's Chinese meaning is "canvas", and its performance in the Web page, but also the role of the canvas.
Some browsers do not support canvas tags, and then see the text message in the Canvas tab.The default width of the
Html canvas non-square rotation and scaling... most of the content is written in the square. Some people say they have been reading the square. canvas Scaling
HTML5 canvas (Shadow), html5 canvas shadow
Case 1:
Note:(1) shadowOffsetX: the horizontal displacement of the shadow, that is, the distance from the horizontal movement of the image;ShadowOffsetY: the vertical displacement of the shadow, that is, the distance from the vertical direction;ShadowColor-the shadow color;ShadowBlur-specifies the Blur range of the Shadow. This attribute is optional.
Comments: Determine whether the browser supports canvas. I have collected and sorted out some usage methods. If you are interested, you can check whether the browser supports canvas. The specific code is as follows:The Code is as follows:
The circular motion of canvas learning, and the circle of canvas Learning
Html section
...
Circular MotionRelated Knowledge: trigonometric functionMethod: place the shape on the circumference and the angle is 0 radian on the right hand side. In each animation loop, you only need to increase the angle of the Shape on the circumference, the shape can be moved along the circumference.Problems to be Solved:How
Canvas copies the characters of the matrix and canvas copies the matrix.?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
"en">"UTF-8">"color:red;text-align:center;font-size:20px;"> Binary rain "myCanvas"width="1000px"height="600px"style="background-color:black;">
This is the result of the previous blog. The ph
){Super (context );
Int x= 10;Int y= 10;Int width= 300;Int height= 50;
Mdrawable= Newshapedrawable (newovalshape ());Mdrawable. getpaint (). setcolor (0xff74ac23 );Mdrawable. setbounds (X,Y, X+ Width, y+ Height );}
ProtectedvoidOndraw (canvas ){Mdrawable. Draw (canvas );}}In the constructor in the above example, shapedrawable is defined as an ovalshape object, and then a color and border are set for it. If
Canvas and canvas
The last time I wrote the prize was a year ago. At that time, I was confused by Baidu's source code. This time, I asked my sister to write the code and thought about how to sort it out again.
Write a simple canvas program for HTML5 canvas
Ideas:
Get the coordinates of CTX. moveTo (E. clientX-10, E. clientY-10) when pressed, and then move the mouse on the wire continuously ,! Isdown | CTX. lineto (E. clientX-10, E. clientY-10, 5, 5) when the mouse is opened, naturally it is necessary to set isdown to false.Then summarize the key steps of the draw line.The first step is to obtain the canvas.Step
123456789Ten - the the - in the[JavaScript Canvas Ispointinpath (x, y) determines whether a point is in the last drawing] JavaScript canvas ispointinpath (x, y) determines whether the point is one of the methods shown in the last drawing
123456789Ten at - About $ - -[HTML canvas drawing text] Canvas drawing implements drawing text Stroketext Filltext method and TextAlign textbaseline Font Property Instance Demo
situation.Of course, if you pull the control point very far, maybe the graph will become you don't know. Let's try it out:
y1 = 950;
I just changed the Y1 a bit, and then the curve went beyond the canvas.However, Quadraticcurveto draw the range of the curve, can never reach or exceed the coordinates of the control point, we only have to "control" the control point is good, do not worry.I have written a simple, movable example page that shows the process of drawing a curve in Quadr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.