We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › text command misunderstanding?
Page Index Toggle Pages: 1
text command misunderstanding??? (Read 963 times)
text command misunderstanding???
Sep 4th, 2009, 1:43pm
 
Hi,
i am trying to draw text on graphic using the text command and got a issue.
diambille is a float, and in the help of command text it says that the first data can be either a float, int or string, but as i try to compile i get the error:
the method text(char[], int, int, float, float) in the type PGraphics is not applicable for the arguments (float, int, int, int, int)
i am using processing 1.0.3
any idea?
Thanks in advance

Code:
  f.beginDraw();
f.textFont(font);
f.text(diamBille,0,0,300,200);
f.endDraw();
image(f,0,0);
Re: text command misunderstanding???
Reply #1 - Sep 5th, 2009, 4:43am
 
A bit puzzling if you declare diamBille as float.
But well, you can use a simple workaround:
f.text("" + diamBille,0,0,300,200);
Re: text command misunderstanding???
Reply #2 - Sep 6th, 2009, 8:52am
 
Thanks o found str () fonction that were a solution too.


But that doesn't tell me why the original fonction doesn't work as it says it should.

Pat Gadget
Re: text command misunderstanding???
Reply #3 - Sep 6th, 2009, 9:30am
 
http://dev.processing.org/reference/core/javadoc/processing/core/PGraphics.html

says that the method takes a float and then either x and y or x, y and z, a total of 3 or 4 floats. you're giving it 5.

void      text(float num, float x, float y)
         This does a basic number formatting, to avoid the generally ugly appearance of printing floats.

void      text(float num, float x, float y, float z)
Re: text command misunderstanding???
Reply #4 - Sep 6th, 2009, 10:14am
 
Ah, I overlooked that... koogy is right, no point in indicating max width and height of text for a simple float (no wrapping...).
Page Index Toggle Pages: 1