Make a Delaunay diagram with Geomerative + Lee Byron's Mesh library
in
Contributed Library Questions
•
1 year ago
Dear all interested readers,
I am trying to combine two sketches.
What I want to achieve is to take points from a SVG-file and use these points for the Delaunay mesh.
This is how I get the points from the SVG:
So, I would like to use the points I get by using the Geomerative library, and use these points to create a mesh.
What would be the best solution?
Thanks in advance.
Kind regards,
Joshua
I am trying to combine two sketches.
What I want to achieve is to take points from a SVG-file and use these points for the Delaunay mesh.
This is how I get the points from the SVG:
- import geomerative.*;
- RPoint[] myPoints;
- float circleSize = 20;
- void setup() {
- size(500, 500);
- smooth();
- noLoop();
- RG.init(this);
- RShape s = RG.loadShape("letterr.svg");
- myPoints = s.getPoints();
- }
- void draw() {
- background(0);
- for (int i = 0; i < myPoints.length; i += 10) {
- fill(255);
- ellipse(random(myPoints[i].x-10,myPoints[i].x+10), random(myPoints[i].y-10,myPoints[i].y+10), circleSize, circleSize);
- }
- noLoop();
-
- }
- import megamu.mesh.*;
- float[][] points = new float[7][4];
- Delaunay myDelaunay ;
- void setup() {
- size(600, 600);
- background(255);
- }
- void draw() {
- points[0][0] = mouseX;
- points[0][1] = mouseY;
- points[1][0] = 150;
- points[1][1] = 105;
- points[2][0] = 320;
- points[2][1] = 113;
- points[3][0] = 220;
- points[3][1] = 413;
- points[4][0] = 160;
- points[4][1] = 253;
- points[5][0] = 230;
- points[5][1] = 30;
- points[6][0] = 500;
- points[6][1] = 500;
- myDelaunay = new Delaunay( points );
- background(200, 200, 250);
- strokeWeight(3);
- stroke(250);
- int[][] myLinks = myDelaunay.getLinks();
- for (int i=0; i<myLinks.length; i++)
- {
- int startIndex = myLinks[i][0];
- int endIndex = myLinks[i][1];
- float startX = points[startIndex][0];
- float startY = points[startIndex][1];
- float endX = points[endIndex][0];
- float endY = points[endIndex][1];
- line( startX, startY, endX, endY );
- }
- }
So, I would like to use the points I get by using the Geomerative library, and use these points to create a mesh.
What would be the best solution?
Thanks in advance.
Kind regards,
Joshua
1