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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application size and width does not reflect width and height of target view #4731

Closed
DavidGOrtega opened this issue Mar 3, 2018 · 8 comments

Comments

@DavidGOrtega
Copy link

DavidGOrtega commented Mar 3, 2018

Hi, I'm here again! 馃槉

var app = new PIXI.Application( {transparent:true, antialias: true, view: mycanvas} );

Should not the height and width be aware of target view width and height instead of 800x600 as default?

@ivanpopelyshev
Copy link
Collaborator

Pixi does not have that logic, its your job to call app.renderer.resize and pass screen width and height there.

There's autoResize: true parameter that sets CSS width and height, useful with reslution: devicePixelRatio.

@DavidGOrtega
Copy link
Author

Now I'm doing this:

var canvas      = document.getElementById('c');
    canvas.width    = window.screen.width;
    canvas.height   = window.screen.height;

    var app = new PIXI.Application(canvas.width, canvas.height, {view: canvas, forceCanvas:false, transparent:true, antialias: true});

I was recently scratching my head on how to support autoResize and resolution. Is there any guide about that in the Docs? Or any interesting resource?

@ivanpopelyshev
Copy link
Collaborator

ivanpopelyshev commented Mar 4, 2018

https://github.com/pixijs/pixi.js/blob/dev/src/core/renderers/SystemRenderer.js#L218

Basically, if you ask app to resize to (W,H) with resolution A,, you'll get canvas of size (W*A, H*A) and if autoResize is true, then (W,H) will be passed to CSS. real pixels will be stored in renderer.view.width because its a canvas. Screen (css) pixels size is in renderer.screen. For your elements (Sprites, Containers) you have to specify screen coordinates, so resolution doesnt affect them.

That's all. If you want more - you have to experiment. I gave you the only part of code that responsible for canvas size.

Resolution in that case is zoom, like, for retina screens :)

@bigtimebuddy
Copy link
Member

@DavidGOrtega hopefully this will help:

Resize to Parent Node
https://jsfiddle.net/bigtimebuddy/wLg7jezb/

Resize to Fullscreen
https://jsfiddle.net/bigtimebuddy/oaLwp0p9/

@ivanpopelyshev
Copy link
Collaborator

@bigtimebuddy please add it to wiki.

@bigtimebuddy
Copy link
Member

@DavidGOrtega
Copy link
Author

Thanks a lot guys!

@lock
Copy link

lock bot commented Mar 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants