p5实现一个咖啡戒指效果代码
代码语言:html
所属分类:其他
代码描述:p5实现一个鼠标点击生成一个咖啡戒指效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.0.10.2.js"></script> <script > function setup() { createCanvas(windowWidth, windowHeight); noStroke(); angleMode(DEGREES); background(250); } function draw() { translate(width / 2, height / 2); coffeeRing(); noLoop(); } function coffeeRing() { b = int(random(0, 4)); for (let i = 0; i < b; i++) { d = random(0, 360); r = (150, 210); s = random(2, 45); c = 255 * abs(sin(d)); fill(74 + c / 2, 53 + c / 2, 40 + c / 2, 200); //74, 53, 40 circle(r * sin(d), r * cos(d), s); for (let j = 0; j < 90; j++) { push(); translate( r * sin(d) + random(-s / 2, s / 2), r * cos(d) + random(-s / 2, s / 2) ); rotate(random(0, 90)); ellipse(0, 0, ra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0