kopia lustrzana https://github.com/gwygonik/SquiggleDraw
Rework how row reversing is done. Rows are now calculated identically if reversed or not. We build arrays of X and Y points for each row. Then, we reverse those lists -- to only change the order that the vertices are added to the curve -- if the row should be drawn in reverse order.pull/16/head
rodzic
cef4e2ffb4
commit
554213dd1e
|
@ -137,7 +137,7 @@ void loadMainImage(String inImageName) {
|
||||||
if (tempheight < 720 + 120)
|
if (tempheight < 720 + 120)
|
||||||
tempheight = 720 + 120;
|
tempheight = 720 + 120;
|
||||||
|
|
||||||
surface.setSize(p1.width + 150, tempheight);
|
surface.setSize(p1.width + 165, tempheight);
|
||||||
|
|
||||||
// filter image
|
// filter image
|
||||||
p1.filter(GRAY);
|
p1.filter(GRAY);
|
||||||
|
@ -283,7 +283,6 @@ void createPic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Step along width of image.
|
Step along width of image.
|
||||||
|
|
||||||
|
@ -340,34 +339,21 @@ void createPic() {
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (reverseRow)
|
x = 1;
|
||||||
{
|
lastX = 1;
|
||||||
x = p2.width;
|
|
||||||
lastX = p2.width;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
x = 1;
|
|
||||||
lastX = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
float[] xPoints = new float[0];
|
||||||
|
float[] yPoints = new float[0];
|
||||||
|
|
||||||
while (finalStep == false) { // Iterate over each each x-step in the row
|
while (finalStep == false) { // Iterate over each each x-step in the row
|
||||||
|
|
||||||
if (reverseRow)
|
// Moving right to left:
|
||||||
{ // Moving left to right on even rows
|
x += xstep;
|
||||||
x -= xstep;
|
if (x + xstep >= p2.width)
|
||||||
if (x - xstep < 1)
|
finalStep = true;
|
||||||
finalStep = true;
|
else
|
||||||
else
|
finalStep = false;
|
||||||
finalStep = false;
|
|
||||||
} else
|
|
||||||
{ // Moving right to left as usual
|
|
||||||
x += xstep;
|
|
||||||
if (x + xstep >= p2.width)
|
|
||||||
finalStep = true;
|
|
||||||
else
|
|
||||||
finalStep = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
b = (int)alpha(p2.get(x, y));
|
b = (int)alpha(p2.get(x, y));
|
||||||
b = max(minB, b);
|
b = max(minB, b);
|
||||||
|
@ -432,11 +418,23 @@ void createPic() {
|
||||||
lastPhase = lastPhase + HALF_PI;
|
lastPhase = lastPhase + HALF_PI;
|
||||||
lastAmpl = lastAmpl + amplPerVertex;
|
lastAmpl = lastAmpl + amplPerVertex;
|
||||||
|
|
||||||
curveVertex(xOffset + scaleFactor * lastX, scaleFactor *(y+sin(lastPhase)*lastAmpl));
|
xPoints = append(xPoints, xOffset + scaleFactor * lastX);
|
||||||
|
yPoints = append(yPoints, scaleFactor *(y+sin(lastPhase)*lastAmpl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reverseRow)
|
||||||
|
{
|
||||||
|
xPoints = reverse(xPoints);
|
||||||
|
yPoints = reverse(yPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < xPoints.length; i++) {
|
||||||
|
curveVertex(xPoints[i], yPoints[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add final "extra" point to give splines a consistent visual endpoint:
|
// Add final "extra" point to give splines a consistent visual endpoint:
|
||||||
if (reverseRow)
|
if (reverseRow)
|
||||||
{
|
{
|
||||||
|
@ -480,7 +478,6 @@ void createPic() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void fileSelected(File selection) {
|
void fileSelected(File selection) {
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
println("Window was closed or the cancel selected.");
|
println("Window was closed or the cancel selected.");
|
||||||
|
@ -634,4 +631,4 @@ void bangDefault() {
|
||||||
// println("Full");
|
// println("Full");
|
||||||
// isInit = false;
|
// isInit = false;
|
||||||
// loadMainImage(imageName);
|
// loadMainImage(imageName);
|
||||||
//}
|
//}
|
||||||
|
|
Ładowanie…
Reference in New Issue