Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize gradient background Picture and download it automatically by HTML5

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article "HTML5 how to achieve gradient background picture and automatically download" article most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "HTML5 how to achieve gradient background picture and automatically download" article it.

The code is as follows:

Html5 draws a gradual background picture and downloads it automatically

/ / step 1: get the canvas object

Var c = document.getElementById ("c")

/ / step 2: get the context object of the canvas object

Var context = c.getContext ("2d")

/ *

* these are other graphic codes for drawing.

Context.beginPath ()

Context.lineWidth=10

Context.strokeStyle= "red"

Context.moveTo (50 and 50)

Context.lineTo (150,50,50,500)

Context.stroke ()

Context.closePath ()

/ / context.strokeRect (220, 50, 50, 50, 50)

Context.fillStyle= "blue"

Context.fillRect (220, 50, 50, 50)

Context.beginPath ()

Context.arc (1501501501505050500pm Math.PIZUBUR 180RHUT 180mm Math.PICUBUP 180 false)

Context.lineTo (150150)

Context.closePath ()

Context.stroke ()

Context.lineWidth=1

Context.font= "50px Song style"

Context.fillText ("briup", 0220)

Context.save ()

Context.translate (50 and 50)

Context.rotate (90*Math.PI/180)

Context.beginPath ()

Context.lineWidth=10

Context.strokeStyle= "red"

Context.moveTo (0Pol 0)

Context.lineTo (100pi 0)

Context.stroke ()

Context.closePath ()

Context.restore ()

, /

Var g = context.createLinearGradient (0je 0penol 0200)

G.addColorStop (0, "90BFFF")

G.addColorStop (1, "white")

Context.fillStyle = g

Context.fillRect (0d01,1200)

_ window.location = c.toDataURL ("image/jpeg") .replace ("image/jpeg", "image/octet-stream")

The above is about "HTML5 how to achieve gradient background pictures and automatically download" the content of this article, I believe we all have a certain understanding, I hope the content shared by the editor will be helpful to you, if you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report