reacthub-pixitweenjs 0.2.10 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/package.json +4 -1
  2. package/.storybook/main.ts +0 -31
  3. package/.storybook/preview.tsx +0 -26
  4. package/CHANGELOG.md +0 -100
  5. package/build-storybook.log +0 -94
  6. package/index.html +0 -13
  7. package/public/vite.svg +0 -1
  8. package/src/App.css +0 -42
  9. package/src/App.tsx +0 -29
  10. package/src/assets/font/OpenSans-Light-webfont.eot +0 -0
  11. package/src/assets/font/OpenSans-Light-webfont.svg +0 -252
  12. package/src/assets/font/OpenSans-Light-webfont.ttf +0 -0
  13. package/src/assets/font/OpenSans-Light-webfont.woff +0 -0
  14. package/src/assets/font/OpenSans-Regular-webfont.eot +0 -0
  15. package/src/assets/font/OpenSans-Regular-webfont.svg +0 -252
  16. package/src/assets/font/OpenSans-Regular-webfont.ttf +0 -0
  17. package/src/assets/font/OpenSans-Regular-webfont.woff +0 -0
  18. package/src/assets/icon/percolate.eot +0 -0
  19. package/src/assets/icon/percolate.svg +0 -139
  20. package/src/assets/icon/percolate.ttf +0 -0
  21. package/src/assets/icon/percolate.woff +0 -0
  22. package/src/assets/react.svg +0 -1
  23. package/src/components/PixiAnimatedSprite/PixiAnimatedSprite.tsx +0 -51
  24. package/src/components/PixiAnimatedSprite/index.ts +0 -2
  25. package/src/components/PixiAudioSprite/PixiAudioSprite.stories.tsx +0 -61
  26. package/src/components/PixiAudioSprite/PixiAudioSprite.tsx +0 -202
  27. package/src/components/PixiAudioSprite/index.ts +0 -1
  28. package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +0 -172
  29. package/src/components/PixiGifSprite/PixiGifSprite.tsx +0 -420
  30. package/src/components/PixiGifSprite/index.ts +0 -2
  31. package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +0 -220
  32. package/src/components/PixiImageSprite/PixiImageSprite.tsx +0 -60
  33. package/src/components/PixiImageSprite/index.ts +0 -1
  34. package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +0 -174
  35. package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +0 -158
  36. package/src/components/PixiSVGSprite/index.ts +0 -1
  37. package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +0 -228
  38. package/src/components/PixiTextSprite/PixiTextSprite.tsx +0 -361
  39. package/src/components/PixiTextSprite/index.ts +0 -1
  40. package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +0 -186
  41. package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +0 -595
  42. package/src/components/PixiVideoSprite/PixiVideoSpriteBackup.txt +0 -755
  43. package/src/components/PixiVideoSprite/index.ts +0 -1
  44. package/src/components/index.ts +0 -7
  45. package/src/declare.module.ts +0 -5
  46. package/src/hocs/AbstractContainer.tsx +0 -199
  47. package/src/hocs/WithFilterContainer.tsx +0 -159
  48. package/src/index.css +0 -457
  49. package/src/index.ts +0 -3
  50. package/src/main.tsx +0 -11
  51. package/src/providers/GsapPixieContextProvider.tsx +0 -245
  52. package/src/providers/index.ts +0 -1
  53. package/src/reacthub-react-bindings.d.ts +0 -27
  54. package/src/stories/Installation.mdx +0 -40
  55. package/src/stories/Introduction.mdx +0 -140
  56. package/src/stories/assets/code-brackets.svg +0 -1
  57. package/src/stories/assets/colors.svg +0 -1
  58. package/src/stories/assets/comments.svg +0 -1
  59. package/src/stories/assets/direction.svg +0 -1
  60. package/src/stories/assets/flow.svg +0 -1
  61. package/src/stories/assets/plugin.svg +0 -1
  62. package/src/stories/assets/repo.svg +0 -1
  63. package/src/stories/assets/stackalt.svg +0 -1
  64. package/src/types/Animations.tsx +0 -41
  65. package/src/types/BaseProps.tsx +0 -56
  66. package/src/types/BlendModes.tsx +0 -19
  67. package/src/types/Effects.tsx +0 -11
  68. package/src/types/transformation.tsx +0 -13
  69. package/src/utils/AppStateProvider.tsx +0 -59
  70. package/src/utils/AppStateStage.tsx +0 -15
  71. package/src/utils/AppWrapper.tsx +0 -47
  72. package/src/utils/ContextBridge.tsx +0 -25
  73. package/src/utils/GsapAnim.tsx +0 -107
  74. package/src/utils/InteractionManager.tsx +0 -36
  75. package/src/utils/PixiStage.tsx +0 -29
  76. package/src/utils/PixiTransformer.tsx +0 -165
  77. package/src/utils/VideoSeekBar.tsx +0 -122
  78. package/src/utils/useDebounce.tsx +0 -15
  79. package/src/utils/useDeepEffect.tsx +0 -23
  80. package/src/vite-env.d.ts +0 -1
  81. package/tsconfig.json +0 -37
  82. package/tsconfig.node.json +0 -10
  83. package/vite.config.ts +0 -39
  84. package/vitest.config.ts +0 -11
