mirror of
https://github.com/euphy/polargraphcontroller
synced 2024-11-14 02:07:57 +01:00
Crazy rocking cool. Now working. No funky gamepad interface, but workflow works.
This commit is contained in:
parent
ab2bf8b251
commit
33f5642fa9
@ -448,11 +448,26 @@ class DisplayMachine extends Machine
|
|||||||
|
|
||||||
public void displayVectorImage()
|
public void displayVectorImage()
|
||||||
{
|
{
|
||||||
displayVectorImage(getVectorShape(), color(0,0,0), true);
|
displayVectorImage(getVectorShape(), vectorScaling/100, getVectorPosition(), color(0,0,0), true);
|
||||||
|
|
||||||
|
if (captureShape != null)
|
||||||
|
{
|
||||||
|
float scaling = inMM(getPictureFrame().getWidth()) / captureShape.getWidth();
|
||||||
|
PVector position = new PVector(inMM(getPictureFrame().getPosition().x), inMM(getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
|
||||||
|
displayVectorImage(captureShape,
|
||||||
|
scaling,
|
||||||
|
position,
|
||||||
|
color(0,200,0), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayVectorImage(RShape vec, int strokeColour, boolean drawCentroid)
|
public void displayVectorImage(RShape vec, float scaling, PVector position, int strokeColour, boolean drawCentroid)
|
||||||
{
|
{
|
||||||
|
PVector centroid = new PVector(vec.width/2, vec.height/2);
|
||||||
|
centroid = PVector.mult(centroid, (vectorScaling/100));
|
||||||
|
centroid = PVector.add(centroid, getVectorPosition());
|
||||||
|
centroid = scaleToScreen(centroid);
|
||||||
|
|
||||||
RPoint[][] pointPaths = vec.getPointsInPaths();
|
RPoint[][] pointPaths = vec.getPointsInPaths();
|
||||||
RG.ignoreStyles();
|
RG.ignoreStyles();
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
@ -466,8 +481,8 @@ class DisplayMachine extends Machine
|
|||||||
for (int j = 0; j<pointPaths[i].length; j++)
|
for (int j = 0; j<pointPaths[i].length; j++)
|
||||||
{
|
{
|
||||||
PVector p = new PVector(pointPaths[i][j].x, pointPaths[i][j].y);
|
PVector p = new PVector(pointPaths[i][j].x, pointPaths[i][j].y);
|
||||||
p = PVector.mult(p, (vectorScaling/100));
|
p = PVector.mult(p, scaling);
|
||||||
p = PVector.add(p, getVectorPosition());
|
p = PVector.add(p, position);
|
||||||
if (getPage().surrounds(inSteps(p)))
|
if (getPage().surrounds(inSteps(p)))
|
||||||
{
|
{
|
||||||
p = scaleToScreen(p);
|
p = scaleToScreen(p);
|
||||||
@ -482,10 +497,6 @@ class DisplayMachine extends Machine
|
|||||||
if (drawCentroid)
|
if (drawCentroid)
|
||||||
{
|
{
|
||||||
// draw spot at centre
|
// draw spot at centre
|
||||||
PVector centroid = new PVector(vec.width/2, vec.height/2);
|
|
||||||
centroid = PVector.mult(centroid, (vectorScaling/100));
|
|
||||||
centroid = PVector.add(centroid, getVectorPosition());
|
|
||||||
centroid = scaleToScreen(centroid);
|
|
||||||
fill(255,0,0,128);
|
fill(255,0,0,128);
|
||||||
ellipse(centroid.x, centroid.y, 20,20);
|
ellipse(centroid.x, centroid.y, 20,20);
|
||||||
noFill();
|
noFill();
|
||||||
|
@ -127,7 +127,18 @@ void button_mode_liveCaptureFromLive()
|
|||||||
|
|
||||||
void button_mode_liveConfirmDraw()
|
void button_mode_liveConfirmDraw()
|
||||||
{
|
{
|
||||||
sendVectorShapes(captureShape);
|
// work out scaling and position
|
||||||
|
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth();
|
||||||
|
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
|
||||||
|
|
||||||
|
// float scaling = getDisplayMachine().getPictureFrame().getWidth() / captureShape.getWidth();
|
||||||
|
// println("Scaling: " + scaling);
|
||||||
|
//
|
||||||
|
// PVector position = getDisplayMachine().getPictureFrame().getPosition();
|
||||||
|
//
|
||||||
|
// println("CApture shape: " + captureShape);
|
||||||
|
|
||||||
|
sendVectorShapes(captureShape, scaling, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
63
drawing.pde
63
drawing.pde
@ -640,14 +640,17 @@ void sendOutlineOfBox()
|
|||||||
|
|
||||||
void sendVectorShapes()
|
void sendVectorShapes()
|
||||||
{
|
{
|
||||||
sendVectorShapes(getVectorShape());
|
sendVectorShapes(getVectorShape(), vectorScaling/100, getVectorPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendVectorShapes(RShape vec)
|
void sendVectorShapes(RShape vec, float scaling, PVector position)
|
||||||
{
|
{
|
||||||
println("Send vector shapes.");
|
println("Send vector shapes.");
|
||||||
RPoint[][] pointPaths = vec.getPointsInPaths();
|
RPoint[][] pointPaths = vec.getPointsInPaths();
|
||||||
|
|
||||||
|
// sort the paths to optimise the draw sequence
|
||||||
|
pointPaths = sortPathLongestFirst(pointPaths);
|
||||||
|
|
||||||
String command = "";
|
String command = "";
|
||||||
PVector lastPoint = new PVector();
|
PVector lastPoint = new PVector();
|
||||||
boolean liftToGetToNewPoint = true;
|
boolean liftToGetToNewPoint = true;
|
||||||
@ -659,7 +662,7 @@ void sendVectorShapes(RShape vec)
|
|||||||
{
|
{
|
||||||
boolean firstPointFound = false;
|
boolean firstPointFound = false;
|
||||||
|
|
||||||
List<PVector> filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength);
|
List<PVector> filteredPoints = filterPoints(pointPaths[i], VECTOR_FILTER_LOW_PASS, minimumVectorLineLength, scaling, position);
|
||||||
//println(filteredPoints);
|
//println(filteredPoints);
|
||||||
if (!filteredPoints.isEmpty())
|
if (!filteredPoints.isEmpty())
|
||||||
{
|
{
|
||||||
@ -695,12 +698,52 @@ void sendVectorShapes(RShape vec)
|
|||||||
println("finished.");
|
println("finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PVector> filterPoints(RPoint[] points, int filterToUse, long filterParam)
|
public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths)
|
||||||
{
|
{
|
||||||
return filterPointsLowPass(points, filterParam);
|
// put the paths into a list
|
||||||
|
List<RPoint[]> pathsList = new ArrayList<RPoint[]>(pointPaths.length);
|
||||||
|
for (int i = 0; i<pointPaths.length; i++)
|
||||||
|
{
|
||||||
|
if (pointPaths[i] != null)
|
||||||
|
{
|
||||||
|
pathsList.add(pointPaths[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println("PathsList: ");
|
||||||
|
for (RPoint[] path : pathsList)
|
||||||
|
println(path.length + ", ");
|
||||||
|
|
||||||
|
// sort the list
|
||||||
|
Collections.sort(pathsList, new Comparator<RPoint[]>() {
|
||||||
|
public int compare(RPoint[] o1, RPoint[] o2) {
|
||||||
|
if (o1.length > o2.length) {
|
||||||
|
return -1;
|
||||||
|
} else if (o1.length < o2.length) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
println("Sorted PathsList: ");
|
||||||
|
for (RPoint[] path : pathsList)
|
||||||
|
println(path.length + ", ");
|
||||||
|
|
||||||
|
for (int i=0; i<pathsList.size(); i++)
|
||||||
|
{
|
||||||
|
pointPaths[i] = pathsList.get(i);
|
||||||
|
}
|
||||||
|
return pointPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
|
List<PVector> filterPoints(RPoint[] points, int filterToUse, long filterParam, float scaling, PVector position)
|
||||||
|
{
|
||||||
|
return filterPointsLowPass(points, filterParam, scaling, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PVector> filterPointsLowPass(RPoint[] points, long filterParam, float scaling, PVector position)
|
||||||
{
|
{
|
||||||
List<PVector> result = new ArrayList<PVector>();
|
List<PVector> result = new ArrayList<PVector>();
|
||||||
|
|
||||||
@ -710,8 +753,8 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
|
|||||||
{
|
{
|
||||||
RPoint firstPoint = points[j];
|
RPoint firstPoint = points[j];
|
||||||
PVector p = new PVector(firstPoint.x, firstPoint.y);
|
PVector p = new PVector(firstPoint.x, firstPoint.y);
|
||||||
p = PVector.mult(p, (vectorScaling/100));
|
p = PVector.mult(p, scaling);
|
||||||
p = PVector.add(p, getVectorPosition());
|
p = PVector.add(p, position);
|
||||||
p = getDisplayMachine().inSteps(p);
|
p = getDisplayMachine().inSteps(p);
|
||||||
if (getDisplayMachine().getPage().surrounds(p))
|
if (getDisplayMachine().getPage().surrounds(p))
|
||||||
{
|
{
|
||||||
@ -734,7 +777,7 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
|
|||||||
|
|
||||||
if (abs(diffx) > filterParam || abs(diffy) > filterParam)
|
if (abs(diffx) > filterParam || abs(diffy) > filterParam)
|
||||||
{
|
{
|
||||||
println("Adding point " + p + ", last: " + result.get(result.size()-1));
|
//println("Adding point " + p + ", last: " + result.get(result.size()-1));
|
||||||
result.add(p);
|
result.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -743,7 +786,7 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
|
|||||||
if (result.size() < 2)
|
if (result.size() < 2)
|
||||||
result.clear();
|
result.clear();
|
||||||
|
|
||||||
println("finished filter.");
|
//println("finished filter.");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,9 +459,9 @@ static PImage processedCapturedImage = null;
|
|||||||
|
|
||||||
JMyron liveCamera;
|
JMyron liveCamera;
|
||||||
BlobDetector blob_detector;
|
BlobDetector blob_detector;
|
||||||
int liveSimplification = 2;
|
int liveSimplification = 4;
|
||||||
int blurValue = 1;
|
int blurValue = 1;
|
||||||
int posterizeValue = 8;
|
int posterizeValue = 12;
|
||||||
int sepKeyColour = color(0, 0, 255);
|
int sepKeyColour = color(0, 0, 255);
|
||||||
|
|
||||||
Map<Integer, PImage> colourSeparations = null;
|
Map<Integer, PImage> colourSeparations = null;
|
||||||
@ -809,6 +809,7 @@ void drawWebcamPage()
|
|||||||
if (displayingInfoTextOnInputPage)
|
if (displayingInfoTextOnInputPage)
|
||||||
showText(250,45);
|
showText(250,45);
|
||||||
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
|
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
|
||||||
|
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user