kumarnvs
asked on
can i pass a float to drawLine() function
can i pass a float to drawLine() function
no, you can type cast the float value to int value.
g.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
cheers...
Jerson
g.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
cheers...
Jerson
ASKER
i have usedthis method only but i need to be precise
Why not multiply the values by 10 to the nth power. For example if you have 1.23, multiply it by 100 to make it 123 then in this case, the decimal places are also considered.
Jerson
Jerson
You have to decide which precision you need and then use jerch comments to draw the line.
There is no way to draw a fraction of a point, you can only draw a point or not.
And lines are many points.
You have to adjust your coordinate system to this.
Lets say x and y are running from 0.00 to 1.00
than you have to map (0.00,0.00) to 0,0
and 1.00/1.00 to 100/100 ... to be able to draw all possible lines in this range with 2 digit precision.
In extension to jerch's comment, to be more precise round and scale (multiplying by something usefull) your values.
P.S. Give jerch the points he give the answer
There is no way to draw a fraction of a point, you can only draw a point or not.
And lines are many points.
You have to adjust your coordinate system to this.
Lets say x and y are running from 0.00 to 1.00
than you have to map (0.00,0.00) to 0,0
and 1.00/1.00 to 100/100 ... to be able to draw all possible lines in this range with 2 digit precision.
In extension to jerch's comment, to be more precise round and scale (multiplying by something usefull) your values.
P.S. Give jerch the points he give the answer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the answers.
ASKER