Advertisement
xeromino

arrow

Mar 7th, 2016
392
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PImage arrow;
  2. int edge = 40, sz = 25, frms = 90;
  3. float theta;
  4.  
  5. void setup() {
  6.   size(540, 540);
  7.   arrow = loadImage("arrow.png");
  8.   arrow.resize(sz, 0);
  9.   imageMode(CENTER);
  10. }
  11.  
  12. void draw() {
  13.   background(200);
  14.   for (int x=edge+sz; x<width-edge; x += sz*2) {
  15.     for (int y=edge+sz; y<height-edge; y+= sz*2) {
  16.       float distance = dist(x, y, width/2, height/2);
  17.       float r = map(distance, 0, sqrt(sq(width/2)+sq(height/2)), 0, HALF_PI);
  18.       pushMatrix();
  19.       translate(x, y);
  20.       rotate(theta+r);
  21.       image(arrow, 0, 0);
  22.       popMatrix();
  23.     }
  24.   }
  25.   textAlign(RIGHT);
  26.   fill(0, 150);
  27.   text("p5art.tumblr.com", width-60, height-10);
  28.   if (frameCount<=frms) saveFrame("image-###.gif");
  29.   theta += TWO_PI/frms;
  30. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement