problem with textAlign();
in
Programming Questions
•
3 years ago
I have a small test program to draw some text. Experimenting with textAlign(), I find that only LEFT alignment works as I expect.
Does anyone see what might be wrong?
.andy
Of course, the problem could be my expectations, but it seems as if CENTER and RIGHT alignment in my test do not align.
Here's the result:
I would have expected the green and blue text to be somewhat to the left.
Here's the code:
- int winWidth = 600; //
- int winHeight = 180; //
- color winColor = color (224, 229, 218); // background color of window
- color lineColor = color ( 64, 128, 0);
- color t1 = color ( 255, 0, 0);
- color t2 = color ( 0, 200, 0);
- color t3 = color ( 0, 0, 255);
- void setup () {
- // draw window and fill it with background color
- size (winWidth, winHeight);
- background (winColor);
- stroke (lineColor);
- line(300,0,300,180);
- fill (t1);
- textAlign(LEFT);
- text("\"Any sufficiently advanced technology\"", 300, 75);
- fill (t2);
- textAlign(CENTER);
- text("\"Any sufficiently advanced technology\"", 300, 90);
- fill (t3);
- textAlign(RIGHT);
- text("\"Any sufficiently advanced technology\"", 300, 105);
- }
- void draw () {
- }
Many thanks.
.andy
1