Jump to content

Pixi coordinate system


vadim
 Share

Recommended Posts

Hi,

I have started to work with pixi

I tried to draw a simple rectangle as a canvas border

If I use point (0,0) for it, my rectangle doesn't have two sides

rect.PNG.4ab3cbd27cdf2972222d274d4ab5d05

I have correct rectangle only in case of graphics.drawRect(0, 1, 99, 99)

Is this a bug or feature? What is the real starting point and size of the working area in pixi?

Code:

var renderer = PIXI.autoDetectRenderer(100, 100, { backgroundColor: 0xeeeeee, antialias: false });

document.body.appendChild(renderer.view);

var stage = new PIXI.Container();
var graphics = new PIXI.Graphics();
stage.addChild(graphics);

graphics.lineStyle(1, 0x000000, 1);
graphics.drawRect(0, 0, 100, 100);
renderer.render(stage);

Link to comment
Share on other sites

Try use (0.5, 0.5, 99.5, 99.5)

That's how canvas context2d works too.

The thing is, you must specify the middle of the line, and if line has width 1 , you have to specify x + 0.5 . If you specify just x, your line will have width 2 width alpha 0.5, but pixi doesnt  do antialiasign so we have that strange result.

If you consider that pixel (0,0) is actually rectangle (0,0)-(1,1) you'll understand that logic :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...