- import geomerative.*;
- import org.apache.batik.svggen.font.table.*;
- import org.apache.batik.svggen.font.*;
- RFont font;
- RShape form;
- RPoint[][] anchors;
- RPath[] paths;
- RShape[] anotherForm;
- void setup() {
- size(400, 400);
- smooth();
- RG.init(this);
- font = new RFont("DroidSans.ttf", 40, RFont.CENTER);
- form = font.toShape("RFont-RShape");
- anchors = form.getPointsInPaths();
- paths = new RPath[anchors.length];
- anotherForm = new RShape[anchors.length];
- for(int i = 0; i < anchors.length; i++) {
- paths[i] = new RPath(anchors[i]);
- anotherForm[i] = new RShape(paths[i]);
- }
- ellipseMode(CENTER);
- rectMode(CENTER);
- }
- void draw() {
- background(255);
- fill(0);
- noStroke();
- pushMatrix();
- translate(width/2, height/2 - 150);
- font.draw("RFont");
- popMatrix();
- pushMatrix();
- translate(width/2, height/2 - 50);
- form.draw(g);
- popMatrix();
- if(form.contains(mouseX - width/2, mouseY - height/2 + 50)) {
- ellipse(134, 140, 5, 5);
- } else {
- rect(134, 140, 5, 5);
- }
- pushMatrix();
- translate(width/2, height/2 + 50);
- for(int i = 0; i < anotherForm.length; i++) {
- anotherForm[i].draw(g);
- }
- popMatrix();
- fill(255);
- for(int i = 0; i < anotherForm.length; i++) {
- if(anotherForm[i].contains(mouseX - width/2, mouseY - height/2 - 50)) {
- ellipse(134, 240, 5, 5);
- break;
- } else {
- if(i == anotherForm.length - 1) rect(134, 240, 5, 5);
- }
- }
- }
OR
Is there a way to know which letter fires the
.contains() in the
RShape form?
If you need the font to run this you can find
DroidSans over at Google.
I need a way to know the particular (in this case) letter that the mouse is over.
1