-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert Sprite to TypeScript #6375
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good, we just need to confirm a few points
@@ -10,6 +10,8 @@ import { TextureMatrix } from './TextureMatrix'; | |||
|
|||
const DEFAULT_UVS = new TextureUvs(); | |||
|
|||
export type TextureSource = string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement|BaseTexture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use ImageSource
from @pixi/core
here instead of HTMLxxx
stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, we have to test if Sprite.from(resource)
works too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I've updated the type. I've not really written any tests, is that something you can help me with?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont mean to write test, just to check if it works in pixi-playground. I can do it tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, its part of our discussion about texture resource parameters.
packages/sprite/src/Sprite.ts
Outdated
import { BLEND_MODES } from '@pixi/constants'; | ||
import { Container } from '@pixi/display'; | ||
import { Shader, Texture, Filter, Renderer, IBaseTextureOptions, TextureSource } from '@pixi/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hands just want to separate it to real import
and import type
but we cant do that before new TS is released, also our linter doesnt like two import lines from same module
packages/sprite/src/Sprite.ts
Outdated
@@ -271,18 +309,18 @@ export class Sprite extends Container | |||
{ | |||
// if the sprite is trimmed and is not a tilingsprite then we need to add the extra | |||
// space before transforming the sprite coords. | |||
w1 = trim.x - (anchor._x * orig.width); | |||
w1 = trim.x - (anchor.x * orig.width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the problem? @finscn wont be happy that we removed his "optimizations". That's a kind of hotspot and it uses extra property calls. LEts confirm that @GoodBoyDigital is ok with that.
Anchor is always ObservablePoint so maybe we need to make _x
and _y
visible, its not the only place we use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made _x
and _y
internal and reverted these changes
Codecov Report
@@ Coverage Diff @@
## dev #6375 +/- ##
=======================================
Coverage 74.09% 74.09%
=======================================
Files 104 104
Lines 5849 5849
=======================================
Hits 4334 4334
Misses 1515 1515 Continue to review full report at Codecov.
|
Description of change
Converts the sprite package to TypeScript.
The main changes are:
TextureSource
andSpriteSource
types_worldID
inTransform
be publicPre-Merge Checklist
npm run lint
)npm run test
)