Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: clarify canvas coordinate system #2867

Merged
merged 4 commits into from Sep 28, 2017
Merged

Conversation

annevk
Copy link
Member

@annevk annevk commented Jul 26, 2017

Fixes #2854.

@annevk annevk added clarification Standard could be clearer topic: canvas labels Jul 26, 2017
source Outdated

<pre>&lt;canvas width=200 height=200 style=width:100px;width:100px></pre>

<p>This represents a 200x200 canvas (using 200x200 <span data-x="'px'">CSS pixels</span> as unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be clarified that 200x200 represents both: a) the domain of the canvas's coordinate space in CSS pixels, and b) the size of the canvas's bitmap in actual pixels.

source Outdated
<p>This represents a 200x200 canvas (using 200x200 <span data-x="'px'">CSS pixels</span> as unit
for ease of integration with CSS), rendered as 100x100 <span data-x="'px'">CSS pixels</span>. As
stated above this could be backed by 200x200 device pixels, meaning that each pixel on the canvas
is backed by a single device pixel.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me what you are trying to explain in this sentence. By "device pixels" are you referring to the pixels of the canvas's bitmap or the pixels of the physical display device? Whichever it is, this sentence doesn't really provide any actionable information (because of the word "could").

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referring to the physical device. It was meant as a statement of fact to affirm the details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then perhaps you should state what conditions need to be met in order to get 1 to 1 correspondence with physical device pixels. Something about the layout vs intrinsic size matching the devicePixelRatio.

@annevk
Copy link
Member Author

annevk commented Jul 27, 2017

I removed the last sentence and reworded the earlier one you commented on. I think it would still be nice to clarify the relationship between output bitmap / layout / actual device further, but it's a little hard for me to come up with the right terminology that makes it clear.

@junov
Copy link
Member

junov commented Jul 27, 2017

I agree. Perhaps we could say something like this: If the intrinsic size of the canvas element is equal to the layout size of the canvas element (e.g. if the width and height style properties are set to 'auto', which is the default), then a CSS pixel in the rendering context's coordinate space is equal in size to a CSS pixel in the canvas element's layout coordinate space. Otherwise, the canvas element's content is resized to fit, using the algorithm specified by the 'content-fit' CSS property.

@annevk
Copy link
Member Author

annevk commented Jul 27, 2017

That covers two out of three (which I actually hoped would be clear from the example I added), but doesn't cover physical device pixels.

@junov
Copy link
Member

junov commented Jul 27, 2017

The ratio between CSS pixels and physical device pixels is given by window.devicePixelRatio, we could just refer to that: https://drafts.csswg.org/cssom-view/#dom-window-devicepixelratio

@domenic
Copy link
Member

domenic commented Sep 21, 2017

What's the plan here?

@annevk
Copy link
Member Author

annevk commented Sep 21, 2017

I'm not sure. Let me push up some rewording. I don't really like referencing devicePixelRatio since that also drags zooming into the equation which makes it even more complicated. Maybe we should just leave device pixels out of it.

Copy link
Member

@junov junov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with nit

source Outdated
<div class="example">
<p>Using <span data-x="'px'">CSS pixels</span> to describe the size of a rendering context's
<span>output bitmap</span> does not mean that when rendered an equivalent number of <span
data-x="'px'">CSS pixels</span> ends up being used. <span data-x="'px'">CSS pixels</span> are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion:

(...) does not mean that when rendered the canvas will cover an equivalent area in <span data-x="'px'">CSS pixels</span>.

@annevk
Copy link
Member Author

annevk commented Sep 28, 2017

Addressed the nit. @domenic could you land?

@domenic
Copy link
Member

domenic commented Sep 28, 2017

Changing commit message per https://github.com/whatwg/meta/blob/master/TEAM.md

Prefix the summary line with "Editorial: " if the change is just to fix formatting, typos, or is a refactoring that does not change how the standard is understood. Note that bug fixes or clarifications are not editorial, even if they only affect non-normative text.

@domenic domenic merged commit 8f2146b into master Sep 28, 2017
@domenic domenic deleted the annevk/canvas-coordinates branch September 28, 2017 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer topic: canvas
Development

Successfully merging this pull request may close these issues.

None yet

3 participants