Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
* { margin:0; padding:0; } html, body { width:100%; height:100%; overflow: hidden; background:black;} canvas { display:block; } #controls { z-index: 2; margin: 20px; position: absolute; top: 0; left: 0; color: white; }
JavaScript
let size = 150; class Flower{ constructor(s, a1, a2){ let l = pow(random(), 2)*size; let l2 = random(); this.l2 = l2; this.x = cos(a1)*(l + l2*size/2); this.y = sin(a1)*(l + l2*size/2); this.hue = random(); this.goalX = this.x; this.goalY = this.y; this.dx = 10; this.dy = 10; this.s = s*(l2*.5 + .5); this.a = a1; this.squash = 1 - (l/size)*.8; this.weights = []; for (let i = 0; i < 5; i++){ this.weights[i] = random()*.5 + .5; } } update(){ this.x += this.dx; this.y += this.dy; this.dx *= .95; this.dy *= .95; let mx = (width/2 + this.x) - mouseX; let my = (height/2 + this.y) - mouseY; let d = dist(width/2 + this.x, height/2 + this.y, mouseX, mouseY); let a = atan2(my, mx); if (d > 1){ this.dx += cos(a)*size/d; this.dy += sin(a)*size/d; } this.x = (this.goalX + this.x)/2; this.y = (this.goalY + this.y)/2; } renderStem(){ pushPop(() => { noFill(); strokeWeight(this.l2*2 + 1); stroke(.35, 1, this.l2*.5 + .5); translate(this.x, size); let a = PI; if (this.x <= 0) a += PI/2; arc(0, 0, this.x*2, (this.y)*2 - size*2, a, a+PI/2); }) } render(){ pushPop(() => { noStroke(); fill(this.l2*.2 + .8); translate(this.x, this.y); rotate(this.a); scale(this.s*this.squash, this.s); for (let j = 0; j < 2; j++) for (let i = 0; i < 5; i++){ let a = i*TAU/5; let s = this.weights[i]; let b = (this.l2*.2 + .8)*(s*.1 + .9) fill(this.hue, .1*this.l2, b); if (j == 0){ s += .05; fill(0); } ellipse(cos(a)*.7*s, sin(a)*.7*s, 1); } fill(0); ellipse(0, 0, .7*(this.weights[0] + .05)); fill(.15, 1, 1*(this.l2*.2 + .8)); ellipse(0, 0, .7*this.weights[0]); }) } } function setup (){ pixelDensity(1); createCanvas(); colorMode(HSB, 1, 1, 1); windowResized(); } function init(){ flowers = []; for (let i = 0; i < 50; i++){ flowers.push( new Flower(random(20) + 20, random(PI*.8) + PI + PI*.1) ); } flowers = flowers.sort((a, b) => a.s - b.s); } function draw(){ background(0); translate(width/2, height/2); flowers.map(f => f.update()); flowers.map(f => f.renderStem()); flowers.map(f => f.render()); } function windowResized(){ resizeCanvas(windowWidth, windowHeight); init(); } let pushPop = f => {push();f();pop();}
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>canvas花-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号