Html5 canvas with pattern filling shape, html5canvas

Source: Internet
Author: User

Html5 canvas with pattern filling shape, html5canvas

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
// Simple onload
// Four types of image filling: repeat, no-repeat, repeat-x, repeat-y;
// CreatePattern () Filling image function, an image instance and a filling type
Var fillPattern = context. createPattern (fillImg, 'Repeat-x'); var fillPattern1 = context. createPattern (fillImg, 'Repeat-y'); var fillPattern2 = context. createPattern (fillImg, 'repeat'); context. fillStyle = fillPattern; context. fillRect (,); context. fillStyle = fillPattern1; context. fillRect (,); context. fillStyle = fillPattern2; context. fillRect (,) ;}}</script> <canvas id = "canva S "width =" 500 "height =" 500 "> you cannot use canvas in your browser. If you have any questions, add QQ: 1035417613; Xiaobai kids shoes. Your support is my greatest pleasure !! </Canvas> </body>
Note the image path !!! The rest is similar to the css background.

// Four types of image filling: repeat, no-repeat, repeat-x, repeat-y;
// CreatePattern () Filling image function, an image instance and a filling type

Related Article

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.