47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
let app = new PIXI.Application({ width: 400, height: 400, backgroundColor: 0x339955 });
|
||
document.body.appendChild(app.view);
|
||
|
||
const basicText = new PIXI.Text('Просто обычный текст');
|
||
basicText.anchor.set(0.5);
|
||
basicText.x = app.screen.width / 2;
|
||
basicText.y = 60;
|
||
|
||
const style = new PIXI.TextStyle({
|
||
fontFamily: 'serif',
|
||
fontSize: 36,
|
||
fontStyle: 'italic',
|
||
fontWeight: 'bold',
|
||
fill: ['#ffffff', '#00ff99'], // gradient
|
||
stroke: '#4a1850',
|
||
strokeThickness: 5,
|
||
dropShadow: true,
|
||
dropShadowColor: '#000000',
|
||
dropShadowBlur: 4,
|
||
dropShadowAngle: Math.PI / 6,
|
||
dropShadowDistance: 6,
|
||
wordWrap: true,
|
||
wordWrapWidth: 400,
|
||
lineJoin: 'round',
|
||
});
|
||
|
||
const richText = new PIXI.Text('Текст со всякими стилями', style);
|
||
richText.anchor.set(0.5, 0);
|
||
richText.x = app.screen.width / 2;
|
||
richText.y = 100;
|
||
|
||
const basicTextCounter = new PIXI.Text('0');
|
||
basicTextCounter.style.fontSize = 50;
|
||
basicTextCounter.anchor.set(0.5);
|
||
basicTextCounter.x = app.screen.width / 2;
|
||
basicTextCounter.y = 275;
|
||
|
||
basicTextCounter.interactive = true;
|
||
basicTextCounter.cursor = 'pointer';
|
||
basicTextCounter.on('click', (event) => {
|
||
basicTextCounter.text = parseInt(basicTextCounter.text) + 1;
|
||
});
|
||
|
||
app.stage.addChild(basicText);
|
||
app.stage.addChild(richText);
|
||
app.stage.addChild(basicTextCounter);
|