Added dpad stuff, and some workflow.

This commit is contained in:
Sandy Noble 2013-03-31 21:42:33 +01:00
parent f02873b218
commit 4b10190eba
6 changed files with 56 additions and 25 deletions

View File

@ -141,17 +141,17 @@ void button_mode_liveConfirmDraw()
{ {
if (captureShape != null) if (captureShape != null)
{ {
// save shape as SVG confirmedDraw = true;
// work out scaling and position // work out scaling and position
float scaling = getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getWidth()) / captureShape.getWidth(); 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)); PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
sendVectorShapes(captureShape, scaling, position); sendVectorShapes(captureShape, scaling, position);
webcam_saveShape(captureShape);
button_mode_penUp(); button_mode_penUp();
// save shape as SVG
webcam_saveShape(captureShape);
} }
} }

BIN
data/dpadlr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

BIN
data/dpadud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@ -714,9 +714,6 @@ public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths, int highPassCutoff
} }
} }
for (RPoint[] path : pathsList)
println(path.length + ", ");
// sort the list // sort the list
Collections.sort(pathsList, new Comparator<RPoint[]>() { Collections.sort(pathsList, new Comparator<RPoint[]>() {
public int compare(RPoint[] o1, RPoint[] o2) { public int compare(RPoint[] o1, RPoint[] o2) {
@ -746,12 +743,14 @@ List<RPoint[]> removeShortPaths(List<RPoint[]> list, int cutoff)
{ {
if (cutoff > 0) if (cutoff > 0)
{ {
int numberOfPaths = list.size()-1; int numberOfPaths = list.size();
for (int i=0; i<numberOfPaths; i++) ListIterator<RPoint[]> it = list.listIterator();
while (it.hasNext())
{ {
if (cutoff >= list.get(i).length) RPoint[] paths = it.next();
if (paths == null || cutoff >= paths.length)
{ {
list.remove(i); it.remove();
} }
} }
} }

View File

@ -113,13 +113,25 @@ void processGamepadInput()
{ {
if (signalFromGamepad != null) if (signalFromGamepad != null)
{ {
println("Signal from gamepad: " + signalFromGamepad);
if (signalFromGamepad == BUTTON_A_RELEASED) if (signalFromGamepad == BUTTON_A_RELEASED)
if (captureShape == null) {
if (captureShape == null && !confirmedDraw)
button_mode_liveCaptureFromLive(); button_mode_liveCaptureFromLive();
else else if (captureShape != null && !confirmedDraw)
button_mode_liveClearCapture(); button_mode_liveClearCapture();
else if (captureShape != null && confirmedDraw)
{
button_mode_liveClearCapture();
button_mode_clearQueue();
confirmedDraw = false;
}
}
else if (signalFromGamepad == BUTTON_B_RELEASED) else if (signalFromGamepad == BUTTON_B_RELEASED)
{
if (captureShape != null && !confirmedDraw)
button_mode_liveConfirmDraw(); button_mode_liveConfirmDraw();
}
// clear the signal // clear the signal

View File

@ -461,6 +461,7 @@ public boolean useWindowedConsole = false;
static boolean drawingLiveVideo = false; static boolean drawingLiveVideo = false;
static boolean drawingWebcamShape = true; static boolean drawingWebcamShape = true;
static boolean flipWebcamImage = true; static boolean flipWebcamImage = true;
static boolean confirmedDraw = false;
static PImage liveImage = null; static PImage liveImage = null;
static PImage processedLiveImage = null; static PImage processedLiveImage = null;
@ -495,6 +496,9 @@ PImage xButtonImage = null;
PImage aButtonImage = null; PImage aButtonImage = null;
PImage bButtonImage = null; PImage bButtonImage = null;
PImage dpadXImage = null;
PImage dpadYImage = null;
void setup() void setup()
{ {
println("Running polargraph controller"); println("Running polargraph controller");
@ -883,23 +887,37 @@ void drawImageLoadPage()
void displayGamepadOverlay() void displayGamepadOverlay()
{ {
textSize(40); textSize(40);
fill(255);
if (captureShape == null) if (captureShape == null)
{ {
image(aButtonImage, width-190, height-180, 128, 128); image(aButtonImage, width-400, height-180, 128, 128);
fill(255); text("SNAP!", width-400, height-200);
text("SNAP!", width-180, height-200);
textSize(30);
image(dpadYImage, width-600, height-180, 128, 128);
text("Simplify", width-600, height-200);
image(dpadXImage, width-600, height-400, 128, 128);
text("Filter short paths", width-600, height-420);
}
else
{
if (confirmedDraw)
{
image(aButtonImage, width-400, height-180, 128, 128);
text("CANCEL!", width-385, height-200);
} }
else else
{ {
image(aButtonImage, width-400, height-180, 128, 128); image(aButtonImage, width-400, height-180, 128, 128);
fill(255);
text("BACK", width-400, height-200); text("BACK", width-400, height-200);
image(bButtonImage, width-190, height-180, 128, 128); image(bButtonImage, width-190, height-180, 128, 128);
fill(255);
text("DRAW!", width-180, height-200); text("DRAW!", width-180, height-200);
} }
}
textSize(12); textSize(12);
@ -3013,6 +3031,8 @@ void initImages()
xButtonImage = loadImage("x.png"); xButtonImage = loadImage("x.png");
aButtonImage = loadImage("a.png"); aButtonImage = loadImage("a.png");
bButtonImage = loadImage("b.png"); bButtonImage = loadImage("b.png");
dpadXImage = loadImage("dpadlr.png");
dpadYImage = loadImage("dpadud.png");
} }
catch (Exception e) catch (Exception e)
{ {