diff --git a/8thWeek/Canny/Canny.pde b/8thWeek/Canny/Canny.pde new file mode 100644 index 0000000..0cd579b --- /dev/null +++ b/8thWeek/Canny/Canny.pde @@ -0,0 +1,68 @@ +PImage img; +PImage board1Thresholded; +HScrollbar thresholdBar0; +HScrollbar thresholdBar1; + +void settings() { + size(1600, 600); +} + +void setup() { + thresholdBar0 = new HScrollbar(0, 560, 800, 20); + thresholdBar1 = new HScrollbar(0, 580, 800, 20); + img = loadImage("src/board1.jpg"); + board1Thresholded = loadImage("src/board1Thresholded.bmp"); + noLoop(); // no interactive behaviour: draw() will be called only once. +} + +void draw() { + image(img, 0, 0);//show image + PImage img2 = img.copy();//make a deep copy + img2.loadPixels();// load pixels + + //img2=threshold(img2, (int)map(thresholdBar.getPos(),0,1,0,255), false); + //img2=HueMap(img2, thresholdBar0.getPos(), thresholdBar1.getPos()); + img2=thresholdHSB(img2, 100, 200, 100, 255, 45, 100 ); + + img2.updatePixels();//update pixels + image(img2, img.width, 0); + /*thresholdBar0.display(); + thresholdBar0.update(); + thresholdBar1.display(); + thresholdBar1.update();*/ + + println(imagesEqual(img2,board1Thresholded)); +} + +PImage threshold(PImage img, int threshold, boolean inverted) { + PImage result = createImage(img.width, img.height, RGB); + for (int i = 0; i < img.width * img.height; i++) { + result.pixels[i]=brightness(img.pixels[i])>threshold^inverted?color(255):color(0); + } + return result; +} + +PImage thresholdHSB(PImage img, int minH, int maxH, int minS, int maxS, int minB, int maxB) { + PImage result = createImage(img.width, img.height, RGB); + for (int i = 0; i < img.width * img.height; i++) { + if (hue(img.pixels[i]) 1) { + sliderPosition = sliderPosition + (newSliderPosition - sliderPosition); + } + } + + /** + * @brief Clamps the value into the interval + * + * @param val The value to be clamped + * @param minVal Smallest value possible + * @param maxVal Largest value possible + * + * @return val clamped into the interval [minVal, maxVal] + */ + float constrain(float val, float minVal, float maxVal) { + return min(max(val, minVal), maxVal); + } + + /** + * @brief Gets whether the mouse is hovering the scrollbar + * + * @return Whether the mouse is hovering the scrollbar + */ + boolean isMouseOver() { + if (mouseX > xPosition && mouseX < xPosition+barWidth && + mouseY > yPosition && mouseY < yPosition+barHeight) { + return true; + } else { + return false; + } + } + + /** + * @brief Draws the scrollbar in its current state + */ + void display() { + noStroke(); + fill(204); + rect(xPosition, yPosition, barWidth, barHeight); + if (mouseOver || locked) { + fill(0, 0, 0); + } else { + fill(102, 102, 102); + } + rect(sliderPosition, yPosition, barHeight, barHeight); + } + + /** + * @brief Gets the slider position + * + * @return The slider position in the interval [0,1] + * corresponding to [leftmost position, rightmost position] + */ + float getPos() { + return (sliderPosition - xPosition)/(barWidth - barHeight); + } +} diff --git a/8thWeek/Canny/src/board1.jpg b/8thWeek/Canny/src/board1.jpg new file mode 100644 index 0000000..8766422 Binary files /dev/null and b/8thWeek/Canny/src/board1.jpg differ diff --git a/8thWeek/Canny/src/board1Blurred.bmp b/8thWeek/Canny/src/board1Blurred.bmp new file mode 100644 index 0000000..7eb8be8 Binary files /dev/null and b/8thWeek/Canny/src/board1Blurred.bmp differ diff --git a/8thWeek/Canny/src/board1Scharr.bmp b/8thWeek/Canny/src/board1Scharr.bmp new file mode 100644 index 0000000..688672d Binary files /dev/null and b/8thWeek/Canny/src/board1Scharr.bmp differ diff --git a/8thWeek/Canny/src/board1Thresholded.bmp b/8thWeek/Canny/src/board1Thresholded.bmp new file mode 100644 index 0000000..318f1de Binary files /dev/null and b/8thWeek/Canny/src/board1Thresholded.bmp differ diff --git a/8thWeek/Canny/src/board2.jpg b/8thWeek/Canny/src/board2.jpg new file mode 100644 index 0000000..dd326b2 Binary files /dev/null and b/8thWeek/Canny/src/board2.jpg differ diff --git a/8thWeek/Canny/src/board3.jpg b/8thWeek/Canny/src/board3.jpg new file mode 100644 index 0000000..8c1bbd3 Binary files /dev/null and b/8thWeek/Canny/src/board3.jpg differ diff --git a/8thWeek/Canny/src/board4.jpg b/8thWeek/Canny/src/board4.jpg new file mode 100644 index 0000000..34fa5cc Binary files /dev/null and b/8thWeek/Canny/src/board4.jpg differ diff --git a/8thWeek/Canny/src/nao.jpg b/8thWeek/Canny/src/nao.jpg new file mode 100644 index 0000000..1bce331 Binary files /dev/null and b/8thWeek/Canny/src/nao.jpg differ diff --git a/Project/Game/ParticleWin.pde b/Project/Game/ParticleWin.pde index a4149e9..3a9b2c6 100644 --- a/Project/Game/ParticleWin.pde +++ b/Project/Game/ParticleWin.pde @@ -1,74 +1,72 @@ class ParticleWin { Mover emitter; ArrayList list=new ArrayList(); float ttl=1;//time to live float size=20; float f; float timeInterval; float prevF; PShape p=new PShape(); ParticleWin(Mover m) { emitter=m; p = createShape(); p.beginShape(TRIANGLES); p.vertex(0, 0, 0); p.vertex(size, 0,0); - p.vertex(size, size, size); + p.vertex(size, -size, size); p.vertex( 0,0, size); - p.vertex(0, size, 0); - p.vertex(size, size, 0); + p.vertex(0, -size, 0); + p.vertex(size, -size, 0); p.endShape(); p.setStroke(false); } void draw(){ if (frameCount-prevF>=timeInterval*frameRate && !shiftMod) { timeInterval=random(0, 0.2); prevF=frameCount; list.add(new smallP(emitter.location.copy())); } ArrayList toBeDestroyed=new ArrayList(); for(smallP sp:list){ sp.draw(); if(sp.isDead()){ toBeDestroyed.add(sp); } } list.removeAll(toBeDestroyed); } class smallP{ PVector loc; PVector speed; float ttl=100; color c; smallP(PVector loc){ this.loc=loc; speed=new PVector(random(-1,1),random(-1,1),random(0,0.5)); c=color((int)random(50,200),(int)random(50,200),(int)random(50,200)); } void draw(){ ttl--; speed.x+=random(-1,1); speed.y+=random(-1,1); speed.z+=random(-1,1); loc.add(speed); gameSurface.pushMatrix(); gameSurface.translate(loc.x,-plate_t+min(-loc.z,0),loc.y); p.setFill(c); - gameSurface.noStroke(); - gameSurface.emissive(c); gameSurface.shape(p); gameSurface.emissive(0); gameSurface.popMatrix(); } boolean isDead(){ return ttl<0; } } }