Issue
I'd like to increment point by point in the function y = x^2 with playing on a scale. so I start by drawing point 2.00-4.00 then 2.01-4.0401, etc... I get crazy as x stays at 2.0 in the loop and getting the value in debug it is always 2.0.
int x = 2;
int y = 4;
int scale = 100;
float xx = (float) x;
float yy = (float) y;
for(int k=0;k<scale;k++) {
canvas.drawPoint((float) (xx*scale) , (float) (yy*scale), paint);
xx = xx + (1/scale);
yy = xx * xx;
}
what am I doing stupid? Many thanks!
Solution
That is because scale
is an integer and 1/scale is zero. Try replacing it with 1/(float)scale
Answered By - hoomi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.