Jump to content

Texture from Graphics on v5


ncatdesigner
 Share

Recommended Posts

Hi there!

I'm migrating my engine from v4 to v5, but I am having problems using a graphics object as a texture.

Any ideas?

const graphics = new PIXI.Graphics();

    graphics.lineStyle(
      backgroundStyle.strokeWidth,
      backgroundStyle.strokeColor,
      backgroundStyle.strokeOpacity
    );

    graphics.beginFill(BACKGROUND_COLOR, BACKGROUND_OPACITY);

    graphics.drawRoundedRect(
      ZERO,
      ZERO,
      width,
      height,
      NODE_CORNER_RADIUS
    );

    graphics.endFill();

    const texture = graphics.generateCanvasTexture();

    sprite.texture = texture;

But now I don't know how to get the texture from graphics since I am trying not to use the legacy version for pixi.

Link to comment
Share on other sites

this should work : "const texture = renderer.generateTexture(graphics);"

However if you dont like antialising quality, you should use legacy, dont mind the name, canvas2d is still has no alternative in shapes quality. Its just several tens Kb of code :)

Edited by ivan.popelyshev
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...