Added some images for gamepad buttons. And saving to svg.

This commit is contained in:
Sandy Noble 2013-03-31 20:58:48 +01:00
parent d838d22ea5
commit f02873b218
7 changed files with 74 additions and 0 deletions

View File

@ -150,6 +150,7 @@ void button_mode_liveConfirmDraw()
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x), getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y) + (captureShape.getHeight() * scaling));
sendVectorShapes(captureShape, scaling, position);
webcam_saveShape(captureShape);
button_mode_penUp();
}
}

BIN
data/a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
data/b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
data/x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
data/y.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -485,12 +485,24 @@ Map<Integer, PImage> colourSeparations = null;
RShape webcamShape = null;
RShape captureShape = null;
String shapeSavePath = "../../savedcaptures/";
String shapeSavePrefix = "shape-";
String shapeSaveExtension = ".svg";
boolean displayGamepadOverlay = true;
PImage yButtonImage = null;
PImage xButtonImage = null;
PImage aButtonImage = null;
PImage bButtonImage = null;
void setup()
{
println("Running polargraph controller");
frame.setResizable(true);
initLogging();
initImages();
RG.init(this);
RG.setPolygonizer(RG.ADAPTATIVE);
@ -831,6 +843,8 @@ void drawWebcamPage()
processGamepadInput();
if (displayGamepadOverlay)
displayGamepadOverlay();
}
@ -866,6 +880,31 @@ void drawImageLoadPage()
drawImagePage();
}
void displayGamepadOverlay()
{
textSize(40);
if (captureShape == null)
{
image(aButtonImage, width-190, height-180, 128, 128);
fill(255);
text("SNAP!", width-180, height-200);
}
else
{
image(aButtonImage, width-400, height-180, 128, 128);
fill(255);
text("BACK", width-400, height-200);
image(bButtonImage, width-190, height-180, 128, 128);
fill(255);
text("DRAW!", width-180, height-200);
}
textSize(12);
}
void drawMoveImageOutline()
{
if (MODE_MOVE_IMAGE == currentMode && getDisplayMachine().getImage() != null)
@ -2966,4 +3005,30 @@ void initLogging()
println("Exception setting up logger: " + e.getMessage());
}
}
void initImages()
{
try
{
yButtonImage = loadImage("y.png");
xButtonImage = loadImage("x.png");
aButtonImage = loadImage("a.png");
bButtonImage = loadImage("b.png");
}
catch (Exception e)
{
yButtonImage = makeColourImage(64,64,color(180,180,0));
xButtonImage = makeColourImage(64,64,color(0,0,180));
aButtonImage = makeColourImage(64,64,color(0,180,0));
bButtonImage = makeColourImage(64,64,color(180,0,0));
}
}
PImage makeColourImage(int w, int h, int colour)
{
PImage img = createImage(w,h,RGB);
for(int i=0; i < img.pixels.length; i++) {
img.pixels[i] = colour;
}
return img;
}

View File

@ -166,6 +166,14 @@ public void webcam_captureCurrentImage()
webcam_captureCurrentImage(capturedImage);
}
public void webcam_saveShape(RShape sh)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String dateCode = sdf.format(new java.util.Date());
String filename = shapeSavePath + shapeSavePrefix + dateCode + shapeSaveExtension;
RG.saveShape(filename, sh);
}
public void stop() {
liveCamera.stop();
super.stop();