the function getResult(Pimage) does not exist.
in
Programming Questions
•
1 year ago
but it does!!
Could someone take a look?
Could someone take a look?
int xStep = 5;
int yStep = 5;
int maxStrokeW = 5;
float minStrokeW = 0.25;
EffectStyle eStyle;
PImage img, img2;
void setup() {
size(600, 600);
img = loadImage("1967.jpg");
//eStyle = new SquareStyle(img);
//eStyle = new SquareStyle();
eStyle = new SquareStyle();
eStyle.disableColor(true)
.setXStep(xStep)
.setYStep(yStep)
.setMaxEffectWidth(maxStrokeW)
.setMinEffectWidth(minStrokeW)
.setRotationDegrees(45)
;
img2 = eStyle.getResult(img);
}
void draw() {
image(img2);
}
public class EffectStyle {
boolean disableColor = false;
int xStep = 5;
int yStep = 5;
float maxStrokeW = 5;
float minStrokeW = 0;
float rot = 0;
EffectStyle() {
}
public EffectStyle disableColor(boolean b) {
disableColor = b;
return this;
}
public EffectStyle setXStep(int v) {
xStep = v;
return this;
}
public EffectStyle setYStep(int v) {
yStep = v;
return this;
}
public EffectStyle setMaxEffectWidth(float v) {
maxStrokeW = v;
return this;
}
public EffectStyle setMinEffectWidth(float v) {
minStrokeW = v;
return this;
}
public EffectStyle setRotationDegrees(float r) {
rot = radians(r);
return this;
}
}
public class SquareStyle extends EffectStyle {
public SquareStyle() {
}
public PImage getResult(PImage origImg) {
PImage img = origImg.get();
float r, g, b;
r = g = b = 0;
float bright, strokeW;
pushStyle();
for (int y=0; y < img.height; y += yStep) {
for (int x=0; x < img.width; x += xStep) {
color c= img.get(x, y);
if (!disableColor) {
r = red(c);
g = green(c);
b = blue(c);
}
bright = brightness(c);
strokeW = map(bright, 0, 255, maxStrokeW, minStrokeW);
if (strokeW > 0) {
if (!disableColor) {
fill(r,g,b);
}
//
//strokeWeight(strokeW);
//line(x, y, x,y+step+1);
pushMatrix();
translate(x, y);
rotate(radians(rot));
rect(0, 0, strokeW, strokeW);
popMatrix();
}
}
}
popStyle();
return img;
}
}
1