Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spirograph generator added, Raspberry Pi GPIO rotary encoders added #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions DisplayMachine.pde
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,84 @@ class DisplayMachine extends Machine
}
}

public void drawForSpiro()
{
// work out the scaling factor.
noStroke();
// draw machine outline

// drop shadow
fill(80);
rect(getOutline().getLeft()+DROP_SHADOW_DISTANCE, getOutline().getTop()+DROP_SHADOW_DISTANCE, getOutline().getWidth(), getOutline().getHeight());

fill(getMachineColour());
rect(getOutline().getLeft(), getOutline().getTop(), getOutline().getWidth(), getOutline().getHeight());
//text("machine " + getDimensionsAsText(getSize()) + " " + getZoomText(), getOutline().getLeft(), getOutline().getTop());

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
fill(getPageColour());
rect(getOutline().getLeft()+sc(getPage().getLeft()),
getOutline().getTop()+sc(getPage().getTop()),
sc(getPage().getWidth()),
sc(getPage().getHeight()));
//text("page " + getDimensionsAsText(getPage()), getOutline().getLeft()+sc(getPage().getLeft()),
//getOutline().getTop()+sc(getPage().getTop()));
fill(0);
//text("offset " + getDimensionsAsText(getPage().getPosition()),
//getOutline().getLeft()+sc(getPage().getLeft()),
//getOutline().getTop()+sc(getPage().getTop())+10);
noFill();

// draw home point
noFill();
strokeWeight(5);
stroke(0, 128);
PVector onScreen = scaleToScreen(inMM(getHomePoint()));
ellipse(onScreen.x, onScreen.y, 15, 15);
strokeWeight(2);
stroke(255);
ellipse(onScreen.x, onScreen.y, 15, 15);

text("Home point", onScreen.x+ 15, onScreen.y-5);
//text(int(inMM(getHomePoint().x)+0.5) + ", " + int(inMM(getHomePoint().y)+0.5), onScreen.x+ 15, onScreen.y+15);


if (displayingGuides
&& getOutline().surrounds(getMouseVector())
&& currentMode != MODE_MOVE_IMAGE
&& mouseOverControls().isEmpty()
)
{
drawHangingStrings();
//drawLineLengthTexts();
cursor(CROSS);
}
else
{
cursor(ARROW);
}

if (displayingVector && getVectorShape() != null)
{
displayVectorImage();
}
}


// public void displayLiveVideo()
// {
// // draw actual image, maximum size
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ copies of all the libraries that I use, as well as all the source, and compiled

[email protected]
http://www.polargraph.co.uk/


Spirograph functions Copyright Mark Craig 2017

GPIO access on Raspberry Pi requires PiJ4 library available from http://pi4j.com/index.html.

@markcra
http://www.markcra.com/
53 changes: 53 additions & 0 deletions controlsActions.pde
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,59 @@ void numberbox_mode_vectorPathLengthHighPassCutoff(int value)
pathLengthHighPassCutoff = value;
}

void numberbox_mode_liveBigRadiusValue(int value)
{
if (value != Radius)
{
Radius = value;
retraceShape = true;
}
}
void numberbox_mode_liveSmallRadiusValue(int value)
{
if (value != radius)
{
radius = value;
retraceShape = true;
}
}
void numberbox_mode_liveRhoRadiusValue(int value)
{
if (value != rho)
{
rho = value;
retraceShape = true;
}
}
void numberbox_mode_liveIntervalValue(int value)
{
if (value != Interval)
{
Interval = value;
retraceShape = true;
}
}
void numberbox_mode_liveMultiplierValue(int value)
{
if (value != multiplier)
{
multiplier = value;
retraceShape = true;
}
}
void numberbox_mode_liveModeValue(int value)
{
if (value != mode)
{
mode = value;
retraceShape = true;
}
}
void button_mode_exportSpirograph()
{
Export();
}

