728x90
전체 코드
const Application = PIXI.Application;
const app = new Application({
width: window.innerWidth,
height: window.innerHeight,
transparent: false,
antialias: true,
backgroundColor: 0xAAAAAA
});
app.renderer.backgroundColor = 0x23395D;
app.renderer.view.style.position = 'absolute';
document.body.appendChild(app.view);
const graphics = PIXI.Graphics;
app.ticker.add(delta => loop(delta));
function loop(delta) {
const miniRect = new graphics();
miniRect.beginFill(0xFFFFFF)
.drawRect(Math.random() * app.screen.width, Math.random() * app.screen.height, 10, 10)//x좌표 y좌표 너비 높이
.endFill()
app.stage.addChild(miniRect);
}
마치 눈이 오는 것처럼 화면에 랜덤하게 하얀 박스가 뿌려지게 된다!
728x90
'Javascript > pixi.js' 카테고리의 다른 글
[PIXI] 이미지를 로드하여 texture -> sprite -> canvas에 add 하는 과정 (0) | 2022.12.26 |
---|---|
[PIXI] PIXI.Text와 PIXI.TextStyle 사용 방법 (0) | 2022.12.26 |
[PIXI] Graphic 클래스 활용하여 도형그리기 (0) | 2022.12.26 |
[PIXI] app.view(사실상 캔버스 태그) 속성 살펴보기 (0) | 2022.12.23 |
[Pixi.js] 환경설정과 PIXI 객체 살펴보기 (0) | 2022.12.21 |