How to Use HTML5 Canvas to make water ripple effects, html5canvas
Today, we will continue to shareJavaScriptThis article describes how to implement water ripple using JavaScript. The watermark effect is triggered when any image is clicked. Sometimes, we use commonJavascriptYou can create an interesting solution.
Download demo source code online
Step 1. HTML
As before, first of allHTMLCode:
Step 2. CSS
Thi
Recently, I suddenly want to study the js rotating image function. We will not talk about the previous implementation method first. Now HTML5 is quite good. Let's take a look at the image rotation in HTML5.
Example:
Http://www.imqing.com/demo/rotateImg.html
Principle:Use the canvas object to rotate.
Implementation Meth
The example in this article describes how the PHP implementation will save the canvas image to the server in HTML5. Share to everyone for your reference. The implementation methods are as follows:
First, the question:
When HTML5 was not popular a few years ago, our project manager asked me to ask the project review e
should be implemented by browsers that support HTML5). Finally, the clientX of the event object is used, clientY minus left and top returned by the getBoundingClientRect method.
The following is the implementation code:
//
In this way, a simple mouse painting function is completed, and there are also shortcomings, such as the inability to draw points... I personally think it is still relatively weak to use can
Draw a rectangle in HTML5 Canvas, html5canvasThis article describes how to draw a rectangle in HTML5 Canvas. This article uses three APIs: fillRect, strokeRect, and clearRect. For more information, see
This article is translated from Steve Fulton Jeff Fulton HTML5
After reading several canvas-related articlesArticleAnd the first twoCodeThere is still a problem with implementation, because there is little knowledge, so we can only implement it on the knowledge we know. But fortunately, this is a process of discovery and a process of correction and improvement. I tried to write my blog for the first time. I think this will also help me to learn more. I can learn more about it, but forget it slowly at least :).
Detailed description of how to specify the color and transparency when drawing HTML5 Canvas, html5canvas
Color
Black is the default color drawn by Canvas. To change the color, you must specify the color before the actual painting.Copy the content to the clipboard using JavaScript Code
Ctx. strokeStyle = color
Specify the line color:Copy the content to the cli
1. Draw the line1.1 "Configure the canvas" before drawing (no longer mentioned later)Example IntroductionFirst set a point of the canvas style has a property to make it have a border (good observation), centered (Display:block, the canvas must first be set to block-level elements, the margin is set to the central only
method, but less efficientFunction BezierEllipse2 (ctx, x, y, a, B){Var k =. 5522848,Ox = a * k, // horizontal control point offsetOy = B * k; // Vertical Control Point offsetCtx. beginPath ();// Draw four cubic besell curves clockwise from the left endpoint of the ellipseCtx. moveTo (x-a, y );Ctx. bezierCurveTo (x-a, y-oy, x-ox, y-B, x, y-B );Ctx. bezierCurveTo (x + ox, y-B, x + a, y-oy, x + a, y );Ctx. bezierCurveTo (x + a, y + oy, x + ox, y + B, x, y + B );Ctx. bezierCurveTo (x-ox, y + B, x-
Use the HTML5 Canvas API to draw arcs and circles. html5canvas
In html5, The CanvasRenderingContext2D object also provides methods specifically used to draw circles or arcs. For details, refer to the following attributes and methods:Copy the content to the clipboard using JavaScript Code
Arc (x, y, radius, startRad, endRad, anticlockwise)
Draw an arc of a cir
Comments: Recently I have been studying html5, which involves a key element canvas-canvas. After searching and researching, I have finally implemented a simple animation for super Mary. I would like to share with you the following, I hope to help beginners. I recently studied html5, which involves the
only two lines of code:var canvas = document.getElementById (' tutorial ');var ctx = Canvas.getcontext (' 2d ');First get the Canvas object, and then call the canvas object's GetContext method, this method can only pass in the parameter "2d", in the near future he may support the parameter "3d", you must understand what that means, let us look forward to it.The
; default: this. boom ++;Break;} This. draw ();Console. log (this. score );},};
In section 3 of the design, we talked about the wild stars and bombs. I am too lazy and don't want to talk about them, because these processes are not complicated, the basic learning of HTML5 Canvas is also acceptable. Later, we should learn more in-depth things, such as how to handle performance, object collision, and kinematic
I. preface this tutorial will explain how to use html5 to combine small map blocks into large maps and how to use the existing advanced html5 game development library lufylegend. js to develop games. First, let's get to know how to use html5 to implement animation. After all, "Dynamic and Static combination" means firs
position is a global variable interference with each other very much, but because step is a local variable, a different copy is called, and the last two laps are executed to 99 drawid setinterval The method is executed in turn, resulting in sangle location is the virtual point of jumping.
local variables: var step, Sangle, Eangle, X, Y, R but note that the same canvas and contact are used in the
HTML5 Canvas draws dotted line instances, html5canvasThis article mainly introduces the example of using HTML5 Canvas to draw dotted lines. HTML5 does not provide a dotted line method. This article is based on the method of Stack
Note: For the sake of convenience, this development uses the open Source Engine lufylegend, the official address is as follows: Http://lufylegend.com/lufylegendLearn about the HTML5 Canvas color animation today. What is color animation? In my understanding, it is the transition from one color to another. And the effect is a bit similar: Http://w3school.com.cn/tiy/t.asp?f=css3_animation1 above the demo is im
);Cxt.drawimage (img,125,125);Cxt.drawimage (img,210,210);
Generate page effects based on the code you write
Picture morphing: Changing the size of the image, you need to use the overloaded DrawImage function to give it the desired width and height parameters.
The code is as followsvar myimage=document.getelementbyidx_x ("MyCanvas");var Cxt=myimage.getcontext ("2d");var img=new Image ();Img.src= "Tu0.jpg";Cxt.drawimage (img,50,50,100,100);Cxt.drawimage (img,125,125,200,50);Cxt.drawimage
elliptic.
// --------- Use cubic besell curves to simulate an elliptic 2 ---------------------
// This method also produces when the lineWidth is wider and the ellipse is relatively flat.
// The long axis is sharp and insmooth.
// This method is more accurate than the previous besell method, but less efficient
Function BezierEllipse2 (ctx, x, y, a, B)
{
Var k =. 5522848,
Ox = a * k, // horizontal control point offset
Oy = B * k; // Vertical Control Point offset
Ctx. beginPath ()
HTML5 Canvas transform is a matrix transformation, a kind of coordinate deformation.Three ways to deform coordinates, pan translate, scale scales, and rotate rotate can all be done by transform.Transform (M11, M12, M21, M22, DX, dy): This method must multiply the current transformation matrix by the following matrix:
M11
M21
Dx
M12
M22
Dy
0
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.