-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
117a22b
commit 3756ff3
Showing
5 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte-pixi': patch | ||
--- | ||
|
||
support HTMLText component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: HTMLText | ||
pixi: https://pixijs.download/release/docs/HTMLText.html | ||
sidebar: | ||
badge: 'New' | ||
--- | ||
|
||
Renders text with support for styling via HTML tags. The rendering can vary across browsers and platforms. | ||
|
||
## Usage | ||
|
||
```svelte live | ||
<script> | ||
import { HTMLText } from 'svelte-pixi' | ||
</script> | ||
<HTMLText | ||
text="<strong>Hello</strong> <em>World</em>" | ||
anchor={0.5} | ||
style={{ | ||
fill: 'white' | ||
}} | ||
/> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<script lang="ts"> | ||
/** | ||
* @restProps {Container} | ||
*/ | ||
import * as PIXI from 'pixi.js' | ||
import { createApplyProps } from './util/props' | ||
import Container from './Container.svelte' | ||
import { afterUpdate } from 'svelte' | ||
import { getRenderer } from './Renderer.svelte' | ||
import type { PointLike } from './util/data-types' | ||
type T = $$Generic<PIXI.HTMLText> | ||
type $$Props = Container<T>['$$prop_def'] & { | ||
text: PIXI.HTMLText['text'] | ||
style?: PIXI.IHTMLTextStyle | ||
anchor?: PointLike | ||
blendMode?: PIXI.Sprite['blendMode'] | ||
pluginName?: PIXI.Sprite['pluginName'] | ||
roundPixels?: PIXI.Sprite['roundPixels'] | ||
} | ||
/** | ||
* The text to display | ||
* | ||
* @type {string} | ||
*/ | ||
export let text: $$Props['text'] | ||
/** | ||
* Sets the style of the text | ||
* | ||
* @type {PIXI.HTMLTextStyle} | ||
*/ | ||
export let style: $$Props['style'] = undefined | ||
/** | ||
* The anchor sets the origin point of the text. | ||
* | ||
* @type {PointLike} | ||
*/ | ||
export let anchor: $$Props['anchor'] = undefined | ||
/** | ||
* The blend mode to be applied to the sprite. | ||
* Apply a value of PIXI.BLEND_MODES.NORMAL to reset the blend mode. | ||
*/ | ||
export let blendMode: $$Props['blendMode'] = PIXI.BLEND_MODES.NORMAL | ||
/** | ||
* Plugin that is responsible for rendering this element. | ||
* | ||
* @type {string} | ||
*/ | ||
export let pluginName: $$Props['pluginName'] = undefined | ||
/** | ||
* If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. | ||
* Advantages can include sharper image quality (like text) and faster rendering on canvas. | ||
* The main disadvantage is movement of objects may appear less smooth. | ||
* | ||
* @type {boolean} | ||
*/ | ||
export let roundPixels: $$Props['roundPixels'] = undefined | ||
/** | ||
* The PIXI.Text instance. Can be set or bound to. | ||
* | ||
* @type {PIXI.HTMLText} | ||
*/ | ||
export let instance: T = new PIXI.HTMLText(text, style as any) as T | ||
const { invalidate } = getRenderer() | ||
const { applyProp } = createApplyProps<PIXI.HTMLText>(instance) | ||
afterUpdate(() => { | ||
invalidate() | ||
}) | ||
$: applyProp('text', text) | ||
$: applyProp('style', style) | ||
$: applyProp('anchor', anchor) | ||
$: applyProp('blendMode', blendMode) | ||
$: applyProp('pluginName', pluginName) | ||
$: applyProp('roundPixels', roundPixels) | ||
</script> | ||
|
||
<Container | ||
{...$$restProps} | ||
{instance} | ||
on:create | ||
on:click | ||
on:globalmousemove | ||
on:globalpointermove | ||
on:globaltouchmove | ||
on:mousedown | ||
on:mousemove | ||
on:mouseout | ||
on:mouseover | ||
on:mouseup | ||
on:mouseupoutside | ||
on:mouseupoutside | ||
on:pointercancel | ||
on:pointerdown | ||
on:pointermove | ||
on:pointerout | ||
on:pointerover | ||
on:pointertap | ||
on:pointerup | ||
on:pointerupoutside | ||
on:removedFrom | ||
on:rightclick | ||
on:rightdown | ||
on:rightup | ||
on:rightupoutside | ||
on:tap | ||
on:touchcancel | ||
on:touchend | ||
on:touchendoutside | ||
on:touchmove | ||
on:touchstart | ||
on:added | ||
on:removed | ||
> | ||
<slot /> | ||
</Container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters