diff --git a/CombSort/CombSort.pde b/CombSort/CombSort.pde index cc53db4..e129995 100644 --- a/CombSort/CombSort.pde +++ b/CombSort/CombSort.pde @@ -1,4 +1,4 @@ -final int amount = 100; +final int amount = 250; final float timeout = 2.5; ArrayList bars; @@ -13,8 +13,8 @@ float tenPercentHeight; float ninetyPercentHeight; void setup() { - // fullScreen(); - size(1280, 720, P3D); + fullScreen(P3D); + // size(1280, 720, P3D); distance = amount-1; tenPercentHeight = height * 0.1; @@ -25,7 +25,7 @@ void setup() { } barWidth = (float)width / amount; - frameRate(120); + frameRate(250); } void draw() { diff --git a/QuickSort/QuickSort.pde b/QuickSort/QuickSort.pde index 7f1dfa6..f184a8e 100644 --- a/QuickSort/QuickSort.pde +++ b/QuickSort/QuickSort.pde @@ -1,22 +1,37 @@ -final float timeout = 5; +final float timeout = 2; ArrayList bars = new ArrayList(); ArrayList queue = new ArrayList(); -int mQL = 1, aQL = 0, amount = 500; +int mQL = 1, aQL = 0, amount = 100; float barWidth = 10f; int sortedFrameCountCapture = -1; +void init() { + amount = floor(random(100, 750)); + barWidth = (float)width / amount; + bars = new ArrayList(); + for (int i = 0; i < amount; i++) { + // bars.add(round(map(i,0,amount-1,0,width/2))); + // bars.add(round(random(width/2))); + bars.add(round(random(height * 0.1, height * 0.9))); + } + // int counter = 0; + // while (counter < 2*amount) { + // int i = floor(random(bars.size())); + // int j = floor(random(bars.size())); + // int t = bars.get(i); + // bars.set(i, bars.get(j)); + // bars.set(j, t); + // counter++; + // } +} + void setup() { - fullScreen(P3D); + fullScreen(P2D); // size(1280, 720); - // amount = floor(random(100, 750)); - // barWidth = (float)width / amount; - for (int i = 0; i < amount; i++) { - bars.add(round(random(width/2))); - // bars.add(round(random(height * 0.1, height * 0.9))); - } + init(); queue.add(new Job(0, amount-1)); frameRate(amount); @@ -26,7 +41,7 @@ void draw() { background(0); noStroke(); - // stroke(0); + stroke(0); for (int i = 0; i < bars.size(); i++) { // stroke(255); fill(255); @@ -44,13 +59,13 @@ void draw() { } } // line(i, height, i, height-bars.get(i)); - // rect(i * barWidth, height, barWidth, -bars.get(i)); + rect(i * barWidth, height, barWidth, -bars.get(i)); // ellipse(i * barWidth + barWidth / 2, height - bars.get(i), barWidth, barWidth); - final float a = map(i, 0, bars.size()-1, 0, 12*TWO_PI); - final float r = bars.get(i); - final float x = width/2 + cos(a) * r; - final float y = height/2 + sin(a) * r; - ellipse(x, y, barWidth, barWidth); + // final float a = map(i, 0, bars.size()-1, 0, 12*TWO_PI); + // final float r = bars.get(i); + // final float x = width/2 + cos(a) * r; + // final float y = height/2 + sin(a) * r; + // ellipse(x, y, barWidth, barWidth); } /*if (queue.size() > 0) { @@ -63,16 +78,10 @@ void draw() { if (queue.size() == 0) { if (sortedFrameCountCapture == -1) { sortedFrameCountCapture = frameCount; - } else if (frameCount-sortedFrameCountCapture>=round((amount/2)*timeout)) { + } else if (frameCount-sortedFrameCountCapture>=round(frameRate*timeout)) { sortedFrameCountCapture = -1; - // amount = floor(random(100, 750)); - // barWidth = (float)width / amount; - bars = new ArrayList(); - for (int i = 0; i < amount; i++) { - bars.add(round(random(width/2))); - // bars.add(round(random(height * 0.1, height * 0.9))); - } + init(); queue.add(new Job(0, amount-1)); mQL = 1;