Skip to content

Commit 9e8ae10

Browse files
committed
landscape vs portrait fitting
1 parent 8130f27 commit 9e8ae10

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

GUI.pde

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class ControlFrame extends PApplet {
105105

106106
cp5.addSlider("flipTime")
107107
.plugTo(parent, "flipSpeed")
108-
.setRange(2, 100)
108+
.setRange(2, 200)
109109
.setValue(30)
110110
.setPosition(20, 460)
111111
.setSize(w-100, 20)
@@ -144,8 +144,7 @@ public class ControlFrame extends PApplet {
144144
}
145145
}
146146

147-
public void reload() {
148-
loadSrcs();
147+
public void reload() {
149148
loadSource();
150149
}
151150
public void nextImage() {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ That's it!
3535

3636
Let's go through what the control window let's you do:
3737

38-
* Play = play/pause
38+
* Play = starts and stops the pixel sorting
3939
* Reload = restart the sorting on the current image
4040
* Wrap = toggle wrapping pixels on image edges on/off (default: on)
4141

pixelSortLive.pde

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ String[] photoSets = {
2525
"cosmos", "desert" // more albums here
2626
};
2727

28+
2829
// Each photo set may contain jpg photos of any size but they are
2930
// to be named "poly0.jpg", "poly1.jpg", "poly2.jpg", and so on.
3031

@@ -80,9 +81,9 @@ void setup() {
8081
selectSet(0);
8182
loadSrcs();
8283
loadSource();
83-
84+
imageMode(CENTER);
8485
background(0);
85-
image(source, ( width-output.width)/2, 0);
86+
image(source,width/2,height/2);
8687
}
8788

8889
void draw() {
@@ -97,7 +98,7 @@ void draw() {
9798
output = cellSort(source);
9899
output.updatePixels();
99100
background(0);
100-
image(output, ( width-output.width)/2, 0);
101+
image(output, width/2,height/2);
101102

102103
if (printFrame) {
103104
println("printing");
@@ -130,14 +131,21 @@ void loadSrcs() {
130131

131132
void loadSource() {
132133
loaded=false;
134+
polySrc[nImg] = loadImage(photoSets[nSet]+"/poly"+nImg+".jpg");
133135
source = polySrc[nImg];
134-
source.resize(width, 0);
136+
137+
if(source.height > source.width){
138+
source.resize(0,height); // portrait
139+
}
140+
else{
141+
source.resize(width,0); // landscape
142+
}
135143
output = source;
136144
imageMode(CENTER);
137145
background(0);
138146
image(source,width/2,height/2);
139147
//image(source, (width-source.width)/2, (height-source.height)/2);
140-
imageMode(CORNER);
148+
//imageMode(CORNER);
141149
loaded = true;
142150
}
143151

0 commit comments

Comments
 (0)