mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-08 19:24:25 +01:00
v2.6 added ability to invert the mask to reveal instead of hide
This commit is contained in:
parent
5e7e010a79
commit
6665883c9b
12
Machine.pde
12
Machine.pde
@ -292,6 +292,16 @@ class Machine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isMasked(PVector pos, float scalingFactor)
|
||||||
|
{
|
||||||
|
switch (invertMaskMode) {
|
||||||
|
case MASK_IS_UNUSED: return false;
|
||||||
|
case MASKED_COLOURS_ARE_HIDDEN: return isChromaKey(pos, scalingFactor);
|
||||||
|
case MASKED_COLOURS_ARE_SHOWN: return !isChromaKey(pos, scalingFactor);
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean isChromaKey(PVector pos, float scalingFactor)
|
boolean isChromaKey(PVector pos, float scalingFactor)
|
||||||
{
|
{
|
||||||
if (getImageFrame().surrounds(pos))
|
if (getImageFrame().surrounds(pos))
|
||||||
@ -626,7 +636,7 @@ class Machine
|
|||||||
PVector cartesianCoord = asCartesianCoords(nativeCoord);
|
PVector cartesianCoord = asCartesianCoords(nativeCoord);
|
||||||
if (selectedArea.surrounds(cartesianCoord))
|
if (selectedArea.surrounds(cartesianCoord))
|
||||||
{
|
{
|
||||||
if (isChromaKey(cartesianCoord, scalingFactor))
|
if (isMasked(cartesianCoord, scalingFactor))
|
||||||
{
|
{
|
||||||
nativeCoord.z = MASKED_PIXEL_BRIGHTNESS; // magic number
|
nativeCoord.z = MASKED_PIXEL_BRIGHTNESS; // magic number
|
||||||
nativeCoords.add(nativeCoord);
|
nativeCoords.add(nativeCoord);
|
||||||
|
@ -762,11 +762,16 @@ void numberbox_mode_changePolygonizerAdaptativeAngle(float value) {
|
|||||||
setupPolygonizer();
|
setupPolygonizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void dropdown_mode_changePolygonizer(int value)
|
void dropdown_mode_changePolygonizer(int value)
|
||||||
{
|
{
|
||||||
polygonizer = value;
|
polygonizer = value;
|
||||||
setupPolygonizer();
|
setupPolygonizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dropdown_mode_changeMaskInvert(int value)
|
||||||
|
{
|
||||||
|
invertMaskMode = value;
|
||||||
|
rebuildPixels();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,9 +279,9 @@ Map<String, Controller> buildAllControls()
|
|||||||
{
|
{
|
||||||
Button b = cp5.addButton(controlName, 0, 100, 100, 100, 100);
|
Button b = cp5.addButton(controlName, 0, 100, 100, 100, 100);
|
||||||
b.setLabel(getControlLabels().get(controlName));
|
b.setLabel(getControlLabels().get(controlName));
|
||||||
controlP5.Label l = b.getCaptionLabel();
|
|
||||||
l.getStyle().marginLeft = 4; //move to the right
|
|
||||||
b.hide();
|
b.hide();
|
||||||
|
controlP5.Label l = b.getCaptionLabel();
|
||||||
|
l.align(ControlP5.LEFT, CENTER);
|
||||||
map.put(controlName, b);
|
map.put(controlName, b);
|
||||||
// println("Added button " + controlName);
|
// println("Added button " + controlName);
|
||||||
}
|
}
|
||||||
@ -291,8 +291,8 @@ Map<String, Controller> buildAllControls()
|
|||||||
t.setLabel(getControlLabels().get(controlName));
|
t.setLabel(getControlLabels().get(controlName));
|
||||||
t.hide();
|
t.hide();
|
||||||
controlP5.Label l = t.getCaptionLabel();
|
controlP5.Label l = t.getCaptionLabel();
|
||||||
l.getStyle().marginTop = -17; //move upwards (relative to button size)
|
l.align(ControlP5.LEFT, CENTER);
|
||||||
l.getStyle().marginLeft = 4; //move to the right
|
l.getStyle().setPaddingLeft(4);
|
||||||
map.put(controlName, t);
|
map.put(controlName, t);
|
||||||
// println("Added toggle " + controlName);
|
// println("Added toggle " + controlName);
|
||||||
}
|
}
|
||||||
@ -302,8 +302,8 @@ Map<String, Controller> buildAllControls()
|
|||||||
t.setLabel(getControlLabels().get(controlName));
|
t.setLabel(getControlLabels().get(controlName));
|
||||||
t.hide();
|
t.hide();
|
||||||
controlP5.Label l = t.getCaptionLabel();
|
controlP5.Label l = t.getCaptionLabel();
|
||||||
l.getStyle().marginTop = -17; //move upwards (relative to button size)
|
l.align(ControlP5.LEFT, CENTER);
|
||||||
l.getStyle().marginLeft = 4; //move to the right
|
l.getStyle().setPaddingLeft(4);
|
||||||
map.put(controlName, t);
|
map.put(controlName, t);
|
||||||
// println("Added minitoggle " + controlName);
|
// println("Added minitoggle " + controlName);
|
||||||
}
|
}
|
||||||
@ -314,8 +314,8 @@ Map<String, Controller> buildAllControls()
|
|||||||
n.hide();
|
n.hide();
|
||||||
n.setDecimalPrecision(0);
|
n.setDecimalPrecision(0);
|
||||||
controlP5.Label l = n.getCaptionLabel();
|
controlP5.Label l = n.getCaptionLabel();
|
||||||
l.getStyle().marginTop = -17; //move upwards (relative to button size)
|
l.align(ControlP5.LEFT, CENTER);
|
||||||
l.getStyle().marginLeft = 40; //move to the right
|
l.getStyle().setPaddingLeft(35);
|
||||||
// change the control direction to left/right
|
// change the control direction to left/right
|
||||||
n.setDirection(Controller.VERTICAL);
|
n.setDirection(Controller.VERTICAL);
|
||||||
map.put(controlName, n);
|
map.put(controlName, n);
|
||||||
@ -688,6 +688,12 @@ Map<String, Controller> initialiseDropdownContents(Map<String, Controller> map)
|
|||||||
ScrollableList sl = (ScrollableList) map.get(key);
|
ScrollableList sl = (ScrollableList) map.get(key);
|
||||||
sl.setItems(polygonizerStyles);
|
sl.setItems(polygonizerStyles);
|
||||||
}
|
}
|
||||||
|
if (MODE_CHANGE_INVERT_MASK.equals(key))
|
||||||
|
{
|
||||||
|
println("Adding " + key);
|
||||||
|
ScrollableList sl = (ScrollableList) map.get(key);
|
||||||
|
sl.setItems(invertMaskModes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -711,6 +717,13 @@ Map<String, Controller> initialiseDropdownValues(Map<String, Controller> map)
|
|||||||
sl.setValue(polygonizer);
|
sl.setValue(polygonizer);
|
||||||
sl.close();
|
sl.close();
|
||||||
}
|
}
|
||||||
|
else if (MODE_CHANGE_INVERT_MASK.equals(key))
|
||||||
|
{
|
||||||
|
println("Adding " + key);
|
||||||
|
ScrollableList sl = (ScrollableList) map.get(key);
|
||||||
|
sl.setValue(polygonizer);
|
||||||
|
sl.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -850,6 +863,7 @@ List<String> getControlNamesForInputPanel()
|
|||||||
controlNames.add(MODE_CHANGE_GRID_SIZE);
|
controlNames.add(MODE_CHANGE_GRID_SIZE);
|
||||||
controlNames.add(MODE_CHANGE_SAMPLE_AREA);
|
controlNames.add(MODE_CHANGE_SAMPLE_AREA);
|
||||||
controlNames.add(MODE_CHOOSE_CHROMA_KEY_COLOUR);
|
controlNames.add(MODE_CHOOSE_CHROMA_KEY_COLOUR);
|
||||||
|
controlNames.add(MODE_CHANGE_INVERT_MASK);
|
||||||
controlNames.add(MODE_CHANGE_PIXEL_SCALING);
|
controlNames.add(MODE_CHANGE_PIXEL_SCALING);
|
||||||
|
|
||||||
controlNames.add(MODE_RENDER_PIXEL_DIALOG);
|
controlNames.add(MODE_RENDER_PIXEL_DIALOG);
|
||||||
@ -1105,6 +1119,7 @@ Map<String, String> buildControlLabels()
|
|||||||
result.put(MODE_MOVE_VECTOR, "Move vector");
|
result.put(MODE_MOVE_VECTOR, "Move vector");
|
||||||
result.put(MODE_RENDER_PIXEL_DIALOG, "Render pixels...");
|
result.put(MODE_RENDER_PIXEL_DIALOG, "Render pixels...");
|
||||||
result.put(MODE_CHOOSE_CHROMA_KEY_COLOUR, "Choose mask colour");
|
result.put(MODE_CHOOSE_CHROMA_KEY_COLOUR, "Choose mask colour");
|
||||||
|
result.put(MODE_CHANGE_INVERT_MASK, "Mask mode");
|
||||||
result.put(MODE_CHANGE_PIXEL_SCALING, "Pixel scaling");
|
result.put(MODE_CHANGE_PIXEL_SCALING, "Pixel scaling");
|
||||||
|
|
||||||
result.put(MODE_PEN_LIFT_UP, "Pen lift");
|
result.put(MODE_PEN_LIFT_UP, "Pen lift");
|
||||||
@ -1260,6 +1275,7 @@ Set<String> buildControlNames()
|
|||||||
result.add(MODE_CHANGE_MIN_VECTOR_LINE_LENGTH);
|
result.add(MODE_CHANGE_MIN_VECTOR_LINE_LENGTH);
|
||||||
|
|
||||||
result.add(MODE_CHOOSE_CHROMA_KEY_COLOUR);
|
result.add(MODE_CHOOSE_CHROMA_KEY_COLOUR);
|
||||||
|
result.add(MODE_CHANGE_INVERT_MASK);
|
||||||
result.add(MODE_CHANGE_PIXEL_SCALING);
|
result.add(MODE_CHANGE_PIXEL_SCALING);
|
||||||
result.add(MODE_PEN_LIFT_UP);
|
result.add(MODE_PEN_LIFT_UP);
|
||||||
result.add(MODE_PEN_LIFT_DOWN);
|
result.add(MODE_PEN_LIFT_DOWN);
|
||||||
|
@ -54,8 +54,8 @@ import java.awt.BorderLayout;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
int majorVersionNo = 2;
|
int majorVersionNo = 2;
|
||||||
int minorVersionNo = 5;
|
int minorVersionNo = 6;
|
||||||
int buildNo = 2;
|
int buildNo = 0;
|
||||||
|
|
||||||
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
|
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
|
||||||
ControlP5 cp5;
|
ControlP5 cp5;
|
||||||
@ -249,6 +249,7 @@ static final String MODE_CHANGE_SAMPLE_AREA = "numberbox_mode_changeSampleArea";
|
|||||||
static final String MODE_CHANGE_GRID_SIZE = "numberbox_mode_changeGridSize";
|
static final String MODE_CHANGE_GRID_SIZE = "numberbox_mode_changeGridSize";
|
||||||
|
|
||||||
static final String MODE_SHOW_DENSITY_PREVIEW = "minitoggle_mode_showDensityPreview";
|
static final String MODE_SHOW_DENSITY_PREVIEW = "minitoggle_mode_showDensityPreview";
|
||||||
|
|
||||||
static final String MODE_SHOW_IMAGE = "minitoggle_mode_showImage";
|
static final String MODE_SHOW_IMAGE = "minitoggle_mode_showImage";
|
||||||
static final String MODE_SHOW_QUEUE_PREVIEW = "minitoggle_mode_showQueuePreview";
|
static final String MODE_SHOW_QUEUE_PREVIEW = "minitoggle_mode_showQueuePreview";
|
||||||
static final String MODE_SHOW_VECTOR = "minitoggle_mode_showVector";
|
static final String MODE_SHOW_VECTOR = "minitoggle_mode_showVector";
|
||||||
@ -346,8 +347,17 @@ static final String MODE_CHANGE_POLYGONIZER = "dropdown_mode_changePolygonizer";
|
|||||||
static final String MODE_CHANGE_POLYGONIZER_LENGTH = "numberbox_mode_changePolygonizerLength";
|
static final String MODE_CHANGE_POLYGONIZER_LENGTH = "numberbox_mode_changePolygonizerLength";
|
||||||
static final String MODE_CHANGE_POLYGONIZER_ADAPTATIVE_ANGLE = "numberbox_mode_changePolygonizerAdaptativeAngle";
|
static final String MODE_CHANGE_POLYGONIZER_ADAPTATIVE_ANGLE = "numberbox_mode_changePolygonizerAdaptativeAngle";
|
||||||
|
|
||||||
|
static final String MODE_CHANGE_INVERT_MASK = "dropdown_mode_changeMaskInvert";
|
||||||
|
|
||||||
|
|
||||||
List<String> polygonizerStyles = Arrays.asList("ADAPTATIVE", "UNIFORMLENGTH");
|
List<String> polygonizerStyles = Arrays.asList("ADAPTATIVE", "UNIFORMLENGTH");
|
||||||
|
|
||||||
|
List<String> invertMaskModes = Arrays.asList("Mask off", "Mask hides", "Mask shows");
|
||||||
|
static final int MASK_MODES_COUNT = 3;
|
||||||
|
static final int MASK_IS_UNUSED = 0;
|
||||||
|
static final int MASKED_COLOURS_ARE_HIDDEN = 1;
|
||||||
|
static final int MASKED_COLOURS_ARE_SHOWN = 2;
|
||||||
|
|
||||||
|
|
||||||
PVector statusTextPosition = new PVector(300.0, 12.0);
|
PVector statusTextPosition = new PVector(300.0, 12.0);
|
||||||
|
|
||||||
@ -412,6 +422,7 @@ static final char BITMAP_BACKGROUND_COLOUR = 0x0F;
|
|||||||
PVector homePointCartesian = null;
|
PVector homePointCartesian = null;
|
||||||
|
|
||||||
public color chromaKeyColour = color(0,255,0);
|
public color chromaKeyColour = color(0,255,0);
|
||||||
|
public int invertMaskMode = MASK_IS_UNUSED;
|
||||||
|
|
||||||
// used in the preview page
|
// used in the preview page
|
||||||
public color pageColour = color(220);
|
public color pageColour = color(220);
|
||||||
@ -1554,6 +1565,11 @@ void setChromaKey(PVector p)
|
|||||||
{
|
{
|
||||||
color col = getDisplayMachine().getPixelAtScreenCoords(p);
|
color col = getDisplayMachine().getPixelAtScreenCoords(p);
|
||||||
chromaKeyColour = col;
|
chromaKeyColour = col;
|
||||||
|
rebuildPixels();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rebuildPixels()
|
||||||
|
{
|
||||||
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
|
if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified())
|
||||||
{
|
{
|
||||||
getDisplayMachine().extractPixelsFromArea(getBoxVector1(), getBoxVectorSize(), getGridSize(), sampleArea);
|
getDisplayMachine().extractPixelsFromArea(getBoxVector1(), getBoxVectorSize(), getGridSize(), sampleArea);
|
||||||
@ -2373,10 +2389,24 @@ void readMachineMessage(String msg)
|
|||||||
void readMachinePosition(String sync)
|
void readMachinePosition(String sync)
|
||||||
{
|
{
|
||||||
String[] splitted = split(sync, ",");
|
String[] splitted = split(sync, ",");
|
||||||
|
int aPosIndex = 0;
|
||||||
|
int bPosIndex = 0;
|
||||||
|
|
||||||
if (splitted.length == 4)
|
if (splitted.length == 4)
|
||||||
{
|
{
|
||||||
String currentAPos = splitted[1];
|
aPosIndex = 1;
|
||||||
String currentBPos = splitted[2];
|
bPosIndex = 2;
|
||||||
|
}
|
||||||
|
else if (splitted.length == 5)
|
||||||
|
{
|
||||||
|
aPosIndex = 2;
|
||||||
|
bPosIndex = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aPosIndex != 0)
|
||||||
|
{
|
||||||
|
String currentAPos = splitted[aPosIndex];
|
||||||
|
String currentBPos = splitted[bPosIndex];
|
||||||
Float a = Float.valueOf(currentAPos).floatValue();
|
Float a = Float.valueOf(currentAPos).floatValue();
|
||||||
Float b = Float.valueOf(currentBPos).floatValue();
|
Float b = Float.valueOf(currentBPos).floatValue();
|
||||||
currentMachinePos.x = a;
|
currentMachinePos.x = a;
|
||||||
|
Loading…
Reference in New Issue
Block a user