@@ -1,420 +0,0 @@
1
- import * as React from "react";
2
- import { useContext, useEffect, useRef, useState } from "react";
3
- // @ts-ignore
4
- import map from "lodash/map";
5
- // @ts-ignore
6
- import PropTypes from "prop-types";
7
- import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
8
- import { Container, useApp, Graphics, withFilters } from "@pixi/react";
9
- import { AdjustmentFilter } from "@pixi/filter-adjustment";
10
- import * as PIXI from "pixi.js";
11
- import gsap from "gsap";
12
- import { useWorkerParser, usePlayerState } from "@react-gifs/tools";
13
- import PixiTransformer from "../../utils/PixiTransformer";
14
-
15
- // @ts-ignore
16
- import isEmpty from "lodash/isEmpty";
17
- import { getAnimByName } from "../../utils/GsapAnim";
18
- import { TransformationEnd } from "../../types/transformation";
19
- import { PixiAnimatedSprite } from "../PixiAnimatedSprite";
20
-
21
- type PixiGifSpriteProps = {
22
- uniqueId: string;
23
- src: string;
24
- startAt: number;
25
- endAt: number;
26
- initialAlpha: number;
27
- locked: boolean;
28
- loop: boolean;
29
- transformation: {
30
- x: number;
31
- y: number;
32
- width: number;
33
- height: number;
34
- anchor: number;
35
- rotation?: number;
36
- alpha?: number;
37
- scale?: number | [number, number];
38
- tint?: number;
39
- blendMode?: number;
40
- animation?: string;
41
- colorCorrection?: {
42
- enabled?: boolean;
43
- temperature?: number;
44
- hue?: number;
45
- contrast?: number;
46
- saturation?: number;
47
- exposure?: number;
48
- reset?: boolean;
49
- sharpness?: number;
50
- value?: number;
51
- levels?: number;
52
- luminance?: number;
53
- enhance?: number;
54
- blurRadius?: number;
55
- red?: number;
56
- green?: number;
57
- blue?: number;
58
- alpha?: number;
59
- scaleInput?: number;
60
- };
61
- effect?: string;
62
- };
63
- pointerdown?: () => void;
64
- pointerup?: () => void;
65
- mousedown?: () => void;
66
- mouseup?: () => void;
67
- pointerover?: () => void;
68
- mouseover?: () => void;
69
- mouseout?: () => void;
70
- pointerout?: () => void;
71
- applyTransformer?: boolean;
72
- onAnchorTransformationEnd?: (endData: any) => void;
73
- };
74
-
75
- const Filters = withFilters(Container, {
76
- blur: PIXI.filters.BlurFilter,
77
- adjust: AdjustmentFilter,
78
- matrix: PIXI.filters.ColorMatrixFilter,
79
- });
80
-
81
- /** CYAN Filters */
82
- const CYAN = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];
83
-
84
- /**
85
- * PixiGifSprite Component is used to render gif image
86
- * @param props Gif Sprite props
87
- * @returns
88
- */
89
- const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
90
- //// State
91
- const [gifFrame, setGifFrame] = React.useState<PIXI.Texture[]>([]);
92
- const [, setGifDuration] = React.useState<number>(0);
93
- const [gifFrameObject, setGifFrameObject] = React.useState<
94
- PIXI.FrameObject[]
95
- >([]);
96
- const [, setCurrentFrame] = useState<number>(0);
97
- const [, setIsComplete] = useState<boolean>(false);
98
-
99
- const [isDragging, setIsDragging] = useState(false);
100
- const [, setIsMouseOverTransformer] = useState(false);
101
-
102
- const [gifState, update] = usePlayerState({ autoPlay: false });
103
- const graphicRef = React.useRef<PIXI.Graphics>(null);
104
-
105
- //// Refs
106
- const animatedSpriteRef = useRef<PIXI.AnimatedSprite>(null);
107
- const containerRef = useRef<PIXI.Container>(null);
108
- const parentNode = useRef<PIXI.Container>(null);
109
- const imgGroupRef = useRef<PIXI.Container>(null);
110
- const transformerRef = useRef<PIXI.Container>(null);
111
-
112
- //// Context
113
- const { tl, play: tlPlay } = useContext(GsapPixieContext);
114
-
115
- /// 1001
116
- const { frames: gifFrames, delays: gifDelays, loaded } = gifState;
117
-
118
- const {
119
- uniqueId,
120
- src,
121
- startAt,
122
- endAt,
123
- initialAlpha,
124
- locked,
125
- loop,
126
- transformation: {
127
- width = 0,
128
- height = 0,
129
- x,
130
- y,
131
- rotation = 0,
132
- scale,
133
- animation,
134
- colorCorrection,
135
- effect,
136
- },
137
- pointerdown,
138
- pointerup,
139
- mousedown,
140
- mouseup,
141
- pointerover,
142
- mouseover,
143
- mouseout,
144
- pointerout,
145
- applyTransformer,
146
- onAnchorTransformationEnd,
147
- } = props;
148
-
149
- // color corrections
150
- const {
151
- contrast = 1,
152
- saturation = 1,
153
- exposure = 1,
154
- blurRadius = 0,
155
- alpha = 1,
156
- } = colorCorrection || {};
157
-
158
- /** adjustment filter */
159
- const adjustments = {
160
- brightness: exposure,
161
- contrast,
162
- saturation,
163
- alpha,
164
- };
165
-
166
- const app = useApp();
167
-
168
- // load and parse gif
169
- useWorkerParser(src, update);
170
-
171
- // updates current index
172
- // usePlayback(gifState, () => update(({ index }) => ({ index: index + 1 })));
173
-
174
- // transformer to handle sprite transformation
175
- const handleOnTransformEnd = React.useCallback(
176
- (endData: TransformationEnd) => {
177
- console.log("changeEnd", endData);
178
- if (onAnchorTransformationEnd) {
179
- onAnchorTransformationEnd(endData);
180
- }
181
- },
182
- []
183
- );
184
-
185
- React.useEffect(() => {
186
- if (!isEmpty(gifFrames)) {
187
- // app.stage.addChild(frames);
188
- /// load textues
189
- const texturedFrames = map(gifFrames, (eachFrame: ImageData) => {
190
- const { data, width, height } = eachFrame;
191
- const dataEx = new Uint8Array(data);
192
- return PIXI.Texture.fromBuffer(dataEx, width, height);
193
- });
194
-
195
- const frameObj = texturedFrames.map(
196
- (eachFrame: PIXI.Texture, index: number) => {
197
- return {
198
- texture: eachFrame,
199
- time: gifDelays[index],
200
- };
201
- }
202
- );
203
-
204
- setGifFrame(texturedFrames);
205
- setGifFrameObject(frameObj);
206
- let duration = 0;
207
- gifDelays.forEach((delay) => {
208
- duration += delay * 10;
209
- });
210
- setGifDuration(duration);
211
- }
212
- }, [gifFrames, gifDelays]);
213
-
214
- /** Gsap Start and Stop Events */
215
- const gsapOnStart = (startAt: number) => {
216
- if (animatedSpriteRef.current) {
217
- animatedSpriteRef.current.gotoAndPlay(startAt || 0);
218
- }
219
- };
220
-
221
- const gsapOnComplete = () => {
222
- if (animatedSpriteRef.current) {
223
- animatedSpriteRef.current.stop();
224
- // animatedSpriteRef.current.gotoAndStop(0);
225
- }
226
- };
227
-
228
- const onInterrupt = () => {
229
- // console.log('interrupting', refId);
230
- };
231
-
232
- const onUpdate = () => {
233
- // console.log('timeline paused', ctxTimeLine.paused());
234
- // if (animatedSpriteRef.current) {
235
- // animatedSpriteRef.current.play();
236
- // dispatchState({
237
- // play: play,
238
- // });
239
- // }
240
- };
241
-
242
- const handleComplete = () => {
243
- setIsComplete(true);
244
- // if (onComplete) {
245
- // onComplete();
246
- // }
247
- };
248
-
249
- useEffect(() => {
250
- let ctx = gsap.context(() => {});
251
- if (containerRef.current && tl.current) {
252
- const data = {
253
- duration: Number(endAt) - Number(startAt),
254
- onStart: gsapOnStart,
255
- onComplete: gsapOnComplete,
256
- onStartParams: [startAt],
257
- onCompleteParams: [],
258
- onInterrupt: onInterrupt,
259
- onUpdate: onUpdate,
260
- onUpdateParams: [],
261
- };
262
-
263
- const ease = getAnimByName(animation || "None");
264
- ctx = gsap.context(() => {
265
- if (!isEmpty(ease.from)) {
266
- tl.current
267
- .from(containerRef.current, { ...ease.from }, startAt)
268
- .to(imgGroupRef.current, { alpha: 1, duration: 0.2 }, startAt)
269
- .from(imgGroupRef.current, { ...data }, startAt)
270
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
271
- } else if (!isEmpty(ease.to)) {
272
- tl.current
273
- .to(
274
- containerRef.current,
275
- { alpha: 1, duration: 0.2, ...ease.to },
276
- startAt
277
- )
278
- .from(imgGroupRef.current, { ...data }, startAt)
279
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
280
- } else if (!isEmpty(ease.fromTo)) {
281
- tl.current
282
- .fromTo(
283
- containerRef.current,
284
- ease.fromTo?.from,
285
- ease.fromTo?.to,
286
- startAt
287
- )
288
- .from(imgGroupRef.current, { ...data }, startAt)
289
- .to(containerRef.current, { alpha: 0, duration: 0.2 }, endAt - 0.2);
290
- } else {
291
- tl.current
292
- .to(containerRef.current, { alpha: 1, duration: 0.01 }, startAt)
293
- .from(imgGroupRef.current, { ...data }, startAt)
294
- .to(
295
- containerRef.current,
296
- { alpha: 0, duration: 0.1 },
297
- Number(endAt) - Number(0.1)
298
- );
299
- }
300
- });
301
- }
302
- return () => ctx.revert(); // cleanup!
303
- }, [animation, startAt, endAt]);
304
-
305
- /** handle on tranformer onchange */
306
- const handleOnTransformChange = React.useCallback(() => {
307
- setIsDragging(true);
308
- }, []);
309
-
310
- app.ticker.add((delta) => {
311
- if (graphicRef.current) {
312
- graphicRef.current.rotation += 0.01 * delta;
313
- graphicRef.current
314
- .clear()
315
- .lineStyle(4, 0xffffff, 1)
316
- .moveTo(40, 0)
317
- .arc(0, 0, 40, 0, Math.PI * 2 * 0.6, false);
318
- }
319
- });
320
-
321
- const draw = React.useCallback((g: PIXI.Graphics) => {
322
- g.clear();
323
- }, []);
324
-
325
- return (
326
- // @ts-ignore
327
- <Container ref={parentNode}>
328
- {/* @ts-ignore */}
329
- <Container
330
- ref={containerRef}
331
- alpha={initialAlpha}
332
- position={[x, y]}
333
- pivot={[x, y]}
334
- width={width}
335
- height={height}
336
- >
337
- {/* @ts-ignore */}
338
- <Container ref={imgGroupRef}>
339
- {!loaded && (
340
- // @ts-ignore
341
- <Container anchor={0.5} position={[width / 2, height / 2]}>
342
- <Graphics x={x} y={y} ref={graphicRef} draw={draw} />
343
- </Container>
344
- )}
345
- {gifFrame && gifFrame.length > 0 && (
346
- <Filters
347
- scale={1}
348
- blur={{ blur: blurRadius, quality: 4 }}
349
- adjust={adjustments}
350
- apply={({ matrix }: { matrix: any }) => {
351
- if (effect === "BlackAndWhite") {
352
- matrix.desaturate();
353
- } else if (effect === "Sepia") {
354
- matrix.sepia();
355
- } else if (effect === "RetroVintage") {
356
- matrix.negative();
357
- } else if (effect === "NightVision") {
358
- matrix.negative();
359
- } else if (effect === "Normal") {
360
- matrix.reset();
361
- }
362
- }}
363
- matrix={{
364
- enabled: true,
365
- // @ts-ignore
366
- matrix: CYAN,
367
- }}
368
- >
369
- <PixiAnimatedSprite
370
- x={x}
371
- y={y}
372
- width={width}
373
- height={height}
374
- rotation={rotation}
375
- animationSpeed={1}
376
- loop={loop}
377
- isPlaying={!!tlPlay}
378
- // @ts-ignore
379
- textures={gifFrameObject}
380
- onComplete={handleComplete}
381
- onFrameChange={(currentFrame: number) =>
382
- setCurrentFrame(currentFrame)
383
- }
384
- anchor={0.5}
385
- {...(!locked &&
386
- !isDragging && {
387
- interactive: true,
388
- buttonMode: true,
389
- pointerdown: pointerdown,
390
- pointerover: pointerover,
391
- pointerout: pointerout,
392
- pointerup: pointerup,
393
- mousedown: mousedown,
394
- mouseup: mouseup,
395
- mouseover: mouseover,
396
- mouseout: mouseout,
397
- })}
398
- forwardRef={animatedSpriteRef}
399
- scale={scale}
400
- />
401
- </Filters>
402
- )}
403
- </Container>
404
- </Container>
405
- {applyTransformer && (
406
- <PixiTransformer
407
- pixiTransformerRef={transformerRef}
408
- imageRef={containerRef}
409
- isMounted={loaded}
410
- transformCommit={handleOnTransformEnd}
411
- transformChange={handleOnTransformChange}
412
- mouseoverEvent={setIsMouseOverTransformer}
413
- uniqueId={uniqueId}
414
- />
415
- )}
416
- </Container>
417
- );
418
- };
419
-
420
- export default PixiGifSprite;
@@ -1,2 +0,0 @@
1
- export { default as PixiGifSprite } from "./PixiGifSprite";
2
- export * from "./PixiGifSprite";
@@ -1,220 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { PixiImageSprite } from ".";
3
- import { AppStateContextProvider } from "../../utils/AppStateProvider";
4
- import { Effects } from "../../types/Effects";
5
-
6
- // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
7
- const meta = {
8
- title: "Components/ImageSprite",
9
- component: PixiImageSprite,
10
-
11
- tags: ["autodocs"],
12
- argTypes: {
13
- uniqueId: {
14
- control: "text",
15
- description: "uniqueId of the sprite",
16
- },
17
- src: {
18
- control: "text",
19
- description: "source of the image",
20
- },
21
- transformation: {
22
- control: "object",
23
- description: "transformation of the sprite",
24
- x: { control: "number", description: "x position of the sprite" },
25
- y: { control: "number", description: "y position of the sprite" },
26
- width: { control: "number", description: "width of the sprite" },
27
- height: { control: "number", description: "height of the sprite" },
28
- anchor: { control: "number", description: "anchor of the sprite" },
29
- rotation: { control: "number", description: "rotation of the sprite" },
30
- alpha: {
31
- control: "number",
32
- min: 0,
33
- max: 1,
34
- description: "alpha of the sprite",
35
- },
36
- scale: { control: "number", description: "scale of the sprite" },
37
- tint: { control: "number", description: "tint of the sprite" },
38
- blendMode: { control: "number", description: "blendMode of the sprite" },
39
- effects: {
40
- type: "string",
41
- options: Object.values(Effects),
42
- description: "filter effects of the sprite",
43
- },
44
- colorCorrection: {
45
- control: "object",
46
- description: "colorCorrection of the sprite",
47
- enabled: {
48
- control: "boolean",
49
- description: "enabled of the sprite with color filter mode applied.",
50
- },
51
- brightness: {
52
- control: "number",
53
- description: "brightness of the sprite",
54
- },
55
- contrast: { control: "number", description: "contrast of the sprite" },
56
- saturation: {
57
- control: "number",
58
- description: "saturation of the sprite",
59
- },
60
- alpha: { control: "number", description: "alpha of the sprite" },
61
- },
62
- },
63
- applyTransformer: { control: "boolean", description: "applyTransformer" },
64
- startAt: { control: "number", description: "startAt" },
65
- endAt: { control: "number", description: "endAt" },
66
- initialAlpha: {
67
- control: "number",
68
- min: 0,
69
- max: 1,
70
- description: "sprite initial alpha value (default 1)",
71
- },
72
- onAnchorTransformationEnd: {
73
- action: "onAnchorTransformationEnd",
74
- description:
75
- "on transforamtion end the event is fire callback with latest sprite transformation properties.",
76
- },
77
- pointerdown: {
78
- action: "pointerdown",
79
- description: "pointerdown event",
80
- },
81
- },
82
- } satisfies Meta<typeof PixiImageSprite>;
83
-
84
- export default meta;
85
- type Story = StoryObj<typeof meta>;
86
-
87
- // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
88
- export const Normal: Story = {
89
- render: (args: any) => (
90
- <AppStateContextProvider {...args}>
91
- <PixiImageSprite {...args} />
92
- </AppStateContextProvider>
93
- ),
94
- args: {
95
- uniqueId: "surya001", // uniqueId of the sprite
96
- src: "https://assets.codepen.io/693612/surya.svg",
97
- applyTransformer: false,
98
- startAt: 0,
99
- endAt: 10,
100
- transformation: {
101
- x: 200,
102
- y: 200,
103
- width: 150,
104
- height: 150,
105
- anchor: 0.5,
106
- rotation: 0,
107
- alpha: 1,
108
- scale: 1,
109
- tint: 0xffffff,
110
- blendMode: 0,
111
- effect: Effects.None,
112
- colorCorrection: {
113
- enabled: false,
114
- contrast: 1,
115
- saturation: 1,
116
- exposure: 1,
117
- blurRadius: 0,
118
- },
119
- },
120
- initialAlpha: 1,
121
- },
122
- };
123
-
124
- export const FadeIn: Story = {
125
- render: (args: any) => (
126
- <AppStateContextProvider {...args}>
127
- <PixiImageSprite {...args} />
128
- </AppStateContextProvider>
129
- ),
130
- args: {
131
- uniqueId: "surya002", // uniqueId of the sprite
132
- src: "https://assets.codepen.io/693612/surya.svg",
133
- applyTransformer: false,
134
- startAt: 0,
135
- endAt: 10,
136
- transformation: {
137
- x: 100,
138
- y: 100,
139
- width: 150,
140
- height: 150,
141
- anchor: 0.5,
142
- rotation: 0,
143
- alpha: 1,
144
- scale: 1,
145
- tint: 0xffffff,
146
- blendMode: 0,
147
- effect: Effects.None,
148
- animation: "FADE_IN",
149
- colorCorrection: {},
150
- },
151
- initialAlpha: 0,
152
- },
153
- };
154
-
155
- // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
156
- export const Filters: Story = {
157
- render: (args: any) => (
158
- <AppStateContextProvider {...args}>
159
- <PixiImageSprite {...args} />
160
- </AppStateContextProvider>
161
- ),
162
- args: {
163
- uniqueId: "image-filters001", // uniqueId of the sprite
164
- src: "https://assets.codepen.io/693612/surya.svg",
165
- applyTransformer: false,
166
- startAt: 0,
167
- endAt: 10,
168
- transformation: {
169
- x: 200,
170
- y: 200,
171
- width: 150,
172
- height: 150,
173
- anchor: 0.5,
174
- rotation: 0,
175
- alpha: 1,
176
- scale: 1,
177
- tint: 0xffffff,
178
- blendMode: 0,
179
- effect: Effects.None,
180
- colorCorrection: {
181
- enabled: true,
182
- contrast: 1,
183
- saturation: 2,
184
- exposure: 1,
185
- blurRadius: 0,
186
- },
187
- },
188
- initialAlpha: 1,
189
- },
190
- };
191
-
192
- // More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
193
- export const FilterEffects: Story = {
194
- render: (args: any) => (
195
- <AppStateContextProvider {...args}>
196
- <PixiImageSprite {...args} />
197
- </AppStateContextProvider>
198
- ),
199
- args: {
200
- uniqueId: "image-filtereffects001", // uniqueId of the sprite
201
- src: "https://assets.codepen.io/693612/surya.svg",
202
- applyTransformer: false,
203
- startAt: 0,
204
- endAt: 10,
205
- transformation: {
206
- x: 200,
207
- y: 200,
208
- width: 150,
209
- height: 150,
210
- anchor: 0.5,
211
- rotation: 0,
212
- alpha: 1,
213
- scale: 1,
214
- tint: 0xffffff,
215
- blendMode: 0,
216
- effect: Effects.BlackAndWhite,
217
- },
218
- initialAlpha: 1,
219
- },
220
- };
@@ -1,60 +0,0 @@
1
- import * as React from "react";
2
- import { useRef } from "react";
3
- import { Sprite, Container } from "@pixi/react";
4
- import * as PIXI from "pixi.js";
5
- // @ts-ignore
6
- import isEmpty from "lodash/isEmpty";
7
- // setup hocs
8
- import AbstractContainer from "../../hocs/AbstractContainer";
9
- import { PixiBaseSpriteProps } from "../../types/BaseProps";
10
-
11
- const PixiImageSprite: React.FC<PixiBaseSpriteProps> = (props) => {
12
- //// State
13
-
14
- //// Refs
15
- const imageRef = useRef<PIXI.Sprite>(null);
16
- const imgGroupRef = useRef<PIXI.Container>(null);
17
-
18
- //// Context
19
-
20
- /// 1001
21
- // console.log("contxt Values", tl);
22
- const {
23
- src,
24
- transformation: { x, y, width, height, anchor },
25
- pointerdown,
26
- pointerup,
27
- mousedown,
28
- mouseup,
29
- pointerover,
30
- mouseover,
31
- mouseout,
32
- } = props;
33
-
34
- return (
35
- <AbstractContainer {...props}>
36
- <Container ref={imgGroupRef}>
37
- <Sprite
38
- image={src}
39
- width={width}
40
- height={height}
41
- anchor={anchor}
42
- ref={imageRef}
43
- x={x}
44
- y={y}
45
- // @ts-ignore
46
- interactive={true}
47
- pointerdown={pointerdown}
48
- pointerup={pointerup}
49
- pointerover={pointerover}
50
- mousedown={mousedown}
51
- mouseup={mouseup}
52
- mouseover={mouseover}
53
- mouseout={mouseout}
54
- />
55
- </Container>
56
- </AbstractContainer>
57
- );
58
- };
59
-
60
- export default PixiImageSprite;
@@ -1 +0,0 @@
1
- export { default as PixiImageSprite } from "./PixiImageSprite";