Html5 canvas: Draw up and down floating Fonts

Source: Internet
Author: User

The main idea of drawing up and down float fonts is to first draw the desired font, clear the canvas at a certain time, and then change the font position and draw it in such a loop.



(Function (window ){
Var flowLogo = function (logo, x, font ){
This. logo = logo;
This. x = x;
This. font = font | "25px Verdana ";
}
FlowLogo. prototype. flow = function (start, min, max, increment, time, container ){
Var logo = this. logo;
Container. font = this. font;
Var x = this. x;
Var logoWidth = container. measureText (logo). width;
Container. strokeStyle = "white ";
Var forward = true;
Var changeInterval = setInterval (function (){
Container. clearRect (x, 0, logoWidth, max + 10 );
Container. strokeText (logo, x, start, logoWidth, 20 );
If (forward ){
Start + = increment;
} Else {
Start-= increment;
}
If (start <min | start> max ){
Forward =! Forward;
}
}, Time );
Storage. changeInterval = changeInterval;
}
Window. flowLogo = flowLogo;
}) (Window );

Usage:

Var logo = new flowLogo (text, left );
Logo. flow (40, 40, 60, 2,150, t );

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.