Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[] values;
- int i = 0, j = 1;
- int items = 5000;
- int strokeWeight;
- int currentIndex = 0;
- void setup() {
- fullScreen(P2D);
- //frameRate(10);
- //size (800, 500);
- if (items > width) {
- items = width;
- }
- strokeWeight = width/items;
- values = new float[items];
- for (int x = 0; x < values.length; x++) {
- values[x] = noise(x) * height;
- }
- }
- void swap(float[] arr, int a, int b) {
- float temp = arr[a];
- arr[a] = arr[b];
- arr[b] = temp;
- }
- void draw() {
- background(0);
- if (i < values.length - 1) {
- int minIndex = i;
- for (j = i + 1; j < values.length; j++) {
- if (values[j] < values[minIndex]) {
- println(values[j] + "<" + values[minIndex]);
- minIndex = j;
- }
- }
- swap(values, minIndex, i);
- i += 1;
- } else {
- println("Finished");
- i++;
- noLoop();
- }
- for (int n = 0; n < values.length; n++) {
- stroke(255);
- if((strokeWeight - 2) < 1){
- strokeWeight(strokeWeight);
- }else{
- strokeWeight(strokeWeight - 2);
- }
- if (n < i) {
- stroke(0, 255, 0);
- }
- line(n * strokeWeight + (strokeWeight / 2), height, n * strokeWeight + (strokeWeight / 2), height - values[n]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement