250x250
Rainbow🌈Coder
My dev Note📒
Rainbow🌈Coder
전체 방문자
오늘
어제
  • 분류 전체보기 (411)
    • 공지사항 (0)
    • Debugger (10)
      • Visual Studio Debugger (1)
      • Chrome DevTools (3)
      • Visual Studio Code Debugger (4)
      • eclipse (1)
      • intelliJ (1)
    • OOP (2)
      • OOP (2)
    • TypeScript (54)
      • 타입스크립트 TypeScript (54)
    • Javascript (87)
      • Javascript (45)
      • Node.js (19)
      • React (5)
      • FE 개발환경설정 (3)
      • React와 Node 같이 때려잡기 (6)
      • next.js (2)
      • pixi.js (7)
    • 마크업 (23)
      • Html & Css (23)
    • C# (80)
      • C# (12)
      • 이것이 C#이다 (68)
    • C++ (30)
      • c++ (27)
      • win api (3)
    • Unity (18)
      • Unity(기초) (8)
      • Unity(C#중급) (5)
      • 유니티 포톤(네트워크) (4)
      • unity c# MyCode (1)
    • Java & Spring (29)
      • Java (11)
      • 스프링 (8)
      • Java Algorithm (9)
      • Javs Data Structures (1)
    • 자료구조와 알고리즘 (15)
      • 자료구조 (5)
      • 알고리즘 (10)
    • 형상관리 (15)
      • Git (11)
      • 소스트리 (3)
    • 그래픽스 (7)
      • WebGl (7)
    • AWS (3)
      • aws (3)
    • 리눅스 (5)
      • 리눅스 (5)
    • 책 리뷰 (13)
      • 클린코드(책리뷰) (3)
      • 유지보수가능한코딩의기술C#편(책리뷰) (1)
      • 리팩토링(자바스크립트판) (9)
    • Server (2)
      • 게임 서버(네트워크, 멀티쓰레드,OS) (2)
    • 설계, 아키텍쳐 (4)
    • 파이썬 (5)
    • 디자인패턴 (2)
    • mocha (2)
    • Jest (1)
    • Spine (1)
    • 인공지능 (1)
      • 혼자공부하는머신러닝+딥러닝 (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • ㅣㄷ
  • 위임
  • MySQL
  • 컴포지션

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Rainbow🌈Coder

My dev Note📒

[PIXI] PIXI.Text와 PIXI.TextStyle 사용 방법
Javascript/pixi.js

[PIXI] PIXI.Text와 PIXI.TextStyle 사용 방법

2022. 12. 26. 19:44
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
    'Javascript/pixi.js' 카테고리의 다른 글
    • [PIXI] 이미지를 로드하여 texture -> sprite -> canvas에 add 하는 과정
    • [PIXI] ticker 사용방법
    • [PIXI] Graphic 클래스 활용하여 도형그리기
    • [PIXI] app.view(사실상 캔버스 태그) 속성 살펴보기
    Rainbow🌈Coder
    Rainbow🌈Coder
    몰라도 결국은 아는 개발자, 그런 사람이 되기 위한 매일의 한걸음

    티스토리툴바