W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2010

[whatwg] Processing the zoom level - MS extensions to window.screen

From: Roger Hågensen <rescator@emsai.net>
Date: Sat, 18 Dec 2010 19:11:07 +0100
Message-ID: <4D0CF93B.5040007@emsai.net>
On 2010-12-18 18:58, Charles Pritchard wrote:
> On 11/24/2010 10:23 AM, Boris Zbarsky wrote:
>> On 11/24/10 4:13 AM, Charles Pritchard wrote:
>>>>> > And, these aren't great lengths. It's about 6 lines of javascript.
>>>> Uh... That depends on how your drawing path is set up. If I understand
>>>> correctly what you're doing, you have to get the DPI ration (call 
>>>> it N),
>>>> change the canvas width/height by a factor of N, and change all
>>>> coordinates in all your drawing calls by a factor of N, right?
>>> You're correct, I grab DPI, lets call it xN and yN, I change the canvas
>>> width height.
>>> Then I run .scale(xN, xY) before my drawing calls. They're completely
>>> agnostic
>>> to the change.
>> Ah, I see.  I assumed you were actually trying to draw the fonts at 
>> the right size for the viewer, see, as opposed to doing an image 
>> upscale of text rendered at a smaller size.
> I frequently use scale(n,n) and scale(1/n,1/n) styles, as well as 
> translate, to set the offsets and ratio of my fillStyle
> when it's a pattern or gradient.
> Transformations are widely used by feature-rich canvas apps.
> font = (fontSize * fontScale) + 'px sans-serif';  is by no means foreign.
> While  translate can be used as a short-cut, for while-loops,
> its most important purpose is offsetting the fill style when painting 
> on textures.

Wouldn't a global (for the canvas) flag that sets the pixels/values to 
pseudopixels that are automatically translated (and thus DPI 
aware/scaled) make things a lot easier?
Windows does this, and so does the recent versions of MacOS and Linux 
GUIs as well.

In some Windows programs I make I get the OS DPI and calculate a 
modifier, this modifier is applied to all sizes so that 300px is scaled 
by say 1.07 if the user/OS is set at 102.72 DPI (well Windows would show 
this as 103 since it doesn't support float DPI, but my programs do)
But it would have been much easier if the scaling was automated under 
the hood and I could use just pseudo/virtual pixels, currently I have to 
wrap or apply scaling, .NET should handle it for you.
HTML (or rather CSS) has the "em", so canvas should also be able to do 
the same right?

Roger "Rescator" H?gensen.
Freelancer - http://www.EmSai.net/
Received on Saturday, 18 December 2010 10:11:07 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:29 UTC