Container
A Container is the base component for all components that render to the screen. It can be used on its own, but components such as Sprite or Graphics will be composed of Containers (and will provide context for getContainer)
When child components are rendered inside, their coordinates become local to the parent Container.
Usage
<script>
import { Container, Text } from 'svelte-pixi'
</script>
<Container>
<Text text="Hello" x={-10} y={-60} style={{ fill: 'white' }} />
<Text text="World" x={-10} y={0} style={{ fill: 'white' }} />
</Container>API
Props
| Name | Description |
|---|---|
accessible false | booleanFlag for if the object is accessible. If true AccessibilityManager will overlay a shadow div with attributes set |
accessibleChildren true | booleanSetting to false will prevent any children inside this container to be accessible. |
accessibleHint | stringSets the aria-label attribute of the shadow div |
accessiblePointerEvents 'auto' | stringSpecify the pointer-events the accessible div will use Defaults to auto. |
accessibleTitle | stringSets the title attribute of the shadow div If accessibleTitle AND accessibleHint has not been this will default to 'displayObject [tabIndex]' |
accessibleType 'button' | stringSpecify the type of div the accessible layer is. Screen readers treat the element differently depending on this type. |
alpha | numberThe opacity of the object. |
angle | numberThe angle of the object in degrees. 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees. |
cacheAsBitmap | booleanSet this to true if you want this display object to be cached as a bitmap. This basically takes a snap shot of the display object as it is at that moment. It can provide a performance benefit for complex static displayObjects. To remove simply set this property to false IMPORTANT GOTCHA - Make sure that all your textures are preloaded BEFORE setting this property to true as it will take a snapshot of what is currently there. If the textures have not loaded then they will not appear. |
cacheAsBitmapMultisample | PIXI.MSAA_QUALITYThe number of samples to use for cacheAsBitmap. If set to null, the renderer's sample count is used. If cacheAsBitmap is set to true, this will re-render with the new number of samples. |
cacheAsBitmapResolution | numberThe resolution to use for cacheAsBitmap. By default this will use the renderer's resolution but can be overriden for performance. Lower values will reduce memory usage at the expense of render quality. A falsey value of null or 0 will default to the renderer's resolution. If cacheAsBitmap is set to true, this will re-render with the new resolution. |
cullable | booleanShould this object be rendered if the bounds of this object are out of frame? Culling has no effect on whether updateTransform is called. |
cullArea | PIXI.RectangleIf set, this shape is used for culling instead of the bounds of this object. It can improve the culling performance of objects with many children. The culling area is defined in local space. |
cursor | stringThis defines what cursor mode is used when the mouse cursor is hovered over the displayObject. |
eventMode | PIXI.EventModeThe type of interaction a DisplayObject can be. For more information on values and their meaning, see https://pixijs.download/dev/docs/PIXI.DisplayObject.html#eventMode |
filterArea | PIXI.RectangleThe area the filter is applied to. This is used as more of an optimization rather than figuring out the dimensions of the displayObject each frame you can set this rectangle. Also works as an interaction mask. |
filters | PIXI.Filter[]nullSets the filters for the displayObject. IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer. To remove filters simply set this property to 'null'. |
height | numberThe height of the Container, setting this will actually modify the scale to achieve the value set. |
hitArea | PIXI.IHitAreaInteraction shape. Children will be hit first, then this shape will be checked. Setting this will cause this shape to be checked in hit tests rather than the displayObject's bounds. |
instance | PIXI.ContainerThe PIXI.Container instance. Can be set or bound to. |
interactive | Enable interaction events for the DisplayObject. Touch, pointer and mouse events will not be emitted unless interactive is set to true. @deprecated since 7.0.0, Setting interactive is deprecated, use eventMode='none'/'passive'/'auto'/'static'/'dynamic' instead. |
interactiveChildren | Determines if the children to the displayObject can be clicked/touched. Setting this to false allows PixiJS to bypass a recursive hitTest function @deprecated since 7.0.0, Setting interactive is deprecated, use eventMode='none'/'passive'/'auto'/'static'/'dynamic' instead. |
isMask | booleanDoes any other displayObject use this object as a mask? |
isSprite | booleanUsed to fast check if a sprite is.. a sprite! |
mask | PIXI.ContainerPIXI.MaskDatanullSets a mask for the displayObject. A mask is an object that limits the visibility of an object to the shape of the mask applied to it. In PixiJS a regular mask must be a PIXI.Graphics or a PIXI.Sprite object. This allows for much faster masking in canvas as it utilities shape clipping. To remove a mask, set this property to null. For sprite mask both alpha and red channel are used. Black mask is the same as transparent mask. At the moment, PIXI.CanvasRenderer doesn't support PIXI.Sprite as mask. |
name | stringThe instance name of the object. |
pivot | PointLikeThe center of rotation, scaling, and skewing for this display object in its local space. The position is the projection of pivot in the parent's local space. By default, the pivot is the origin (0, 0). |
position | PointLikeThe coordinate of the object relative to the local coordinates of the parent. |
renderable | booleanCan this object be rendered, if false the object will not be drawn but the updateTransform methods will still be called. Only affects recursive calls from parent. You can ask for bounds manually |
rotation | numberThe rotation of the object in radians. 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees. |
scale | PointLikeThe scale factors of this object along the local coordinate axes. The default scale is (1, 1). |
skew | PointLikeThe skew factor for the object in radians. |
sortableChildren | booleanIf set to true, the container will sort its children by zIndex value when updateTransform() is called, or manually if sortChildren() is called. This actually changes the order of elements in the array, so should be treated as a basic solution that is not performant compared to other solutions, such as @link https://github.com/pixijs/pixi-display Also be aware of that this may not work nicely with the addChildAt() function, as the zIndex sorting may cause the child to automatically sorted to another position. |
transform | PIXI.TransformWorld transform and local transform of this object. This will become read-only later, please do not assign anything there unless you know what are you doing. |
visible | booleanThe visibility of the object. If false the object will not be drawn, and the updateTransform function will not be called. Only affects recursive calls from parent. You can ask for bounds or call updateTransform manually. |
width | numberThe width of the Container, setting this will actually modify the scale to achieve the value set. |
x | numberThe position of the displayObject on the x axis relative to the local coordinates of the parent. An alias to position.x |
y | numberThe position of the displayObject on the y axis relative to the local coordinates of the parent. An alias to position.y |
zIndex | numberThe zIndex of the displayObject. If a container has the sortableChildren property set to true, children will be automatically sorted by zIndex value; a higher value will mean it will be moved towards the end of the array, and thus rendered on top of other display objects within the same container. |
Slots
| Name | Props | Fallback |
|---|---|---|
| default | {} |
Events
| Name | Type | Detail |
|---|---|---|
| added | dispatched | |
| create | dispatched | |
| removed | dispatched |