Skip to content

Commit

Permalink
Fixed background image button
Browse files Browse the repository at this point in the history
Background image functionality doesn’t work however.
  • Loading branch information
kellyegan committed Jul 26, 2014
1 parent 931851a commit 4df9e25
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
58 changes: 29 additions & 29 deletions Stroke.pde
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Stroke implements I_PathGen {
color strokeColor;
float strokeWeight;
Point lastPoint;

Brush style;

PApplet app;
PathTube mesh;
boolean meshCreated;

/**
* Create an empty Stroke with a specific Brush
* @param b Brush to attach to this Stroke
Expand All @@ -32,7 +32,7 @@ class Stroke implements I_PathGen {
lastPoint = null;
meshCreated = false;
}

/**
* Create an empty Stroke and a new Brush
* @param n Name of the new Brush
Expand All @@ -42,14 +42,14 @@ class Stroke implements I_PathGen {
Stroke(PApplet a, String n, int c, int w) {
this(a, new Brush(n, c, w));
}

/**
* Create an empty Stroke with a default Brush
*/
*/
Stroke(PApplet a) {
this( a, new Brush() );
}

/**
* Add a point to the Stroke.
* @param Point to add
Expand All @@ -59,70 +59,70 @@ class Stroke implements I_PathGen {
lastPoint = p;
createMesh();
}

/** Creates a mesh for the given stroke
* Not sure if this is needed or should just be implemented for the drawing class
*/
void createMesh() {
if( points != null && points.size() >= 2) {
if ( points != null && points.size() >= 2) {
PVector[] pts = new PVector[points.size()];
for( int i = 0; i < points.size(); i++ ) {
pts[i] = points.get(i).location;

for ( int i = 0; i < points.size (); i++ ) {
pts[i] = points.get(i).location;
}

mesh = new PathTube( app, this, style.getWeight(), points.size(), 6, false );
mesh.drawMode( Shape3D.SOLID );
mesh.fill( style.getColor() );
mesh.fill( style.getColor(), Tube.BOTH_CAP );
meshCreated = true;
}
}

/**
* Display the stroke
*/
void display() {
if( meshCreated ) {
if ( meshCreated ) {
mesh.draw();
} else {
style.apply();
beginShape();
for( Point point : points ) {
for ( Point point : points ) {
vertex( point.location.x, point.location.y, point.location.z );
}
endShape();
}
}

/**
* List the points within the Stroke
*/
void list() {
for( Point point : points ) {
for ( Point point : points ) {
point.list();
}
println();
}

Point getLastPoint() {
return lastPoint;
return lastPoint;
}

float distanceToLast( float x, float y, float z ) {
if( lastPoint != null ) {
if ( lastPoint != null ) {
return dist( lastPoint.location.x, lastPoint.location.y, lastPoint.location.z, x, y, z );
} else {
return -1;
}
}

/**
* Return x position along stroke length
*/
public float x( float t ) {
float xPos = 0;
if( t < 1.0 ) {
if ( t < 1.0 ) {
float pathPos = t * (points.size() - 1);
int startPt = floor(pathPos);
int endPt = startPt + 1;
Expand All @@ -133,13 +133,13 @@ class Stroke implements I_PathGen {
}
return xPos;
}

/**
* Return x position along stroke
*/
public float y( float t ) {
float yPos = 0;
if( t < 1.0 ) {
if ( t < 1.0 ) {
float pathPos = t * (points.size() - 1);
int startPt = floor(pathPos);
int endPt = startPt + 1;
Expand All @@ -150,13 +150,13 @@ class Stroke implements I_PathGen {
}
return yPos;
}

/**
* Return x position along stroke
*/
public float z( float t ) {
float zPos = 0;
if( t < 1.0 ) {
if ( t < 1.0 ) {
float pathPos = t * (points.size() - 1);
int startPt = floor(pathPos);
int endPt = startPt + 1;
Expand All @@ -167,5 +167,5 @@ class Stroke implements I_PathGen {
}
return zPos;
}

}

2 changes: 2 additions & 0 deletions code/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
21 changes: 7 additions & 14 deletions sketch3d.pde
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ void setup() {
currentPosition = new PVector();
positionDelta = new PVector();

//hint(DISABLE_DEPTH_MASK);

//
// File path = new File(sketchPath + "/data");
//
Expand All @@ -195,17 +193,16 @@ void setup() {
// println(this);
startMillis = millis();
logoDuration = 10000; //10 seconds to display logo and pick hand.
shader(shader);

}

void draw() {
shader(shader);
update();

/*************************************** DISPLAY **************************************/

hint(ENABLE_DEPTH_TEST);
pushMatrix();

if ( exportDXF ) {
beginRaw( DXF, dxfName + ".dxf");
}
Expand Down Expand Up @@ -269,16 +266,14 @@ void draw() {

translate(offset.x, offset.y, offset.z);
d.display();

popMatrix();

if ( exportDXF || exportPDF ) {
endRaw();
exportDXF = false;
exportPDF = false;
}

hint(DISABLE_DEPTH_TEST);
camera();
noLights();

Expand All @@ -290,7 +285,7 @@ void draw() {
helpMenu.setVisible( menuState == HELP_MENU );

cp5.draw();

if ( menuState == COLOR_MENU ) {
if ( currentColor == FOREGROUND ) {
brushColor = colorChooser.getColorValue();
Expand All @@ -313,7 +308,6 @@ void draw() {
line( x, y - 10, x, y + 10 );
line( x - 10, y, x + 10, y );
}

}


Expand Down Expand Up @@ -395,7 +389,6 @@ void mousePressed() {
void mouseReleased() {
if ( menuState != MENUS_OFF ) {
cp5.getPointer().released();
println("Mouse pressed");
}
else {
if (mouseButton==LEFT) {
Expand Down Expand Up @@ -807,6 +800,7 @@ void createControllers(ControlP5 cp5) {
;

cp5.addButton("loadBackgroundImage")
.setLabel("Load background image")
.setGroup("file")
.setPosition( margin, margin + (spacing + barHeight) * 4)
.setSize( menuWidth - margin * 2, barHeight )
Expand Down Expand Up @@ -891,10 +885,9 @@ void exportPDFPressed() {
void exportDXFPressed() {
selectOutput("Export DXF:", "exportDXF");
menuState = MENUS_OFF;

}

void loadBackgroundImageButton() {
void loadBackgroundImage() {
selectInput("Please select a background image", "loadBackground" );
}

Expand Down

0 comments on commit 4df9e25

Please sign in to comment.