Skip to content

Commit

Permalink
Merge pull request #1 from drskullster/master
Browse files Browse the repository at this point in the history
Pen speed control
  • Loading branch information
ciaron authored Nov 19, 2017
2 parents 579fc75 + ab75fa6 commit 12f4644
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin
tmp
distribution
*.iml
.idea/
32 changes: 32 additions & 0 deletions examples/speed/speed.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import hpglgraphics.*;

int lines = 30;

void setup() {

size(1104, 772);

HPGLGraphics hpgl = (HPGLGraphics) createGraphics(width, height, HPGLGraphics.HPGL);

hpgl.setPaperSize("A4");
hpgl.setPath("output.hpgl");

background(255);
stroke(0);
fill(0);

beginRecord(hpgl);

// draw lines at incremental speed
for(int i = 0; i < lines; i++) {
hpgl.setSpeed(i);
int y = height / lines * (i + 1);
line(0, y, width, y);
}

endRecord();

}

void draw() {
}
4 changes: 2 additions & 2 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ source.repository=https://github.com/ciaron/HPGLGraphics.git
# This is used to compare different versions of the same Library, and check if
# an update is available.

library.version=4
library.version=5


# The version as the user will see it.

library.prettyVersion=1.0.3
library.prettyVersion=1.0.4


# The min and max revision of Processing compatible with your Library.
Expand Down
4 changes: 2 additions & 2 deletions resources/library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ paragraph = This library works in much the same way as PDF or DXF export - by wr
# compare different versions of the same Library, and check if an update is
# available. You should think of it as a counter, counting the total number of
# releases you've had.
version = 004
version = 005

# The version as the user will see it. If blank, the version attribute will be
# used here. This should be a single word, with no spaces.
prettyVersion = 1.0.3 # This is treated as a String
prettyVersion = 1.0.4 # This is treated as a String

# The min and max revision of Processing compatible with your Library.
# Note that these fields use the revision and not the version of Processing,
Expand Down
24 changes: 21 additions & 3 deletions src/hpglgraphics/HPGLGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,34 @@ public void setPath(String path) {
throw new RuntimeException("Something went wrong trying to create file "+this.path);
}
}

/**
* This method selects plotter pen via the HPGL 'SP' instruction.
* Called from the Processing sketch.
*
*
* @example simple_demo
* @param pen : integer number of pen to select (depends on plotter)
*/
public void selectPen(int pen) {
writer.println("SP"+pen+";");
if(writer != null) {
writer.println("SP"+pen+";");
} else {
System.out.println("selectPen() used outside of beginRecord() has no effect");
}
}

/**
* This method sets speed for pen moves when down via the HPGL 'VS' instruction.
*
* @example speed
* @param speed : integer number for speed from 0 to 127
*/
public void setSpeed(int speed) {
if(writer != null) {
writer.println("VS"+speed+";");
} else {
System.out.println("setSpeed() used outside of beginRecord() has no effect");
}
}

public void beginDraw() {
Expand Down

0 comments on commit 12f4644

Please sign in to comment.