Hey there.
Yes, Ged it is correct about the units. We don't have any support internally for units at this point, but that doesn't mean you cannot add them. Vector graphics are unit-less and scalable in nature, the units are only provided by the context (e.g. how big is the document that we're looking at).
According to this website, 1 meter for example is 3779.527559055 pixels:
http://www.unitconversion.org/unit_converter/typography.html
Note that this is a convention. Without a DPI information, there is no clear way of mapping one to the other. I assume the above value results from using the default 72DPI, which is outdated and does not actually apply to any screen anymore these days.
Ignoring this, JavaScript allows you to add methods to the Number prototype, so you could do things like the code below, and they would all convert to the internal, unit-less form which is in pixels, in their respective ratios that you'll have to decide on (Applications like Adobe Illustrator do the exact same thing):
Number.prototype.meters = function() {
return this / 3779.527559055;
}
Number.prototype.millimiters = function() {
return this / 3.779527559055;
}
(10).meters()
(0.5).millimiters()
The parenthesis are necessary because JavaScript interprets the period as the beginning of the fractional digits otherwise.
This is just one way you could accomplish this. You could also define them as globals and call it like this.
meters(10)
millimiters(0.5)
Best,
Jürg
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
paperjs+u...@googlegroups.com.