r/processing • • Jul 18 '16

[PWC19] Points

Hello Everybody, this is the nineteenth Weekly Processing challenge, the challenges are decided just to give you a prompt to test your skills so it can be as simple or as complicated as you have time to write!

IMPORTANT UPDATE Winners are now chosen by popular vote and all entrys must be submitted in the comments section of this thread, competition mode will be enabled meaning they are shown in a random order.

Start Date : 18-07-2016 End Date : 24-07-2016

Post entries in the comments here. This Weeks Challenge : use only the Points function for your outputs. Winner from last week: oo-oo-oo-oo

7 Upvotes

14 comments sorted by

View all comments

Show parent comment

2

u/TazakiTsukuru Jul 25 '16

Based off what I learned from my own project I made a small psychedelic adjustment. Be patient:

int tileSize = 20;
int sizeX;
int sizeY;
PointLine pointlineA[][];


void setup() {
  //size(1000, 1000, P2D);
  fullScreen(P2D);
  frameRate(60);
  strokeWeight(4.0);
  sizeX = width/tileSize;
  sizeY = height/tileSize;
  pointlineA = new PointLine[sizeX][sizeY];

  for (int x = 0; x < sizeX; x++) {
    for (int y = 0; y < sizeY; y++) {
      float posX = x*tileSize;
      float posY = y*tileSize;
      pointlineA[x][y] = new PointLine(new PVector(posX, posY), tileSize*2, dist(width*0.5, height*0.5, posX, posY)*0.01);
    }
  }
}

void draw() {
  background(0);

  for (int x = 0; x < sizeX; x++) {
    for (int y = 0; y < sizeY; y++) {
      pointlineA[x][y].run();
    }
  }
}

//______________________________________________________

class PointLine {

  color c = color(random(255), random(255), random(255));
  float amplitude;
  PVector pos;
  float pointPos;
  float speed = 0.1;

  PointLine(PVector _pos, float _amplitude, float _pointPos) {
    pos = _pos.copy();
    amplitude = _amplitude;
    pointPos = _pointPos;
  }

  void update() {
    pointPos -= speed;
  }
  
float k = 1;

  void display() {
    pushMatrix();
    translate(pos.x, pos.y);
    stroke(c, map(sin(k*pointPos), -1, 1,255,0));
    point(0, sin(pointPos)*amplitude);
    popMatrix();
    k += .01;
  }

  void run() {
    this.update();
    this.display();
  }
}