daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let radius = 100, // radius: blob 的基准半径
  2. offset = .8, // offset: 根据基准半径的偏移程度
  3. scale = 20, // scale: 形变的程度
  4. speed = .02 // speed: 形变的速度
  5.  
  6. const width = window.innerWidth, height = window.innerHeight
  7.  
  8. function setup() {
  9.     createCanvas(width, height)
  10. }
  11.  
  12. function draw() {
  13.     background(0)
  14.     fill('#ff0000')
  15.     noStroke()
  16.     translate(width / 2, height / 2)
  17.     beginShape()
  18.         for (let i = 0; i < TWO_PI; i += radians(1)) {
  19.  
  20.             let xOff = offset * cos(i) + .2
  21.             let yOff = offset * sin(i) + .2
  22.  
  23.             let r = radius + map(noise(xOff, yOff, speed), 0, 1, -scale, scale)
  24.  
  25.             let x = r * cos(i)
  26.             let y = r * sin(i)
  27.  
  28.             vertex(x, y)
  29.         }
  30.     endShape()
  31.     speed += .01
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top