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

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 24 Nov 2010 13:23:39 -0500
Message-ID: <4CED582B.7000005@mit.edu>
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.

Try this simple testcase:

<body>
   <canvas id="x" width="500" height="500"
           style="border: 1px solid red"></canvas>
   <script>
     var c = document.getElementById("x").getContext("2d");
     c.fillStyle = "green"
     c.font = "30px sans-serif";
     c.fillText("aaa", 100, 100);
     c.font = "10px sans-serif";
     c.scale(3, 3);
     c.fillText("aaa", 100, 100);
   </script>
</body>

Note that the two strings look different in at least Firefox, Chrome and 
Opera on Mac (in fact in Opera on Mac the upscaled one looks really 
crappy, but there are differences in the other browsers too)

> I'm going to go back to the ad-hominem.

<shrug>.  I think I'm done with this thread.

>> My faith in canvas coders is closer to 0.2 (on a 0-1 scale), largely
>> because it's not quite as mainstream yet, so only the more competent
>> folks are doing it.
> I hope you have more respect for other parts of your user base.

What does this have to do with respect?  Canvas coders are just trying 
to get something done, as are browser users.

Browser users tend to not be experts on browser stuff.  Neither do 
canvas coders, for the most part (largely because no one is in a 
position to really be an expert on all the various parts of a browser at 
this point).  I certainly don't claim to be one.

But the upshot is that people make mistakes.  If you don't assume they 
will, you come to grief.

-Boris
Received on Wednesday, 24 November 2010 10:23:39 UTC

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