1 line
25 KiB
Plaintext
1 line
25 KiB
Plaintext
|
|
{"version":3,"file":"Sprite.mjs","sources":["../src/Sprite.ts"],"sourcesContent":["import { BLEND_MODES, Color, ObservablePoint, Point, Rectangle, settings, Texture, utils } from '@pixi/core';\nimport { Bounds, Container } from '@pixi/display';\n\nimport type { ColorSource, IBaseTextureOptions, IPointData, Renderer, TextureSource } from '@pixi/core';\nimport type { IDestroyOptions } from '@pixi/display';\n\nconst tempPoint = new Point();\nconst indices = new Uint16Array([0, 1, 2, 0, 2, 3]);\n\nexport type SpriteSource = TextureSource | Texture;\n\nexport interface Sprite extends GlobalMixins.Sprite, Container {}\n\n/**\n * The Sprite object is the base for all textured objects that are rendered to the screen\n *\n * A sprite can be created directly from an image like this:\n *\n * ```js\n * import { Sprite } from 'pixi.js';\n *\n * const sprite = Sprite.from('assets/image.png');\n * ```\n *\n * The more efficient way to create sprites is using a {@link PIXI.Spritesheet},\n * as swapping base textures when rendering to the screen is inefficient.\n *\n * ```js\n * import { Assets, Sprite } from 'pixi.js';\n *\n * const sheet = await Assets.load('assets/spritesheet.json');\n * const sprite = new Sprite(sheet.textures['image.png']);\n * ```\n * @memberof PIXI\n */\nexport class Sprite extends Container\n{\n /**\n * The blend mode to be applied to the sprite. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.\n * @default PIXI.BLEND_MODES.NORMAL\n */\n public blendMode: BLEND_MODES;\n public indices: Uint16Array;\n\n /**\n * Plugin that is responsible for rendering this element.\n * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods.\n * @default 'batch'\n */\n public pluginName: string;\n\n /**\n * The width of the sprite (this is initially set by the texture).\n * @protected\n */\n _width: number;\n\n /**\n * The height of the sprite (this is initially set by the texture)\n * @protected\n */\n _height: number;\n\n /**\n * The texture that the sprite is using.\n * @private\n */\n _texture: Texture;\n _textureID: number;\n\n /**\n * Cached tint value so we can tell when the tint is changed.\n * Value is used for 2d CanvasRenderer.\n * @protected\n * @default 0xFFFFFF\n */\n _cachedTint: number;\n protected _textureTrimmedID: number;\n\n /**\n * This is used to store the uvs data of the sprite, assigned at the same time\n * as the vertexData in calculateVertices().\n * @member {Float32Array}\n */\n protected uvs: Float32Array;\n\n /**\n * The anchor point defines the normalized coordinates\n * in the texture that map to the position of this\n * sprite.\n *\n * By default, this is `(0,0)` (or `texture.defaultAnchor`\n * if you have modified that), which means the position\n * `(x,y)` of this `Sprite` will be the top-left corner.\n *\n * Note: Updating `texture.defaultAnchor` after\n * constructing a `Sprite` does _not_ update its anchor.\n *\n * {@link https://docs.cocos2d-x.org/cocos2d-x/en/sprites/manipulation.html}\n * @default `this.texture.defaultAnchor`\n */\n protected _anchor: ObservablePoint;\n\n /**\n * This is used to store the vertex data of the sprite (basically a quad).\n * @member {Float32Array}\n */\n protected vertexData: Float32Array;\n\n /**\n * This is used to calculate the bounds of the object IF it is a trimmed sprite.\n * @member {Float32Array}\n */\n private vertexTrimmedData: Float32Array;\n\n /**\n * Internal roundPixels field\n * @private\n */\n private _roundPixels: boolean;\n private _transformID: number;\n private _transformTrimmedID: number;\n\n /**\n * The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.\n * @default 0xFFFFFF\n */\n private _tintColor: Color;\n\n // Internal-only properties\n /
|