Loading...
Logo
Processing Forum
Let you try attached sample sketch. Single pixel black dots are plotted upper side of text-line.

Copy code
  1. size(640, 400);
  2. String _FONTNAME = "FFScala";
  3. PGraphics pg = createGraphics(640, 480, P3D);
  4. PFont font = createFont("FFScala", 18, false);
  5. pg.beginDraw();
  6. pg.textFont(font);
  7. pg.textMode(SCREEN);
  8. pg.textSize(18);
  9. pg.textAlign(LEFT, TOP);
  10. pg.endDraw();
  11. pg.beginDraw();
  12. pg.text("Look upward of this line. There are many single pixel dots.", 100, 100);
  13. pg.endDraw();
  14. blend(pg, 0, 0, 640, 480, 0, 0, 640, 480, BLEND);

Replies(6)

I don't know the source of the problem, but removing line 7 fixes it...
Thanks, calsign! You right!!

But...my application need SCREEN setting ! (> <)
Is this so that you can draw text in front of a 3D display?
If it is, there are alternatives to using SCREEN...
Hi calsign. thanks for your reply!

I don't need 3-dimension feature, however text() did not output(display) any characters when I had tried "JAVA2D" renderer.
Now I have tried "P2D", then the illegal pixels are still displayed (with SCREEN setting).
I guess that P2D renderer equalt to JAVA2D in Processing 1.5, isn't it?
" I guess that P2D renderer equalt to JAVA2D in Processing 1.5, isn't it?"
Not at all!
JAVA2D, as the name implies, delegates most of the drawing to Java2D, the graphics layer designed by Sun.
P2D and P3D are renderers made by the Processing designers, drawing pixels directly. It is faster (not drawing on an offline buffer, to load when doing pixel operations, etc.) but more subject to bugs (somehow, less tested than JAVA2D, used by hundred of thousands of professional developers worldwide).
If you remove textMode(SCREEN), unnecessary in JAVA2D with createFont(), you will see your text, without the black pixels.
Hi! PhiLho, thanks for detail information about P2D and JAVA2D.

Sorry, that is my misunderstanding!
I tried to switch JAVA2D and P2D on my application and confirmed that P2D is faster than JAVA2D clearly.

# pg.textFont(font) is necessary for displaying japanese characters.

Case (A) is JAVA2D version. No problem, but running speed of my application is very slow...I want to use P2D.
Case (B) is P2D version. Both of with/without SCREEN, illeagal pixel problem occurs.
Case (C) is P3D version. Ok, without SCREEN, there are no illegal dots! but color of japanese characters is not white...

Based on above experimental results, I had chosen a couple of P3D and SCREEN, and small hack that skip of outputting only space character in string for text(). This small hack can apply for P2D too, then now I use a couple of P2D and SCREEN with the hack.

Copy code
  1. size(640, 480);
  2. PGraphics pg = createGraphics(640, 480, JAVA2D);  // Case (A)  Slow, can resolve illegal pixel problem (without SCREEN)
  3. //PGraphics pg = createGraphics(640, 480, P2D);       // Case (B)  Fast, but illegal pixel problem (with/without SCREEN)
  4. //PGraphics pg = createGraphics(640, 480, P3D);       // Case (C)  Fast, without SCREEN then OK, however Japanese characters become gray.
  5. PFont font = createFont("FFScala", 18, false);
  6. pg.beginDraw();
  7. pg.textFont(font);  // need for Japanese (multi-byte characters)
  8. //pg.textMode(SCREEN);  // case (A) : comment out, case (B) : necessarily since color of Japanese characters become gray...
  9. pg.textSize(18);
  10. pg.textAlign(LEFT, TOP);
  11. pg.endDraw();
  12. pg.beginDraw();
  13. pg.text("Look upward of this line. There are many single pixel dots.", 50, 100);
  14. pg.text("Japanese : 上を見て.いくつかの小さなドットが表示されてしまう.", 50, 200);
  15. pg.endDraw();
  16. blend(pg, 0, 0, 640, 480, 0, 0, 640, 480, BLEND);