Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01a1b85
commit e6bac21
Showing
12 changed files
with
685 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# More on this file here: https://github.com/processing/processing/wiki/Library-Basics | ||
# UTF-8 supported. | ||
|
||
# The name of your Library as you want it formatted. | ||
name = Dashed Lines | ||
|
||
# List of authors. Links can be provided using the syntax [author name](url). | ||
authors = [Jose Luis Garcia del Castillo](http://garciadelcastillo.es) | ||
|
||
# A web page for your Library, NOT a direct link to where to download it. | ||
url = https://github.com/garciadelcastillo/-dashed-lines-for-processing- | ||
|
||
# The category (or categories) of your Library, must be from the following list: | ||
# "3D" "Animation" "Compilations" "Data" | ||
# "Fabrication" "Geometry" "GUI" "Hardware" | ||
# "I/O" "Language" "Math" "Simulation" | ||
# "Sound" "Utilities" "Typography" "Video & Vision" | ||
# | ||
# If a value other than those listed is used, your Library will listed as | ||
# "Other". Many categories must be comma-separated. | ||
categories = Geometry | ||
|
||
# A short sentence (or fragment) to summarize the Library's function. This will | ||
# be shown from inside the PDE when the Library is being installed. Avoid | ||
# repeating the name of your Library here. Also, avoid saying anything redundant | ||
# like mentioning that it's a Library. This should start with a capitalized | ||
# letter, and end with a period. | ||
sentence = Draw Processing shapes with dashed lines! | ||
|
||
# Additional information suitable for the Processing website. The value of | ||
# 'sentence' always will be prepended, so you should start by writing the | ||
# second sentence here. If your Library only works on certain operating systems, | ||
# mention it here. | ||
paragraph = | ||
|
||
# Links in the 'sentence' and 'paragraph' attributes can be inserted using the | ||
# same syntax as for authors. | ||
# That is, [here is a link to Processing](http://processing.org/) | ||
|
||
# A version number that increments once with each release. This is used to | ||
# 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 = 1 # This must be parsable as an int | ||
|
||
# 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 = 0.0.1 # 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, | ||
# parsable as an int. For example, the revision number for 2.2.1 is 227. | ||
# You can find the revision numbers in the change log: https://raw.githubusercontent.com/processing/processing/master/build/shared/revisions.txt | ||
# Only use maxRevision (or minRevision), when your Library is known to | ||
# break in a later (or earlier) release. Otherwise, use the default value 0. | ||
minRevision = 0 | ||
maxRevision = 0 |
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
...Dash_01_Hello_Dash/Dash_01_Hello_Dash.pde → examples/ex01_Hello_Dash/ex01_Hello_Dash.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* DASHED LINES | ||
* Basic dashed lines, and the things you can do with them. | ||
* | ||
* Dashed Lines for Processing, by Jose Luis Garcia del Castillo 2017 | ||
* https://github.com/garciadelcastillo/-dashed-lines-for-processing- | ||
*/ | ||
|
||
import garciadelcastillo.dashedlines.*; | ||
|
||
DashedLines dash; | ||
Node n1, n2; // some draggable nodes for added interactivity | ||
float dist = 0; | ||
|
||
void setup() { | ||
size(800, 600); | ||
noFill(); | ||
strokeWeight(5); | ||
strokeCap(SQUARE); | ||
textAlign(CENTER); | ||
|
||
dash = new DashedLines(this); | ||
dash.pattern(20, 10); | ||
|
||
n1 = new Node(0.25 * width, 0.5 * height, 5); | ||
n2 = new Node(0.75 * width, 0.5 * height, 5); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
|
||
n1.render(); | ||
n2.render(); | ||
|
||
dash.line(n1.x, n1.y, n2.x, n2.y); | ||
|
||
// Animate dashes with 'walking ants' effect | ||
dash.offset(dist); | ||
dist += 1; | ||
|
||
pushStyle(); | ||
fill(0); | ||
text("Drag nodes around", 0.5 * width, height - 25); | ||
popStyle(); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
// A quick class for a draggable node | ||
class Node { | ||
|
||
float x, y; | ||
float r; | ||
boolean dragged; | ||
|
||
Node(float x_, float y_, float r_) { | ||
x = x_; | ||
y = y_; | ||
r = r_; | ||
} | ||
|
||
void render() { | ||
pushStyle(); | ||
noStroke(); | ||
fill(127, 100); | ||
ellipse(x, y, 2 * r, 2 * r); | ||
popStyle(); | ||
if (dragged) { | ||
x = mouseX; | ||
y = mouseY; | ||
} | ||
} | ||
|
||
boolean inside(float xpos, float ypos) { | ||
return dist(x, y, xpos, ypos) < r; | ||
} | ||
} | ||
|
||
void mousePressed() { | ||
if (n1.inside(mouseX, mouseY)) { | ||
n1.dragged = true; | ||
} else if (n2.inside(mouseX, mouseY)) { | ||
n2.dragged = true; | ||
} | ||
} | ||
|
||
void mouseReleased() { | ||
n1.dragged = false; | ||
n2.dragged = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* DASHED 2D PRIMITIVES | ||
* A showcase of simple 2D primitives drawn with dashed lines. | ||
* | ||
* Dashed Lines for Processing, by Jose Luis Garcia del Castillo 2017 | ||
* https://github.com/garciadelcastillo/-dashed-lines-for-processing- | ||
*/ | ||
|
||
import garciadelcastillo.dashedlines.*; | ||
|
||
DashedLines dash; | ||
Node[] n; | ||
float dist = 0; | ||
|
||
void setup() { | ||
size(800, 600); | ||
strokeWeight(5); | ||
strokeCap(SQUARE); | ||
textAlign(CENTER); | ||
|
||
dash = new DashedLines(this); | ||
|
||
// Dash patterns can be created with different combinations of dash-gap lengths | ||
//dash.pattern(30); | ||
//dash.pattern(30, 10); | ||
dash.pattern(30, 10, 15, 10); | ||
//float[] decreasingPattern = { 50, 10, 40, 10, 30, 10, 20, 10, 10, 10 }; | ||
//dash.pattern(decreasingPattern); | ||
|
||
initializeNodes(); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
renderNodes(); | ||
|
||
// Dashed objects inherit Processing's style properties, including shape modes. | ||
fill(255, 0, 0, 100); | ||
rectMode(CORNERS); | ||
dash.rect(n[0].x, n[0].y, n[1].x, n[1].y); | ||
|
||
fill(0, 255, 0, 100); | ||
ellipseMode(CORNERS); | ||
dash.ellipse(n[2].x, n[2].y, n[3].x, n[3].y); | ||
|
||
fill(0, 0, 255, 100); | ||
dash.triangle(n[4].x, n[4].y, n[5].x, n[5].y, n[6].x, n[6].y); | ||
|
||
fill(255, 0, 255, 100); | ||
dash.quad(n[7].x, n[7].y, n[8].x, n[8].y, n[9].x, n[9].y, n[10].x, n[10].y); | ||
|
||
|
||
// Animate dashes with 'walking ants' effect | ||
dash.offset(dist); | ||
dist += 1; | ||
|
||
pushStyle(); | ||
fill(0); | ||
text("Drag nodes around", 0.5 * width, height - 25); | ||
popStyle(); | ||
} | ||
|
||
|
||
|
||
|
||
void initializeNodes() { | ||
n = new Node[11]; | ||
n[0] = new Node(1.0/8 * width, 1.0/8 * height, 5); | ||
n[1] = new Node(3.0/8 * width, 3.0/8 * height, 5); | ||
n[2] = new Node(5.0/8 * width, 1.0/8 * height, 5); | ||
n[3] = new Node(7.0/8 * width, 3.0/8 * height, 5); | ||
n[4] = new Node(2.0/8 * width, 5.0/8 * height, 5); | ||
n[5] = new Node(3.0/8 * width, 7.0/8 * height, 5); | ||
n[6] = new Node(1.0/8 * width, 7.0/8 * height, 5); | ||
n[7] = new Node(5.5/8 * width, 5.0/8 * height, 5); | ||
n[8] = new Node(7.0/8 * width, 5.0/8 * height, 5); | ||
n[9] = new Node(6.5/8 * width, 7.0/8 * height, 5); | ||
n[10] = new Node(5.0/8 * width, 7.0/8 * height, 5); | ||
} | ||
|
||
void renderNodes() { | ||
for (int i = 0; i < n.length; i++) { | ||
n[i].render(); | ||
} | ||
} | ||
|
||
|
||
// A quick class for a draggable node | ||
class Node { | ||
|
||
float x, y; | ||
float r; | ||
boolean dragged; | ||
|
||
Node(float x_, float y_, float r_) { | ||
x = x_; | ||
y = y_; | ||
r = r_; | ||
} | ||
|
||
void render() { | ||
pushStyle(); | ||
ellipseMode(CENTER); | ||
noStroke(); | ||
fill(127, 100); | ||
ellipse(x, y, 2 * r, 2 * r); | ||
popStyle(); | ||
if (dragged) { | ||
x = mouseX; | ||
y = mouseY; | ||
} | ||
} | ||
|
||
boolean inside(float xpos, float ypos) { | ||
return dist(x, y, xpos, ypos) < r; | ||
} | ||
} | ||
|
||
void mousePressed() { | ||
for (int i = 0; i < n.length; i++) { | ||
if (n[i].inside(mouseX, mouseY)) { | ||
n[i].dragged = true; | ||
} | ||
} | ||
} | ||
|
||
void mouseReleased() { | ||
for (int i = 0; i < n.length; i++) { | ||
n[i].dragged = false; | ||
} | ||
} |
Oops, something went wrong.