mirror of
https://github.com/euphy/polargraphcontroller
synced 2025-01-09 19:55:16 +01:00
Choosable line sorting types.
This commit is contained in:
parent
782f6000bb
commit
0bff66fcd5
@ -152,7 +152,7 @@ void button_mode_liveConfirmDraw()
|
|||||||
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x),
|
PVector position = new PVector(getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().x),
|
||||||
getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y));
|
getDisplayMachine().inMM(getDisplayMachine().getPictureFrame().getPosition().y));
|
||||||
|
|
||||||
sendVectorShapes(captureShape, scaling, position);
|
sendVectorShapes(captureShape, scaling, position, PATH_SORT_CENTRE_FIRST);
|
||||||
button_mode_penUp();
|
button_mode_penUp();
|
||||||
|
|
||||||
// save shape as SVG
|
// save shape as SVG
|
||||||
|
20
drawing.pde
20
drawing.pde
@ -71,6 +71,11 @@ static final String CMD_DRAW_NORWEGIAN = "C43,";
|
|||||||
static final String CMD_DRAW_NORWEGIAN_OUTLINE = "C44,";
|
static final String CMD_DRAW_NORWEGIAN_OUTLINE = "C44,";
|
||||||
static final String CMD_SETPENLIFTRANGE = "C45,";
|
static final String CMD_SETPENLIFTRANGE = "C45,";
|
||||||
|
|
||||||
|
static final int PATH_SORT_NONE = 0;
|
||||||
|
static final int PATH_SORT_MOST_POINTS_FIRST = 1;
|
||||||
|
static final int PATH_SORT_GREATEST_AREA_FIRST = 2;
|
||||||
|
static final int PATH_SORT_CENTRE_FIRST = 3;
|
||||||
|
|
||||||
private PVector mouseVector = new PVector(0, 0);
|
private PVector mouseVector = new PVector(0, 0);
|
||||||
|
|
||||||
Comparator xAscending = new Comparator()
|
Comparator xAscending = new Comparator()
|
||||||
@ -646,18 +651,21 @@ void sendOutlineOfBox()
|
|||||||
|
|
||||||
void sendVectorShapes()
|
void sendVectorShapes()
|
||||||
{
|
{
|
||||||
sendVectorShapes(getVectorShape(), vectorScaling/100, getVectorPosition());
|
sendVectorShapes(getVectorShape(), vectorScaling/100, getVectorPosition(), PATH_SORT_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendVectorShapes(RShape vec, float scaling, PVector position)
|
|
||||||
|
void sendVectorShapes(RShape vec, float scaling, PVector position, int pathSortingAlgorithm)
|
||||||
{
|
{
|
||||||
println("Send vector shapes.");
|
println("Send vector shapes.");
|
||||||
RPoint[][] pointPaths = vec.getPointsInPaths();
|
RPoint[][] pointPaths = vec.getPointsInPaths();
|
||||||
|
|
||||||
// sort the paths to optimise the draw sequence
|
// sort the paths to optimise the draw sequence
|
||||||
// pointPaths = sortPathsLongestFirst(pointPaths, pathLengthHighPassCutoff);
|
switch (pathSortingAlgorithm) {
|
||||||
// pointPaths = sortPathsGreatestAreaFirst(vec, pathLengthHighPassCutoff);
|
case PATH_SORT_MOST_POINTS_FIRST: pointPaths = sortPathsLongestFirst(pointPaths, pathLengthHighPassCutoff); break;
|
||||||
pointPaths = sortPathsCentreFirst(vec, pathLengthHighPassCutoff);
|
case PATH_SORT_GREATEST_AREA_FIRST: pointPaths = sortPathsGreatestAreaFirst(vec, pathLengthHighPassCutoff); break;
|
||||||
|
case PATH_SORT_CENTRE_FIRST: pointPaths = sortPathsCentreFirst(vec, pathLengthHighPassCutoff); break;
|
||||||
|
}
|
||||||
|
|
||||||
String command = "";
|
String command = "";
|
||||||
PVector lastPoint = new PVector();
|
PVector lastPoint = new PVector();
|
||||||
@ -708,7 +716,7 @@ void sendVectorShapes(RShape vec, float scaling, PVector position)
|
|||||||
println("finished.");
|
println("finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public RPoint[][] sortPathLongestFirst(RPoint[][] pointPaths, int highPassCutoff)
|
public RPoint[][] sortPathsLongestFirst(RPoint[][] pointPaths, int highPassCutoff)
|
||||||
{
|
{
|
||||||
// put the paths into a list
|
// put the paths into a list
|
||||||
List<RPoint[]> pathsList = new ArrayList<RPoint[]>(pointPaths.length);
|
List<RPoint[]> pathsList = new ArrayList<RPoint[]>(pointPaths.length);
|
||||||
|
@ -1,22 +1,3 @@
|
|||||||
import processing.video.*;
|
|
||||||
import diewald_CV_kit.libraryinfo.*;
|
|
||||||
import diewald_CV_kit.utility.*;
|
|
||||||
import diewald_CV_kit.blobdetection.*;
|
|
||||||
|
|
||||||
import geomerative.*;
|
|
||||||
import org.apache.batik.svggen.font.table.*;
|
|
||||||
import org.apache.batik.svggen.font.*;
|
|
||||||
import java.util.zip.CRC32;
|
|
||||||
|
|
||||||
|
|
||||||
// for OSX
|
|
||||||
import java.text.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
import java.util.logging.*;
|
|
||||||
//import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
//import processing.opengl.PGraphicsOpenGL;
|
|
||||||
/**
|
/**
|
||||||
Polargraph controller
|
Polargraph controller
|
||||||
Copyright Sandy Noble 2012.
|
Copyright Sandy Noble 2012.
|
||||||
@ -46,13 +27,30 @@ import java.util.logging.*;
|
|||||||
http://code.google.com/p/polargraph/
|
http://code.google.com/p/polargraph/
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
import processing.video.*;
|
||||||
|
import diewald_CV_kit.libraryinfo.*;
|
||||||
|
import diewald_CV_kit.utility.*;
|
||||||
|
import diewald_CV_kit.blobdetection.*;
|
||||||
|
|
||||||
|
import geomerative.*;
|
||||||
|
import org.apache.batik.svggen.font.table.*;
|
||||||
|
import org.apache.batik.svggen.font.*;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
|
|
||||||
|
// for OSX
|
||||||
|
import java.text.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import java.util.logging.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import processing.serial.*;
|
import processing.serial.*;
|
||||||
import controlP5.*;
|
import controlP5.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
|
||||||
int majorVersionNo = 1;
|
int majorVersionNo = 1;
|
||||||
int minorVersionNo = 3;
|
int minorVersionNo = 4;
|
||||||
int buildNo = 0;
|
int buildNo = 0;
|
||||||
|
|
||||||
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
|
String programTitle = "Polargraph Controller v" + majorVersionNo + "." + minorVersionNo + " build " + buildNo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user