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 style = new PIXI.TextStyle({
fontFamily: 'Montserrat',
fontsize: 48,
fill: 'deepskyblue',
stroke: '#ffffff',
strokeThickness: 4,
dropShadow: true,
dropShadowDistance: 10,
dropShadowAngle: Math.PI / 2,
dropShadowBlur: 4,
dropShadowColor: '#000000'
});
const myText = new PIXI.Text('Hello PIXI!', style);
app.stage.addChild(myText);
여기서 직접 텍스트 변경
myText.text = 'Hi PIXI.js!!!';
이렇게 줄바꿈 속성도 추가가능
myText.style.wordWrap = true;
myText.style.wordWrapWidth = true;
전체 코드
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;
const rect = new graphics();
rect.beginFill(0x00ff00)
.lineStyle(4, 0xFFEAA00, 1)
.drawRect(40, 40, 200, 250)//x좌표 y좌표 너비 높이
.endFill()
app.stage.addChild(rect);
const style = new PIXI.TextStyle({
fontFamily: 'Montserrat',
fontsize: 48,
fill: 'deepskyblue',
stroke: '#ffffff',
strokeThickness: 4,
dropShadow: true,
dropShadowDistance: 10,
dropShadowAngle: Math.PI / 2,
dropShadowBlur: 4,
dropShadowColor: '#000000'
});
const myText = new PIXI.Text('Hello PIXI!', style);
app.stage.addChild(myText);
myText.text = 'Hi PIXI.js!!!';
myText.style.wordWrap = true;
myText.style.wordWrapWidth = true;
myText.style.align = 'center';//가로정렬
728x90
'Javascript > pixi.js' 카테고리의 다른 글
[PIXI] 이미지를 로드하여 texture -> sprite -> canvas에 add 하는 과정 (0) | 2022.12.26 |
---|---|
[PIXI] ticker 사용방법 (0) | 2022.12.26 |
[PIXI] Graphic 클래스 활용하여 도형그리기 (0) | 2022.12.26 |
[PIXI] app.view(사실상 캔버스 태그) 속성 살펴보기 (0) | 2022.12.23 |
[Pixi.js] 환경설정과 PIXI 객체 살펴보기 (0) | 2022.12.21 |