These are chat archives for pixijs/pixi.js

27th
Sep 2016
Urban
@UrKr
Sep 27 2016 10:58
I have a global renderer constant which I use for both. So I'm sure it's the same renderer. However it returns RenderTexture instead of Texture (as graphics.generateTexture()) does. Is that significant?
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 10:59
no its not
you can use easiest approach:
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
var context = canvas.getContext('2d');
context.fillStyle = 'white';
context.fillRect(0, 0, 1, 1);
var WHITE_1x1 = Texture.fromCanvas(canvas);
We have the same thing in latest 4.0.2 for pixi graphics, its called "Graphics._SPRITE_TEXTURE' and has 10x10 size
Urban
@UrKr
Sep 27 2016 11:01
aha, interesting. Ok, I'll try that
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 11:11
that will work for sure
Urban
@UrKr
Sep 27 2016 14:37
Question: is there a reason Graphics._SPRITE_TEXTURE is 10x10 and not 1x1?
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 14:40
no
Urban
@UrKr
Sep 27 2016 14:50
haha, ok :)
how do you make it so that zooming the browser doesn't mess with the canvas?
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:09
what'd you mean?
Nikita Agafonov
@lightest
Sep 27 2016 19:09
like no blurry stuff?
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:09
its always 800x600 there
Urban
@UrKr
Sep 27 2016 19:09
yes
Nikita Agafonov
@lightest
Sep 27 2016 19:09
without redrawing I'm afraid you can't
Urban
@UrKr
Sep 27 2016 19:10
I see
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:10
I have blurry stuff on 150%
Urban
@UrKr
Sep 27 2016 19:10
which browser?
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:10
zooming in brwser is inevitable evil
chrome
but if you ask about zooming TEXT
then its completely different stuff
Urban
@UrKr
Sep 27 2016 19:10
yes, the zooming is really screwing with me
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:10
font size must be somewhere near real pixel size on canvas.
Urban
@UrKr
Sep 27 2016 19:11
I don't specifically mean text
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:11
ah
well, if you just specified in css width:100% and height too
then it will be a problem
every time your window is resized (or zoomed) you have to do something with renderer
resize it too
but it all depends on what you want. so far i dont understand you
Urban
@UrKr
Sep 27 2016 19:13
I'm already handling window resize. I just redraw based on the new windows size.
However, with zoom I suppose I have to take scale into account?
Basically, I'm creating a graph where I need to display many items
So I have to use webgl/canvas, otherwise it's too slow.
Nikita Agafonov
@lightest
Sep 27 2016 19:16
and zooming?
for instance to see some part of graph closely?
Urban
@UrKr
Sep 27 2016 19:16
I do that within javascript
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:17
dont. do. zooming. its simple as that :)
zooming exists for canvas apps only for one purpose: to see what happens in different resolution
Urban
@UrKr
Sep 27 2016 19:17
yeah, the problem is that the graph opens in a new window
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:18
and whats the problem?
Urban
@UrKr
Sep 27 2016 19:18
and if the user has previously zoomed in on some html the graph is not going to show up correctly
because the browser will remember that zoom and use it for the new window
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:18
its ok, all canvas apps have that
zoom exists per domain, right
may be somehow detect it and ask user not to do it
Urban
@UrKr
Sep 27 2016 19:19
Yes it's per domain, and I suppose it isn't a problem when it's a pure canvas/webgl page
I suppose I should just detect it and notify the user, yes
I mean, the website is for work, so it shouldn't have TOO much of an adverse effect on keeping the user around
surely they won't scrap the whole site because they have to rezoom the graph. It is a bit annoying though :)
Urban
@UrKr
Sep 27 2016 19:38
Doesn't seem like there's a proper way to find out if the browser is zoomed in anymore. Damn. I don't understand why the browser wouldn't let you control that. Ok, maybe not all the time to avoid shenanigans, but at least on redirect.
If it at least let you read the zoom.
Ivan Popelyshev
@ivanpopelyshev
Sep 27 2016 19:39
:)
actually for that windows
you can just fix canvas size
and not to resize renderer
and apply width:100% height:100% css
but there might be a problem with interaction but its not always :)
Urban
@UrKr
Sep 27 2016 19:43
hm, let me try
Urban
@UrKr
Sep 27 2016 19:50
that did keep the image to the same portion of the screen, but it made it blurry, and unfortunately messed with the interaction, which is also quite extensive.
Aha, so now it works like the examples page on the pixi.js webpage.
Urban
@UrKr
Sep 27 2016 20:30
@ivanpopelyshev Yeah, your solution does actually work, provided that the browser window is maximized. Unfortunately, I can't rely on that. Plus, I have some absolutely positioned html mixed in with pixi, and IT goes out of whack when I zoom.