Jump to content

Draw dashed rectangle with PixiJS


p.vk
 Share

Recommended Posts

Is it possible to draw a rectangle with a dashed line?

My code looks like:

import {Application, Graphics} from 'pixi.js';

(async () => {
    const app = new Application();
    await app.init({width: 300, height: 300});
    document.body.appendChild(app.canvas);
    
    const c = 'white';
    const x = 0;
    const y = 0;
    const w = 100;
    const h = 100;

    const graphics = new Graphics();
    graphics.rect(x, y, w, h);
    graphics.fill(c);
    graphics.stroke({ width: 1, color: 217854 });

    app.stage.addChild(graphics);    
})();

And it draws next scene:

 

scene.png

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...