Why draw operation in android canvas are using float instead of int for (x,y)? For example: http://developer.android.com/reference/android/graphics/Canvas.html#drawCircle(float, float, float, android.graphics.Paint)
http://developer.android.com/reference/android/graphics/Canvas.html#drawRect(float, float, float, float, android.graphics.Paint)
If I have a lot of objects (say 200) to draw in my application and i have a class for each object, should I use 'int' or 'float' for the x, y attribute (the location of the object when drawn on screen)? i think 'float' use less memory than 'int'.
class MyObject {
public int x;
public int y;
}
Thank you.
Float because anti-aliasing allows you to paint at sub-pixel level. Also because there can be a transformation matrix active (e.g. A scale).
A float and int take both 32 bit (most likely)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With