Thanks PhiLho - I've solved the issue for the same character (I think - I haven't tested it for every character), so I've modified the code to illustrate the essential problem - if I have a class that might be any character - 'o' or 'p' or 'd' or '☻' - how can I ensure that it will appear to rest with its bottom flush at a certain position?
I assume the solution is to include scalar in the class but I'm not sure how to programmatically set it for each character.
- float scalar = 0.0;
- ArrayList<Ball> balls;
- void setup() {
- size(640, 480);
- balls = new ArrayList();
- for (int i = 0; i < 50; i++) {
- balls.add(new Ball());
- }
- }
- void draw() {
- background(0);
- for (int i = 0; i < 50; i++) {
- balls.get(i).put();
- }
- }
- class Ball {
- char a;
- float x, y, size, desc;
- Ball () {
- a = char(ceil(random(80)) + 32);
- y = 0;
- size = random(64) + 1;
- x = random(width - size);
- desc = random(10)+1;
- }
- void put() {
- textSize(size);
- if (y < height - textDescent() * scalar) y += desc;
- else y = height - textDescent() * scalar;
- text(a, x, y);
- }
- }