Closed ianmackenzie closed 5 years ago
Pixels.fromInt
and Pixels.fromFloat
might be better - a little inconsistent with Quantity.int
and Quantity.float
, but it is a slightly different operation: a Quantity Float Unitless
is semantically the same as a plain Float
value, while a Quantity Float Pixels
is not. So it kind of makes sense that the former is constructed by Quantity.float
(just "a Float
quantity") while the latter would be constructed by Pixels.fromFloat
(convert a Float
to a number of pixels).
Problem: what should pixelsPerSecond
, inPixelsPerSecond
etc. be then? Perhaps best to stick with pixels
/inPixels
and either:
pixels 200
vs Pixels.pixels 200
)Quantity
on import (e.g. import Pixels as Quantity
) and then use Quantity.pixels
, Quantity.inPixels
etc.Aliasing-to-Quantity
(or perhaps even moving everything into a huge Quantity
module as suggested in #31) seems more promising - closing this for now.
Similar to the corresponding functions in
Quantity
:A little less flexible than
Pixels.pixels
/Pixels.inPixels
(not generic onnumber
type) but a bit more clear/explicit and read better when used in prefixed form (Pixels.toInt
vs.Pixels.inPixels
).Seems like a good general pattern to follow for any quantity type where the units type is synonymous with the quantity itself (pixels, game tiles, grid cells etc.) as opposed to ones where the same quantity can be expressed in many different units (length in meters/centimeters/feet, duration in hours/minutes/seconds, etc.).