How to realize gradient background Picture and download it automatically by HTML5
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.