Type conversion for NSRect parameters
Am I doing something wrong, or does Swift have to be written with constant conversions? For example, I want to define a NSRect
circle for drawing, and I have already determined NSPoint
which will be its center, also I have a radius of the type Float
that will determine the width and height, but this should be multiplied by the scale Int
before, so I do it like this:
let objectRect = NSRect(x: center.x - radius*scale ...
I am getting a warning that I cannot propagate Int
to Float
. So now it looks like this:
let objectRect = NSRect(x: center.x - radius*Float(scale) ...
Now that part is fine, but another warning says what Float
cannot be subtracted from CGFloat
. Another conversion:
let objectRect = NSRect(x: Float(center.x) - radius*Float(scale) ...
Looks awful already, but at the top of the sticking out last warning says that NSRect does not accept Float, so I need to convert it to Double.
source to share