Creating Letters from Circular Objects

I wanted to input from the people on here about a problem I am currently working on.

I want to take a string in a given font and create the string using a 3d model of a flat bottomed, round stone. I am currently creating a glyphVector from the given string and getting the outline and placing stones at the points in the outline.

The issue is that I only get some points. For example, if the string is “H”, I just get 4 points, one at the end of each vertical line. I want to be able to create the “H” from my circular stone object.

Does anyone have any ideas or suggestions as to what I could do differently?

Here is and example of what I am currently doing:
[java] public void ShapeTest() {

    String s = "Hello";
    Font font = new Font("Arial", Font.PLAIN, 72);

    FontRenderContext frc = new FontRenderContext(null, false, false);

    GlyphVector gv = font.createGlyphVector(frc, s);

//Get the “H” character
Shape test = gv.getGlyphVisualBounds(0);

    PathIterator itr = test.getPathIterator(null);
    float[] coords = new float[6];
    ArrayList<Point> points = new ArrayList<Point>();

    while (!itr.isDone()) {
      int type =  itr.currentSegment(coords);
        int x = (int) coords[0];
        int y = (int) coords[1];

        points.add(new Point(x, y));
        itr.next();
    }

    for (int i = 0; i < points.size(); i++) {

        posToPlaceStone.x = points.get(i).x;
        posToPlaceStone.y = points.get(i).y;
        MakeStone("StoneModel");
    }
}[/java]

[java]
// pseudo code
if( distance from last stone > stoneSpacing ) {
for( pos = lastStonePos; pos < nextStonePos; pos += stoneSpacing ) {
place a stone
}
}
[/java]

?

@pspeed said: [java] // pseudo code if( distance from last stone > stoneSpacing ) { for( pos = lastStonePos; pos < nextStonePos; pos += stoneSpacing ) { place a stone } } [/java]

?

I understand what you are doing there, but I am not quite understanding how that will place the stones based on the shape outline.

You have to pay closer attention to the path. You have to render the segments and not just the points.

Ahh ok. Thank you for your help. I was able to place the stones along the path. It looks pretty good, but I am having some difficulty in getting them spaced properly. Certain strings look ok, but others have gaps in them, which makes them look bad.

I calculated the total length of the path and divided that by the width of the stone object to determine how many stones would fit along the path. From there I used that number to figure out how far apart to place each stone, but this technique did not look correct at all.

Any suggestions would be much appreciated. I am apparently not very skilled with using paths…

Can you show a picture of what looks bad and what you’d rather it look like?

From your description it sounds like you may need to eliminate the remainder so that the gaps stretch/grow as needed to not overlap stones… but I’m only guessing what “look bad” means.

You were correct. I was not taking the remainder into account. I think everything is looking good now. Thank you so much for your help. If you are ever in Texas, let me know and I will buy you a beer. (or a beverage of your choice if beer is not your thing) =D

@ChrisGraham said: You were correct. I was not taking the remainder into account. I think everything is looking good now. Thank you so much for your help. If you are ever in Texas, let me know and I will buy you a beer. (or a beverage of your choice if beer is not your thing) =D

Hahah… glad my “Dungeon Master”-style cryptic hints helped. :slight_smile: