Give out point in a Fontshape to an array?
in
Contributed Library Questions
•
2 years ago
Hey Folks,
I am not sure how I can give out x and y coordinates to an Array or Arraylist.
I am trying to find points in a shape working with geomerative
A simple tester is contains. I also get the points drawn but I want to use them later.
I am not sure how I can give out x and y coordinates to an Array or Arraylist.
I am trying to find points in a shape working with geomerative
A simple tester is contains. I also get the points drawn but I want to use them later.
- /* BUGS:
- abstandFill: jekleiner um so langsamer die Anwendung
- strokeWeight in draw(): verlangsam Anwendungen
*/
import geomerative.*;
RFont font;
int gridSize;
int x = 0;
int y = 0;
int fillCounter = 0;
int initSetup = 0;
int abstandFill = 2;
String UNSERWORT = "A";
void setup() {
size(500,500, P3D);
smooth();
noStroke();
gridSize = width/abstandFill*height/abstandFill;
println(gridSize);
if(UNSERWORT.length() > 0) {
RG.init(this);
font = new RFont( "lucon.ttf", 200, RFont.CENTER);
RGroup grp = font.toGroup(UNSERWORT);
RCommand.setSegmentLength(1);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
grp = grp.toPolygonGroup();
RPoint[] pnts = grp.getPoints();
println("gridSize: " + gridSize);
if (pnts.length > gridSize) {
gridSize = gridSize;
println("pnts.length > gridSize");
} else {
gridSize = pnts.length;
println("ELSE: gridSize = pnts.length");
}
println("gridSize: " + gridSize);
}
}
void draw() {
background(255);
translate(width/2, (height+ 200/2)/2);
pushMatrix();
fill(100);
//RG.shape(grpsShape);
RGroup grp = font.toGroup(UNSERWORT);
RShape grpsShape = font.toShape(UNSERWORT);
RCommand.setSegmentLength(1);
RCommand.setSegmentator(RCommand.UNIFORMLENGTH);
grp = grp.toPolygonGroup();
RPoint[] pnts = grp.getPoints();
println("Outline-Points: " + pnts.length);
popMatrix();
if (pnts.length > gridSize) {
gridSize = gridSize;
//println("pnts.length > gridSize");
} else {
gridSize = pnts.length;
//println("ELSE: gridSize = pnts.length");
}
// FUNKTIONIERENDES BEISPIEL 1
// ---------------------------
//translate(-width/2,-height/2);
pushMatrix();
fill(0);
for (int i = -width/2; i < width/2; i=i+abstandFill) {
for (int j = -height/2; j < height/2; j=j+abstandFill) {
if (grpsShape.contains(i,j)) {
//translate(-width/2,-height/2);
ellipse(i, j, 2, 2);
fillCounter++;
}
}
}
println("Anzahl füllende Objekte: " + fillCounter);
fillCounter = 0; // zurücksetzen
popMatrix();
noFill();
1