void button_mode_liveConfirmDraw()
{
if (captureShape != null)
Expand Down
106 changes: 104 additions & 2 deletions controlsSetup.pde
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ Map<String, Panel> buildPanels() {
tracePanel.setControlSizes(buildControlSizesForPanel(tracePanel));
panels.put(PANEL_NAME_TRACE, tracePanel);

Rectangle panelOutlineSpirograph = new Rectangle(getMainPanelPosition(),
new PVector((DEFAULT_CONTROL_SIZE.x+CONTROL_SPACING.x)*2, panelHeight));
Panel spirographPanel = new Panel(PANEL_NAME_SPIROGRAPH, panelOutlineSpirograph);
spirographPanel.setOutlineColour(color(200,255,200));
// get controls
spirographPanel.setResizable(true);
spirographPanel.setControls(getControlsForPanels().get(PANEL_NAME_SPIROGRAPH));
// get control positions
spirographPanel.setControlPositions(buildControlPositionsForPanel(spirographPanel));
spirographPanel.setControlSizes(buildControlSizesForPanel(spirographPanel));
panels.put(PANEL_NAME_SPIROGRAPH, spirographPanel);

Rectangle panelOutlineDetails = new Rectangle(getMainPanelPosition(),
new PVector((DEFAULT_CONTROL_SIZE.x+CONTROL_SPACING.x)*2, panelHeight));
Panel detailsPanel = new Panel(PANEL_NAME_DETAILS, panelOutlineDetails);
Expand Down Expand Up @@ -510,6 +522,54 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
n.setMax(10);
n.setMultiplier(0.1);
}
else if (MODE_LIVE_BIG_RADIUS_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(Radius);
n.setMin(1);
n.setMax(255);
n.setMultiplier(1);
}
else if (MODE_LIVE_SMALL_RADIUS_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(radius);
n.setMin(1);
n.setMax(255);
n.setMultiplier(1);
}
else if (MODE_LIVE_RHO_RADIUS_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(rho);
n.setMin(1);
n.setMax(255);
n.setMultiplier(1);
}
else if (MODE_LIVE_INTERVAL_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(Interval);
n.setMin(100);
n.setMax(5000);
n.setMultiplier(1);
}
else if (MODE_LIVE_MULTIPLIER_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(multiplier);
n.setMin(0);
n.setMax(60);
n.setMultiplier(1);
}
else if (MODE_LIVE_MODE_VALUE.equals(key))
{
n.setDecimalPrecision(1);
n.setValue(mode);
n.setMin(0);
n.setMax(3);
n.setMultiplier(1);
}
else if (MODE_LIVE_SIMPLIFICATION_VALUE.equals(key))
{
n.setDecimalPrecision(1);
Expand Down Expand Up @@ -550,7 +610,7 @@ Map<String, Controller> initialiseNumberboxValues(Map<String, Controller> map)
}
else if (MODE_CHANGE_POLYGONIZER_LENGTH.equals(key)) {
n.setValue(polygonizerLength);
n.setMin(1.0);
n.setMin(1.0);
n.setDecimalPrecision(1);
n.setMultiplier(0.1);

Expand Down Expand Up @@ -693,6 +753,7 @@ Map<String, List<Controller>> buildControlsForPanels()
map.put(PANEL_NAME_QUEUE, getControllersForControllerNames(getControlNamesForQueuePanel()));
map.put(PANEL_NAME_GENERAL, getControllersForControllerNames(getControlNamesForGeneralPanel()));
map.put(PANEL_NAME_TRACE, getControllersForControllerNames(getControlNamesForTracePanel()));
map.put(PANEL_NAME_SPIROGRAPH, getControllersForControllerNames(getControlNamesForSpirographPanel()));
return map;
}

Expand Down Expand Up @@ -788,7 +849,7 @@ List<String> getControlNamesForRovingPanel()
return controlNames;
}

List<String> getControlNamesForTracePanel()
List<String> getControlNamesForTracePanel()
{
List<String> controlNames = new ArrayList<String>();
controlNames.add(MODE_LIVE_BLUR_VALUE);
Expand All @@ -806,6 +867,31 @@ List<String> getControlNamesForTracePanel()
return controlNames;
}

List<String> getControlNamesForSpirographPanel() // now spirograph panel
{
List<String> controlNames = new ArrayList<String>();
controlNames.add(MODE_LIVE_BIG_RADIUS_VALUE);
controlNames.add(MODE_LIVE_SMALL_RADIUS_VALUE);
controlNames.add(MODE_LIVE_INTERVAL_VALUE);
controlNames.add(MODE_LIVE_RHO_RADIUS_VALUE);
controlNames.add(MODE_LIVE_MULTIPLIER_VALUE);
controlNames.add(MODE_LIVE_MODE_VALUE);
controlNames.add(MODE_EXPORT_SPIROGRAPH);

//copied from INPUT tab:
//controlNames.add(MODE_LOAD_VECTOR_FILE);
controlNames.add(MODE_RESIZE_VECTOR);
controlNames.add(MODE_MOVE_VECTOR);
controlNames.add(MODE_PEN_LIFT_UP);
controlNames.add(MODE_PEN_LIFT_DOWN);
controlNames.add(MODE_SET_POSITION_HOME);
controlNames.add(MODE_RETURN_TO_HOME);
controlNames.add(MODE_CLEAR_QUEUE);
controlNames.add(MODE_RENDER_VECTORS);

return controlNames;
}

List<String> getControlNamesForDetailPanel()
{
List<String> controlNames = new ArrayList<String>();
Expand Down Expand Up @@ -1015,6 +1101,14 @@ Map<String, String> buildControlLabels()
result.put(MODE_LIVE_CONFIRM_DRAW, "Draw capture");
result.put(MODE_LIVE_CANCEL_CAPTURE, "Cancel capture");
result.put(MODE_LIVE_ADD_CAPTION, "Add caption");

result.put(MODE_LIVE_BIG_RADIUS_VALUE, "Major Radius");
result.put(MODE_LIVE_SMALL_RADIUS_VALUE, "Minor radius");
result.put(MODE_LIVE_RHO_RADIUS_VALUE, "Rho");
result.put(MODE_LIVE_INTERVAL_VALUE, "Interval");
result.put(MODE_LIVE_MULTIPLIER_VALUE, "Multiplier");
result.put(MODE_LIVE_MODE_VALUE, "Mode");
result.put(MODE_EXPORT_SPIROGRAPH, "Export Spirograph");

result.put(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF, "Path length cutoff");
result.put(MODE_SHOW_WEBCAM_RAW_VIDEO, "Show video");
Expand Down Expand Up @@ -1168,6 +1262,14 @@ Set<String> buildControlNames()
result.add(MODE_LIVE_CANCEL_CAPTURE);
result.add(MODE_LIVE_ADD_CAPTION);
result.add(MODE_VECTOR_PATH_LENGTH_HIGHPASS_CUTOFF);

result.add(MODE_LIVE_BIG_RADIUS_VALUE);
result.add(MODE_LIVE_SMALL_RADIUS_VALUE);
result.add(MODE_LIVE_RHO_RADIUS_VALUE);
result.add(MODE_LIVE_INTERVAL_VALUE);
result.add(MODE_LIVE_MULTIPLIER_VALUE);
result.add(MODE_LIVE_MODE_VALUE);
result.add(MODE_EXPORT_SPIROGRAPH);

result.add(MODE_SHOW_WEBCAM_RAW_VIDEO);
result.add(MODE_FLIP_WEBCAM_INPUT);
Expand Down
Loading