janvas实现canvas华为鸿蒙操作系统开机动画效果代码
代码语言:html
所属分类:动画
代码描述:janvas实现canvas华为鸿蒙操作系统开机动画效果代码
代码标签: janvas canvas 华为 鸿蒙 操作系统 开机 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body{ background: black; } </style> </head> <body > <div id="app"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/janvas.js"></script> <script > new janvas.Canvas({ container: "#app", duration: 4000, width: 800, height: 400, props: { leftText: "Harmony", centerText: "O", rightText: "S" }, methods: { init: function () { var ctx = this.$ctx, w = this.$width, h = this.$height, font = w / 2 + "px sans-serif", blur = w / 10; this.bg = new janvas.Rect(ctx, 0, 0, w, h); this.top = new janvas.Rect(ctx, 0, 0, w, h / 2); this.bottom = new janvas.Rect(ctx, 0, h / 2, w, h / 2); this.centerTop = this._getText(w / 2, h / 2, this.centerText, font, "center", blur); var offsetY = h / 2 - (this.centerTop.getTop() + this.centerTop.getBottom()) / 2, startY = h / 2 + offsetY; this.centerTop.setStartY(startY); this.centerBottom = this._getText(w / 2, startY, this.centerText, font, "center", blur); var centerWidth = this.centerTop.getWidth(); this.centerTop.getMatrix().setOffsetY(centerWidth / 2); this.centerBottom.getMatrix().setOffsetY(-centerWidth / 2); this.left = this._getText(w / 2 - centerWidth / 2, startY, this.leftText, font, "right"); this.right = this._getText(w / 2 + centerWidth / 2, startY, this.rightText, font, "left"); var targetScale = w * 0.8 / (this.right.getRight() - this.left.getLeft()), originX = (this.left.getLeft() * targetScale - w * 0.1) / (targetScale - 1), originY = h / 2; this.line = new janvas.Line(ctx, -w / 100, originY + w / 4, -w / 100, originY + w / 4); this.line.getStyle().setLineWidth(w / 50).setStrokeStyle("rgb(0, 128, 255)").setLineCap("round"); this._transforms = [this.centerTop, this.centerBottom, this.left, this.right, this.line]; for (var i = 0; i < this._transforms.length; i++) { this._transforms[i].setOrigin(originX, originY); } this.shadow = new janvas.Arc(ctx, w / 2, h / 2, 0).setOrigin(w / 2, h / 2); var grd = janvas.Utils.createRadialGradient(0, 0, 0, 0, 0, centerWidth, this.shadow), sep = 0.2; grd.a.........完整代码请登录后点击上方下载按钮下载查看
网友评论0