mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-02-22 07:42:51 +01:00
Added buttons
This commit is contained in:
parent
b2f61582f9
commit
5c1755f1a0
@ -352,40 +352,17 @@ class DisplayMachine extends Machine
|
|||||||
noStroke();
|
noStroke();
|
||||||
// draw machine outline
|
// draw machine outline
|
||||||
|
|
||||||
// fill(80);
|
|
||||||
// rect(getOutline().getLeft()+DROP_SHADOW_DISTANCE, getOutline().getTop()+DROP_SHADOW_DISTANCE, getOutline().getWidth(), getOutline().getHeight());
|
|
||||||
|
|
||||||
fill(getMachineColour());
|
fill(getMachineColour());
|
||||||
rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
|
rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (displayingGuides)
|
|
||||||
// {
|
|
||||||
// // draw some guides
|
|
||||||
// stroke(getGuideColour());
|
|
||||||
// strokeWeight(1);
|
|
||||||
// // centre line
|
|
||||||
// line(getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getTop(),
|
|
||||||
// getOutline().getLeft()+(getOutline().getWidth()/2), getOutline().getBottom());
|
|
||||||
//
|
|
||||||
// // page top line
|
|
||||||
// line(getOutline().getLeft(), getOutline().getTop()+sc(getHomePoint().y),
|
|
||||||
// getOutline().getRight(), getOutline().getTop()+sc(getHomePoint().y));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// draw page
|
// draw page
|
||||||
fill(getPageColour());
|
fill(getPageColour());
|
||||||
rect(getOutline().getLeft()+sc(getPage().getLeft()),
|
rect(getOutline().getLeft()+sc(getPage().getLeft()),
|
||||||
getOutline().getTop()+sc(getPage().getTop()),
|
getOutline().getTop()+sc(getPage().getTop()),
|
||||||
sc(getPage().getWidth()),
|
sc(getPage().getWidth()),
|
||||||
sc(getPage().getHeight()));
|
sc(getPage().getHeight()));
|
||||||
text("page " + getDimensionsAsText(getPage()), getOutline().getLeft()+sc(getPage().getLeft()),
|
|
||||||
getOutline().getTop()+sc(getPage().getTop())-3);
|
|
||||||
noFill();
|
noFill();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stroke(getBackgroundColour(),150);
|
stroke(getBackgroundColour(),150);
|
||||||
strokeWeight(3);
|
strokeWeight(3);
|
||||||
noFill();
|
noFill();
|
||||||
@ -406,12 +383,11 @@ class DisplayMachine extends Machine
|
|||||||
|
|
||||||
if (drawingLiveVideo)
|
if (drawingLiveVideo)
|
||||||
{
|
{
|
||||||
drawLiveVideo();
|
displayLiveVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayingVector && getVectorShape() != null)
|
if (displayingVector && getVectorShape() != null)
|
||||||
{
|
{
|
||||||
stroke(100);
|
|
||||||
displayVectorImage(color(200));
|
displayVectorImage(color(200));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,6 +405,40 @@ class DisplayMachine extends Machine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayLiveVideo()
|
||||||
|
{
|
||||||
|
buildLiveImage();
|
||||||
|
// draw actual image
|
||||||
|
if (liveImage != null)
|
||||||
|
{
|
||||||
|
float ox = getOutline().getLeft()+sc(getImageFrame().getLeft());
|
||||||
|
float oy = getOutline().getTop()+sc(getImageFrame().getTop());
|
||||||
|
float w = sc(getImageFrame().getWidth());
|
||||||
|
float h = sc(getImageFrame().getHeight());
|
||||||
|
tint(255, getImageTransparency());
|
||||||
|
translate(ox, oy);
|
||||||
|
rotate(radians(270));
|
||||||
|
image(liveImage, 0, 0, w, h);
|
||||||
|
rotate(radians(-270));
|
||||||
|
translate(-ox,-oy);
|
||||||
|
noTint();
|
||||||
|
noFill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildLiveImage()
|
||||||
|
{
|
||||||
|
liveCamera.update();
|
||||||
|
liveImage = createImage(640,480, RGB);
|
||||||
|
liveImage.loadPixels();
|
||||||
|
// rotate it
|
||||||
|
liveImage.pixels = liveCamera.image();
|
||||||
|
liveImage.filter(BLUR, blurValue);
|
||||||
|
liveImage.filter(GRAY);
|
||||||
|
liveImage.filter(POSTERIZE, posterizeValue);
|
||||||
|
liveImage.updatePixels();
|
||||||
|
}
|
||||||
|
|
||||||
public void displayVectorImage()
|
public void displayVectorImage()
|
||||||
{
|
{
|
||||||
displayVectorImage(color(0,0,0));
|
displayVectorImage(color(0,0,0));
|
||||||
|
@ -131,11 +131,14 @@ class Panel
|
|||||||
{
|
{
|
||||||
for (Controller c : this.getControls())
|
for (Controller c : this.getControls())
|
||||||
{
|
{
|
||||||
|
println("Control: " + c.name());
|
||||||
PVector pos = getControlPositions().get(c.name());
|
PVector pos = getControlPositions().get(c.name());
|
||||||
float x = pos.x+getOutline().getLeft();
|
float x = pos.x+getOutline().getLeft();
|
||||||
float y = pos.y+getOutline().getTop();
|
float y = pos.y+getOutline().getTop();
|
||||||
c.setPosition(x, y);
|
c.setPosition(x, y);
|
||||||
|
|
||||||
|
println("controlsizes: " + getControlSizes());
|
||||||
|
|
||||||
PVector cSize = getControlSizes().get(c.name());
|
PVector cSize = getControlSizes().get(c.name());
|
||||||
c.setSize((int)cSize.x, (int)cSize.y);
|
c.setSize((int)cSize.x, (int)cSize.y);
|
||||||
|
|
||||||
|
@ -108,6 +108,24 @@ void button_mode_sendPenliftRange()
|
|||||||
addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END");
|
addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void numberbox_mode_liveBlurValue(int value)
|
||||||
|
{
|
||||||
|
blurValue = value;
|
||||||
|
}
|
||||||
|
void numberbox_mode_liveSimplificationValue(int value)
|
||||||
|
{
|
||||||
|
liveSimplification = value;
|
||||||
|
}
|
||||||
|
void numberbox_mode_livePosteriseValue(int value)
|
||||||
|
{
|
||||||
|
posterizeValue = value;
|
||||||
|
}
|
||||||
|
void button_mode_liveCaptureFromLive()
|
||||||
|
{
|
||||||
|
addToCommandQueue(CMD_SETPENLIFTRANGE+penLiftDownPosition+","+penLiftUpPosition+",END");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void toggle_mode_inputBoxTopLeft(boolean flag)
|
void toggle_mode_inputBoxTopLeft(boolean flag)
|
||||||
{
|
{
|
||||||
if (flag)
|
if (flag)
|
||||||
|
@ -469,6 +469,30 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
|
|||||||
n.setMax(360);
|
n.setMax(360);
|
||||||
n.setMultiplier(0.1);
|
n.setMultiplier(0.1);
|
||||||
}
|
}
|
||||||
|
else if (MODE_LIVE_BLUR_VALUE.equals(key))
|
||||||
|
{
|
||||||
|
n.setDecimalPrecision(1);
|
||||||
|
n.setValue(blurValue);
|
||||||
|
n.setMin(1);
|
||||||
|
n.setMax(100);
|
||||||
|
n.setMultiplier(0.1);
|
||||||
|
}
|
||||||
|
else if (MODE_LIVE_SIMPLIFICATION_VALUE.equals(key))
|
||||||
|
{
|
||||||
|
n.setDecimalPrecision(1);
|
||||||
|
n.setValue(liveSimplification);
|
||||||
|
n.setMin(0);
|
||||||
|
n.setMax(360);
|
||||||
|
n.setMultiplier(0.1);
|
||||||
|
}
|
||||||
|
else if (MODE_LIVE_POSTERISE_VALUE.equals(key))
|
||||||
|
{
|
||||||
|
n.setDecimalPrecision(1);
|
||||||
|
n.setValue(posterizeValue);
|
||||||
|
n.setMin(2);
|
||||||
|
n.setMax(32);
|
||||||
|
n.setMultiplier(0.1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@ -586,6 +610,7 @@ Map<String, List<Controller>> buildControlsForPanels()
|
|||||||
map.put(PANEL_NAME_DETAILS, getControllersForControllerNames(getControlNamesForDetailPanel()));
|
map.put(PANEL_NAME_DETAILS, getControllersForControllerNames(getControlNamesForDetailPanel()));
|
||||||
map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
|
map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
|
||||||
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
|
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
|
||||||
|
map.put(PANEL_NAME_WEBCAM, getControllersForControllerNames(getControlNamesForWebcamPanel()));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,6 +694,16 @@ List<String> getControlNamesForRovingPanel()
|
|||||||
return controlNames;
|
return controlNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> getControlNamesForWebcamPanel()
|
||||||
|
{
|
||||||
|
List<String> controlNames = new ArrayList<String>();
|
||||||
|
controlNames.add(MODE_LIVE_BLUR_VALUE);
|
||||||
|
controlNames.add(MODE_LIVE_SIMPLIFICATION_VALUE);
|
||||||
|
controlNames.add(MODE_LIVE_POSTERISE_VALUE);
|
||||||
|
controlNames.add(MODE_LIVE_CAPTURE_FROM_LIVE);
|
||||||
|
return controlNames;
|
||||||
|
}
|
||||||
|
|
||||||
List<String> getControlNamesForDetailPanel()
|
List<String> getControlNamesForDetailPanel()
|
||||||
{
|
{
|
||||||
List<String> controlNames = new ArrayList<String>();
|
List<String> controlNames = new ArrayList<String>();
|
||||||
@ -863,6 +898,12 @@ Map<String, String> buildControlLabels()
|
|||||||
result.put(MODE_STOP_RANDOM_SPRITES, "Stop sprites");
|
result.put(MODE_STOP_RANDOM_SPRITES, "Stop sprites");
|
||||||
result.put(MODE_DRAW_NORWEGIAN_DIALOG, "Draw norwegian...");
|
result.put(MODE_DRAW_NORWEGIAN_DIALOG, "Draw norwegian...");
|
||||||
|
|
||||||
|
result.put(MODE_LIVE_BLUR_VALUE, "Blur");
|
||||||
|
result.put(MODE_LIVE_SIMPLIFICATION_VALUE, "Simplify");
|
||||||
|
result.put(MODE_LIVE_POSTERISE_VALUE, "Posterise");
|
||||||
|
result.put(MODE_LIVE_CAPTURE_FROM_LIVE, "Capture");
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,6 +1028,11 @@ Set<String> buildControlNames()
|
|||||||
result.add(MODE_STOP_RANDOM_SPRITES);
|
result.add(MODE_STOP_RANDOM_SPRITES);
|
||||||
result.add(MODE_DRAW_NORWEGIAN_DIALOG);
|
result.add(MODE_DRAW_NORWEGIAN_DIALOG);
|
||||||
|
|
||||||
|
result.add(MODE_LIVE_BLUR_VALUE);
|
||||||
|
result.add(MODE_LIVE_SIMPLIFICATION_VALUE);
|
||||||
|
result.add(MODE_LIVE_POSTERISE_VALUE);
|
||||||
|
result.add(MODE_LIVE_CAPTURE_FROM_LIVE);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +306,12 @@ static final String MODE_START_RANDOM_SPRITES = "button_mode_startRandomSprite";
|
|||||||
static final String MODE_STOP_RANDOM_SPRITES = "button_mode_stopRandomSprites";
|
static final String MODE_STOP_RANDOM_SPRITES = "button_mode_stopRandomSprites";
|
||||||
static final String MODE_DRAW_NORWEGIAN_DIALOG = "button_mode_drawNorwegianDialog";
|
static final String MODE_DRAW_NORWEGIAN_DIALOG = "button_mode_drawNorwegianDialog";
|
||||||
|
|
||||||
|
static final String MODE_LIVE_BLUR_VALUE = "numberbox_mode_liveBlurValue";
|
||||||
|
static final String MODE_LIVE_SIMPLIFICATION_VALUE = "numberbox_mode_liveSimplificationValue";
|
||||||
|
static final String MODE_LIVE_POSTERISE_VALUE = "numberbox_mode_livePosteriseValue";
|
||||||
|
static final String MODE_LIVE_CAPTURE_FROM_LIVE = "button_mode_liveCaptureFromLive";
|
||||||
|
|
||||||
|
|
||||||
PVector statusTextPosition = new PVector(240.0, 12.0);
|
PVector statusTextPosition = new PVector(240.0, 12.0);
|
||||||
|
|
||||||
static String currentMode = MODE_BEGIN;
|
static String currentMode = MODE_BEGIN;
|
||||||
@ -442,6 +448,18 @@ boolean overwriteExistingStoreFile = true;
|
|||||||
public static Console console;
|
public static Console console;
|
||||||
public boolean useWindowedConsole = false;
|
public boolean useWindowedConsole = false;
|
||||||
|
|
||||||
|
static boolean drawingLiveVideo = true;
|
||||||
|
|
||||||
|
static PImage liveImage = null;
|
||||||
|
JMyron liveCamera;
|
||||||
|
BlobDetector blob_detector;
|
||||||
|
int liveSimplification = 0;
|
||||||
|
int blurValue = 1;
|
||||||
|
int posterizeValue = 6;
|
||||||
|
Set<Integer> colours = null;
|
||||||
|
List<Integer> colourList = null;
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
println("Running polargraph controller");
|
println("Running polargraph controller");
|
||||||
@ -511,6 +529,17 @@ void setup()
|
|||||||
|
|
||||||
addEventListeners();
|
addEventListeners();
|
||||||
|
|
||||||
|
liveCamera = new JMyron();
|
||||||
|
liveCamera.start(640,480);
|
||||||
|
|
||||||
|
blob_detector = new BlobDetector( 640, 480);
|
||||||
|
blob_detector.setResolution(1);
|
||||||
|
blob_detector.computeContours(true);
|
||||||
|
blob_detector.computeBlobPixels(true);
|
||||||
|
blob_detector.setMinMaxPixels(10*10, 640*480);
|
||||||
|
|
||||||
|
blob_detector.setBLOBable(new BLOBable_blueBlobs(liveImage));
|
||||||
|
|
||||||
}
|
}
|
||||||
void addEventListeners()
|
void addEventListeners()
|
||||||
{
|
{
|
||||||
@ -766,6 +795,7 @@ void drawWebcamPage()
|
|||||||
|
|
||||||
for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM))
|
for (Panel panel : getPanelsForTab(TAB_NAME_WEBCAM))
|
||||||
{
|
{
|
||||||
|
println("Panel:" + panel);
|
||||||
panel.draw();
|
panel.draw();
|
||||||
}
|
}
|
||||||
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
|
text(propertiesFilename, getPanel(PANEL_NAME_GENERAL).getOutline().getLeft(), getPanel(PANEL_NAME_GENERAL).getOutline().getTop()-7);
|
||||||
|
@ -72,7 +72,7 @@ Map<String, Set<Panel>> buildPanelsForTabs()
|
|||||||
|
|
||||||
List<String> buildTabNames()
|
List<String> buildTabNames()
|
||||||
{
|
{
|
||||||
List<String> list = new ArrayList<String>(4);
|
List<String> list = new ArrayList<String>(5);
|
||||||
list.add(TAB_NAME_INPUT);
|
list.add(TAB_NAME_INPUT);
|
||||||
list.add(TAB_NAME_ROVING);
|
list.add(TAB_NAME_ROVING);
|
||||||
list.add(TAB_NAME_WEBCAM);
|
list.add(TAB_NAME_WEBCAM);
|
||||||
@ -106,7 +106,7 @@ void initTabs()
|
|||||||
|
|
||||||
public Set<String> buildPanelNames()
|
public Set<String> buildPanelNames()
|
||||||
{
|
{
|
||||||
Set<String> set = new HashSet<String>(5);
|
Set<String> set = new HashSet<String>(6);
|
||||||
set.add(PANEL_NAME_INPUT);
|
set.add(PANEL_NAME_INPUT);
|
||||||
set.add(PANEL_NAME_ROVING);
|
set.add(PANEL_NAME_ROVING);
|
||||||
set.add(PANEL_NAME_WEBCAM);
|
set.add(PANEL_NAME_WEBCAM);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user