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

Make collages resolution independent #144

Merged
merged 1 commit into from Jan 27, 2015

Conversation

Projects
None yet
3 participants
@salutis
Contributor

salutis commented Jan 26, 2015

This should make Elm more usable on modern systems with high-resolution screens. Tested with Retina MacBook Pro 15".
Related discussion: https://groups.google.com/forum/#!topic/elm-discuss/pq1KS8XgFiQ

@Apanatshka

This comment has been minimized.

Show comment
Hide comment
@Apanatshka

Apanatshka Jan 26, 2015

I took a look at the support for devicePixelRatio on MDN which in turn refers to PPK. I would suggest that you use a local variable and default the value to 1 if window.devicePixelRatio doesn't exist:

devicePixelRatio = window.devicePixelRatio || 1;

And please note that MDN says this property doesn't get updated if the browser is moved between screens with different device pixel ratios.

Apanatshka commented Jan 26, 2015

I took a look at the support for devicePixelRatio on MDN which in turn refers to PPK. I would suggest that you use a local variable and default the value to 1 if window.devicePixelRatio doesn't exist:

devicePixelRatio = window.devicePixelRatio || 1;

And please note that MDN says this property doesn't get updated if the browser is moved between screens with different device pixel ratios.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 26, 2015

Member

Great, thank you so much! :D

I think there is one place that needs to know about the new initial scale though. Specifically when dealing with an Element inserted with toForm. I believe there's something like createTransform that needs its initial configuration updated.

Member

evancz commented Jan 26, 2015

Great, thank you so much! :D

I think there is one place that needs to know about the new initial scale though. Specifically when dealing with an Element inserted with toForm. I believe there's something like createTransform that needs its initial configuration updated.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 26, 2015

Member

Is there an event that triggers when windew.devicePixelRatio changes?

There is already a mechanism to do a redraw asynchronously (for images), so I assume that could be reused?

Member

evancz commented Jan 26, 2015

Is there an event that triggers when windew.devicePixelRatio changes?

There is already a mechanism to do a redraw asynchronously (for images), so I assume that could be reused?

@salutis

This comment has been minimized.

Show comment
Hide comment
@salutis

salutis Jan 26, 2015

Contributor

MDN says: There are no callbacks or events to listen to when this value changes (for example, if you drag the window between displays with different densities).

Contributor

salutis commented Jan 26, 2015

MDN says: There are no callbacks or events to listen to when this value changes (for example, if you drag the window between displays with different densities).

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 26, 2015

Member

Oh, I guess the toForm stuff should work the same, maybe I was wrong about that! Do you mind testing toForm thing to see if it is the right size?

Hmm, is there a recommended behavior for apps that need to cross from screen to screen? I assume going low to high is not a big deal, but is the reverse true?

Also, if the dimensions of the canvas are set initially, but then the scaling is done on a per-render bases, is it possible for them to get out of sync with each other?

Member

evancz commented Jan 26, 2015

Oh, I guess the toForm stuff should work the same, maybe I was wrong about that! Do you mind testing toForm thing to see if it is the right size?

Hmm, is there a recommended behavior for apps that need to cross from screen to screen? I assume going low to high is not a big deal, but is the reverse true?

Also, if the dimensions of the canvas are set initially, but then the scaling is done on a per-render bases, is it possible for them to get out of sync with each other?

@salutis

This comment has been minimized.

Show comment
Hide comment
@salutis

salutis Jan 26, 2015

Contributor

@evancz, I've just tried to embed Clock using toForm like this:
collage 400 400 [(toForm (collage 400 400 ...
... and it works as expected. Is that what you saying?

Contributor

salutis commented Jan 26, 2015

@evancz, I've just tried to embed Clock using toForm like this:
collage 400 400 [(toForm (collage 400 400 ...
... and it works as expected. Is that what you saying?

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 26, 2015

Member

Yeah, I was worried it might show up half size or something. Another example would be adding toForm (image 20 20 "http://elm-lang.org/yogi.jpg") and see if it comes out 20x20.

Member

evancz commented Jan 26, 2015

Yeah, I was worried it might show up half size or something. Another example would be adding toForm (image 20 20 "http://elm-lang.org/yogi.jpg") and see if it comes out 20x20.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 26, 2015

Member

Does the question about crossing from a normal monitor to a hi-DPI monitor make sense?

Member

evancz commented Jan 26, 2015

Does the question about crossing from a normal monitor to a hi-DPI monitor make sense?

@salutis

This comment has been minimized.

Show comment
Hide comment
@salutis

salutis Jan 26, 2015

Contributor

@evancz No issues. This:
collage 400 400 [toForm (image 20 20 "http://elm-lang.org/yogi.jpg")]
... draws exactly the same output as with http://elm-lang.org/try.

Contributor

salutis commented Jan 26, 2015

@evancz No issues. This:
collage 400 400 [toForm (image 20 20 "http://elm-lang.org/yogi.jpg")]
... draws exactly the same output as with http://elm-lang.org/try.

@evancz evancz merged commit c8f7c86 into elm:master Jan 27, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Jan 27, 2015

Member

Ah, I have read through the code all in one go and my concern is not realized there. Transferring from lo to hi should be no problem. Thanks a ton for working on this @salutis!

Member

evancz commented Jan 27, 2015

Ah, I have read through the code all in one go and my concern is not realized there. Transferring from lo to hi should be no problem. Thanks a ton for working on this @salutis!

@salutis

This comment has been minimized.

Show comment
Hide comment
@salutis

salutis Jan 27, 2015

Contributor

My pleasure, @evancz!

Contributor

salutis commented Jan 27, 2015

My pleasure, @evancz!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment