Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the template of html5 confession

Shulou Source: shulou.com Published: 2022-06-01 05:52:48 10月03日 Update

This article mainly explains the "html5 confession template how to achieve", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "html5 confession template how to achieve" it!

The HTML code is as follows:

(function () {

Var canvas=$ ('# ke'+'leyi')

If (! Canvas [0] .getContext) {

$("# error") Show ()

Return false;}

Var width=canvas.width ()

Var height=canvas.height ()

Canvas.attr ("width", width)

Canvas.attr ("height", height)

Var opts= {

Seed: {

X: width / 2-20

Color: "rgb (190,26,37)"

Scale: 2

}

Branch: [

[535, 680, 570, 250, 500, 200, 30, 100, [

[540, 500, 455, 417, 340, 400, 13, 100, [

[450, 435, 434, 430, 394, 395, 2, 40]

]]

[550, 445, 600, 356, 680, 345, 12, 100, [

[578, 400, 648, 409, 661, 426, 3, 80]

]]

[539, 281, 537, 248, 534, 217, 3, 40]

[546, 397, 413, 247, 328, 244, 9, 80, [

[427, 286, 383, 253, 371, 205, 2, 40]

[498, 345, 435, 315, 395, 330, 4, 60]

]]

[546, 357, 608, 252, 678, 221, 6, 100, [

[590, 293, 646, 277, 648, 271, 2, 80]

]]

]]

]

Bloom: {

Num: 700

Width: 1080

Height: 650

}

Footer: {

Width: 1200

Height: 5

Speed: 10

}

}

Var tree=new Tree (canvas [0], width, height, opts)

Var seed=tree.seed

Var foot=tree.footer

Var hold=1

Canvas.click (function (e) {

Var offset=canvas.offset (), x, y

X=e.pageX-offset.left

Y=e.pageY-offset.top

If (seed.hover (x, y)) {

Hold=0

Canvas.unbind ("click")

Canvas.unbind ("mousemove")

Canvas.removeClass ('hand')

}

}). Mousemove (function (e) {

Var offset=canvas.offset (), x, y

X=e.pageX-offset.left

Y=e.pageY-offset.top

Canvas.toggleClass ('hand', seed.hover (x, y))

})

Var seedAnimate=eval (Jscex.compile ("async", function () {

Seed.draw ()

While (hold) {

$await (Jscex.Async.sleep (10))

}

While (seed.canScale ()) {

Seed.scale (0.95)

$await (Jscex.Async.sleep (10))

}

While (seed.canMove ()) {

Seed.move (0,2)

Foot.draw ()

$await (Jscex.Async.sleep (10))

}

}))

Var growAnimate=eval (Jscex.compile ("async", function () {

Do {

Tree.grow ()

$await (Jscex.Async.sleep (10))

} while (tree.canGrow ())

}))

Var flowAnimate=eval (Jscex.compile ("async", function () {

Do {

Tree.flower (2)

$await (Jscex.Async.sleep (10))

} while (tree.canFlower ())

}))

Var moveAnimate=eval (Jscex.compile ("async", function () {

Tree.snapshot ("p1", 240,0610,680)

While (tree.move ("p1", 500,0)) {

Foot.draw ()

$await (Jscex.Async.sleep (10))

}

Foot.draw ()

Tree.snapshot ("p2", 500,0610,680)

/ / there will be flashes that do not proudly do so, (> please <)

Canvas.parent (). Css ("background", "url (" + tree.toDataURL ('image/png') + "))

Canvas.css ("background", "# ffe")

$await (Jscex.Async.sleep)

Canvas.css ("background", "none")

}))

Var jumpAnimate=eval (Jscex.compile ("async", function () {

Var ctx=tree.ctx

While (true) {

Tree.ctx.clearRect (0,0, width, height)

Tree.jump ()

Foot.draw ()

Await (Jscex.Async.sleep (25))

}

}))

Var textAnimate=eval (Jscex.compile ("async", function () {

$("# code") Show (). Typewriter ()

}))

Var runAsync=eval (Jscex.compile ("async", function () {

Await (seedAnimate ())

Await (growAnimate ())

Await (flowAnimate ())

Await (moveAnimate ())

TextAnimate (). Start ()

Await (jumpAnimate ())

}))

RunAsync (). Start ()

) ()

Applicable browsers: 360,360, FireFox, Chrome, Safari, Opera, Aoyou, Sogou, window of the World. IE8 and below browsers are not supported.

Thank you for your reading, the above is the content of "how to achieve the html5 confession template". After the study of this article, I believe you have a deeper understanding of how to achieve the html5 confession template, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Templates learning content browsing browsing world window of the world code that is ideas situations Sogou articles more knowledge knowledge points articles follow questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Microsoft MySQL Xiaomi