The following snippet draws a filled, solid-stroked rectangle in its own PixiJS application. PIXI.Graphics
provides no built-in way to draw dashed strokes.
import {
Component,
OnInit
} from '@angular/core';
import * as PIXI from 'pixi.js';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
ngOnInit(): void {
// Autodetect, create and append the renderer to the body element
let renderer = PIXI.autoDetectRenderer(400, 400, {
backgroundColor: 0xffffff,
antialias: true
});
document.getElementById('demo').appendChild(renderer.view);
// Create the main stage for your display objects
let stage = new PIXI.Container();
// Initialize the pixi Graphics class
let graphics = new PIXI.Graphics();
// Set the fill color
graphics.beginFill(0x222222); // Red
graphics.lineStyle(2, 0xff0000);
// Draw a circle
graphics.drawRoundedRect(240, 150, 100, 100, 10); // drawCircle(x, y, radius)
// Applies fill to lines and shapes since the last call to beginFill.
graphics.endFill();
// Append child to Stage
stage.addChild(graphics);
// Rendering
renderer.render(stage);
}
}