Skip to content

Commit

Permalink
textOffsetCurves example
Browse files Browse the repository at this point in the history
  • Loading branch information
micycle1 committed Sep 1, 2021
1 parent e3f057a commit 1d1883b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to PGS will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Dates are *YYYY-MM-DD*.

## **1.1.3** *(2021-08-xx)*
## **1.1.3** *(2021-09-01)*
### Added
- `diameter()` to `PGS_ShapePredicates`. Computes the diameter of a shape.
- `width()` and `height()` to `PGS_ShapePredicates`.
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ A number of example Processing sketches are provided in [examples](https://githu

<p float="middle">
<a href="examples/partitionSmooth"><img src="resources/examples/partitionSmooth.png" alt="" width="24%"/></a>
<a href="examples/drawOffsetCurves"><img src="resources/examples/drawOffsetCurves.png" alt="" width="24%"/></a>
<a href="examples/textOffsetCurves"><img src="resources/examples/textOffsetCurves.png" alt="" width="24%"/></a>
<a href="examples/ripplingTriangles"><img src="resources/examples/ripplingTriangles.png" alt="" width="24%"/></a>
<a href="examples/contourMap"><img src="resources/examples/contourMap.png" alt="" width="24%"/></a>
</p>
Expand Down Expand Up @@ -156,7 +156,9 @@ Much of the functionality (but by no means all) is demonstrated below:


### Metrics
* Length
* Length/perimeter
* Width & Height
* Diameter
* Circularity
* Similarity
* Holes
Expand Down
4 changes: 4 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ All examples are dynamic and/or interactive. Shown below are merely screenshots.

<img src="../resources/examples/slice.png" alt="" width="500"/>

## textOffsetCurves

<img src="../resources/examples/textOffsetCurves.png" alt="" width="500"/>

## triangulate

<img src="../resources/examples/triangulate.png" alt="" width="500"/>
Expand Down
54 changes: 54 additions & 0 deletions examples/textOffsetCurves/textOffsetCurves.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import processing.javafx.*;
import micycle.pgs.*;
import java.util.List;

PShape pgs;
PFont font;

void setup() {
size(800, 800, FX2D);
smooth();
colorMode(HSB, 1, 1, 1, 1);
font = createFont(PFont.list()[(int) random(PFont.list().length)], 300, true);
}

void draw() {
background(0, 0, 0.1);
prepareText();
PShape offsetCurves = PGS_Contour.offsetCurvesOutward(pgs, PGS_Contour.OffsetStyle.BEVEL, 15 + sin(frameCount*0.02f)*8, 25);

float hue = 0;
final float inc = 1f / offsetCurves.getChildCount();
for (PShape offsetCurve : offsetCurves.getChildren()) {
offsetCurve.setStroke(color((hue+frameCount*0.01f) % 1, 0.8f, 1, 1));
offsetCurve.setStrokeWeight(3);
hue += inc;
}

shape(offsetCurves);
shape(pgs);
}

void prepareText() {
PShape p = font.getShape('P');
PShape g = font.getShape('G');
PShape s = font.getShape('S');
float pWidth = PGS_ShapePredicates.width(p);
float gWidth = PGS_ShapePredicates.width(g);
p = PGS_Morphology.fieldWarp(p, 50, 0.6, frameCount*0.01, false, 81);
g = PGS_Transformation.translate(g, pWidth + 30, 0);
g = PGS_Morphology.fieldWarp(g, 60, 0.75, frameCount*0.01, false, 1337);
s = PGS_Transformation.translate(s, pWidth + gWidth + 60, 0);
s = PGS_Morphology.fieldWarp(s, 30, 0.5, frameCount*0.01, false, 123081);
pgs = createShape(GROUP);
pgs.addChild(p);
pgs.addChild(g);
pgs.addChild(s);

pgs = PGS_Transformation.translateTo(pgs, width/2f, height/2f);
PGS_Conversion.setAllFillColor(pgs, color(0.5f, 0, 1));
}

void keyPressed() {
font = createFont(PFont.list()[(int) random(PFont.list().length)], 300, true);
}
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ authors=[Michael Carleton](https://github.com/micycle1/)
url=https://github.com/micycle1/PTS/
sentence=Software project that provides easy access to geometric algorithms
paragraph=
version=202101
prettyVersion=1.0.0
version=202109
prettyVersion=1.1.3
lastUpdated=0
minRevision=0
maxRevision=0
Binary file added resources/examples/textOffsetCurves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1d1883b

Please sign in to comment.