Crazy rocking cool. Now working. No funky gamepad interface, but workflow works.

This commit is contained in:
Sandy Noble 2013-03-30 23:27:19 +00:00
parent ab2bf8b251
commit 33f5642fa9
4 changed files with 87 additions and 21 deletions

View File

@ -448,11 +448,26 @@ class DisplayMachine extends Machine
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();
RG.ignoreStyles();
strokeWeight(1);
@ -466,8 +481,8 @@ class DisplayMachine extends Machine
for (int j = 0; j<pointPaths[i].length; j++)
{
PVector p = new PVector(pointPaths[i][j].x, pointPaths[i][j].y);
p = PVector.mult(p, (vectorScaling/100));
p = PVector.add(p, getVectorPosition());
p = PVector.mult(p, scaling);
p = PVector.add(p, position);
if (getPage().surrounds(inSteps(p)))
{
p = scaleToScreen(p);
@ -482,10 +497,6 @@ class DisplayMachine extends Machine
if (drawCentroid)
{
// 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);
ellipse(centroid.x, centroid.y, 20,20);
noFill();

View File

@ -127,7 +127,18 @@ void button_mode_liveCaptureFromLive()
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);
}

View File

@ -640,14 +640,17 @@ void sendOutlineOfBox()
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.");
RPoint[][] pointPaths = vec.getPointsInPaths();
// sort the paths to optimise the draw sequence
pointPaths = sortPathLongestFirst(pointPaths);
String command = "";
PVector lastPoint = new PVector();
boolean liftToGetToNewPoint = true;
@ -659,7 +662,7 @@ void sendVectorShapes(RShape vec)
{
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);
if (!filteredPoints.isEmpty())
{
@ -695,12 +698,52 @@ void sendVectorShapes(RShape vec)
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]);
}
}
List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
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> 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>();
@ -710,8 +753,8 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
{
RPoint firstPoint = points[j];
PVector p = new PVector(firstPoint.x, firstPoint.y);
p = PVector.mult(p, (vectorScaling/100));
p = PVector.add(p, getVectorPosition());
p = PVector.mult(p, scaling);
p = PVector.add(p, position);
p = getDisplayMachine().inSteps(p);
if (getDisplayMachine().getPage().surrounds(p))
{
@ -734,7 +777,7 @@ List<PVector> filterPointsLowPass(RPoint[] points, long 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);
}
}
@ -743,7 +786,7 @@ List<PVector> filterPointsLowPass(RPoint[] points, long filterParam)
if (result.size() < 2)
result.clear();
println("finished filter.");
//println("finished filter.");
return result;
}

View File

@ -459,9 +459,9 @@ static PImage processedCapturedImage = null;
JMyron liveCamera;
BlobDetector blob_detector;
int liveSimplification = 2;
int liveSimplification = 4;
int blurValue = 1;
int posterizeValue = 8;
int posterizeValue = 12;
int sepKeyColour = color(0, 0, 255);
Map<Integer, PImage> colourSeparations = null;
@ -809,6 +809,7 @@ void drawWebcamPage()
if (displayingInfoTextOnInputPage)
showText(250,45);
drawStatusText((int)statusTextPosition.x, (int)statusTextPosition.y);
showCommandQueue((int) getDisplayMachine().getOutline().getRight()+6, 20);
}