p5实现canvas 70年代的椭圆形纹理效果代码
代码语言:html
所属分类:其他
代码描述:p5实现canvas 70年代的椭圆形纹理效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { margin: 0; padding: 0; } canvas { width: 500px; height: 500px; max-width: 100vw; max-height: 100vh; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); border: 2px solid #8DA5B2; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.7.0.js"></script> <script > console.clear(); const palette = [ "#708d81", "#f4d58d", "#bf0603", ]; const itemWidth = 100; const itemHeight = window.innerHeight * .5; const strokeSize = .333; let globalRand = 0; let count = 3; let img; function preload() { img = loadImage('//repo.bfw.wiki/bfwrepo/image/6505438f47d0b.png'); } function setup() { createCanvas(windowWidth,windowHeight); background(0); noStroke(); // OVALS for(let round = 0; round < count; round++) { globalRand = random() * 1000; if(round > 0) { blendMode(SOFT_LIGHT); } drawOvals(round); } // TEXTURE tint(255, 90); image(img, 0, 0, width, height); } function drawOvals(round) { for(x = 0; x < width+itemWidth; x += itemWidth) { let rand = noise(x, globalRand); rand = (rand-.5)*2*(round+1); const y = itemHeight*rand; fill(random(palette)); drawOval(x, .........完整代码请登录后点击上方下载按钮下载查看
网友评论0