reacthub-pixitweenjs 0.2.6 → 0.2.8
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.
- package/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/src/components/PixiGifSprite/PixiGifSprite.stories.tsx +41 -4
- package/src/components/PixiGifSprite/PixiGifSprite.tsx +85 -37
- package/src/components/PixiImageSprite/PixiImageSprite.stories.tsx +92 -7
- package/src/components/PixiImageSprite/PixiImageSprite.tsx +27 -276
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.stories.tsx +49 -12
- package/src/components/PixiSVGSprite/PixiSvgPathSprite.tsx +32 -220
- package/src/components/PixiTextSprite/PixiTextSprite.stories.tsx +60 -8
- package/src/components/PixiTextSprite/PixiTextSprite.tsx +44 -223
- package/src/components/PixiVideoSprite/PixiVideoSprite.stories.tsx +39 -0
- package/src/components/PixiVideoSprite/PixiVideoSprite.tsx +595 -631
- package/src/components/index.ts +7 -0
- package/src/hocs/AbstractContainer.tsx +199 -0
- package/src/hocs/WithFilterContainer.tsx +159 -0
- package/src/index.ts +1 -1
- package/src/types/Animations.tsx +41 -0
- package/src/types/BaseProps.tsx +56 -0
- package/src/types/BlendModes.tsx +19 -0
- package/src/types/Effects.tsx +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.2.8](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.7...v0.2.8) (2023-08-27)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* exported all pixi elements ([cec8ce1](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/cec8ce10588432fd775b6cd3cbb22118b034c4ca))
|
|
11
|
+
|
|
12
|
+
### [0.2.7](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.6...v0.2.7) (2023-08-27)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* reupdated the filters and hoc wrappers ([0083847](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/00838477793b342453341f1dbd3e418c66f02619))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* filters applied on all video and other elements ([19100d0](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/19100d0f16d7f7be4ad0f4622a1b9f67765b3134))
|
|
23
|
+
* pixi fixed colorization component ([8ca4c32](https://github.com/khanzzirfan/reacthub-pixitweenjs/commit/8ca4c326514eb6c677c1460323afe92c34c25060))
|
|
24
|
+
|
|
5
25
|
### [0.2.6](https://github.com/khanzzirfan/reacthub-pixitweenjs/compare/v0.2.5...v0.2.6) (2023-08-25)
|
|
6
26
|
|
|
7
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reacthub-pixitweenjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "reacthub-pixitweenjs is a library that provides a powerful combination of React, PixiJS, GSAP, and image manipulation capabilities in a timeline sequence. With this library, you can easily create stunning animations and interactive graphics for your React applications",
|
|
5
5
|
"author": "khanzzirfan",
|
|
6
6
|
"type": "module",
|
|
@@ -114,11 +114,14 @@ export const Normal: Story = {
|
|
|
114
114
|
src: "https://media.giphy.com/media/5VKbvrjxpVJCM/giphy.gif",
|
|
115
115
|
locked: false,
|
|
116
116
|
loop: false,
|
|
117
|
+
applyTransformer: false,
|
|
118
|
+
startAt: 0,
|
|
119
|
+
endAt: 4,
|
|
117
120
|
transformation: {
|
|
118
|
-
x:
|
|
119
|
-
y:
|
|
120
|
-
width:
|
|
121
|
-
height:
|
|
121
|
+
x: 200,
|
|
122
|
+
y: 200,
|
|
123
|
+
width: 200,
|
|
124
|
+
height: 200,
|
|
122
125
|
anchor: 0.5,
|
|
123
126
|
rotation: 0,
|
|
124
127
|
alpha: 1,
|
|
@@ -127,9 +130,43 @@ export const Normal: Story = {
|
|
|
127
130
|
blendMode: 0,
|
|
128
131
|
colorCorrection: {},
|
|
129
132
|
},
|
|
133
|
+
initialAlpha: 1,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const Filters: Story = {
|
|
138
|
+
render: (args: any) => (
|
|
139
|
+
<AppStateContextProvider {...args}>
|
|
140
|
+
<PixiGifSprite {...args} />
|
|
141
|
+
</AppStateContextProvider>
|
|
142
|
+
),
|
|
143
|
+
args: {
|
|
144
|
+
uniqueId: "suryaGify001", // uniqueId of the sprite
|
|
145
|
+
src: "https://media.giphy.com/media/5VKbvrjxpVJCM/giphy.gif",
|
|
146
|
+
locked: false,
|
|
147
|
+
loop: false,
|
|
130
148
|
applyTransformer: false,
|
|
131
149
|
startAt: 0,
|
|
132
150
|
endAt: 4,
|
|
151
|
+
transformation: {
|
|
152
|
+
x: 200,
|
|
153
|
+
y: 200,
|
|
154
|
+
width: 200,
|
|
155
|
+
height: 200,
|
|
156
|
+
anchor: 0.5,
|
|
157
|
+
rotation: 0,
|
|
158
|
+
alpha: 1,
|
|
159
|
+
scale: 1,
|
|
160
|
+
tint: 0xffffff,
|
|
161
|
+
blendMode: 0,
|
|
162
|
+
colorCorrection: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
contrast: 2,
|
|
165
|
+
saturation: 2,
|
|
166
|
+
exposure: 2,
|
|
167
|
+
blurRadius: 1,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
133
170
|
initialAlpha: 1,
|
|
134
171
|
},
|
|
135
172
|
};
|
|
@@ -5,7 +5,8 @@ import map from "lodash/map";
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import { GsapPixieContext } from "../../providers/GsapPixieContextProvider";
|
|
8
|
-
import { Container, useApp, Graphics } from "@pixi/react";
|
|
8
|
+
import { Container, useApp, Graphics, withFilters } from "@pixi/react";
|
|
9
|
+
import { AdjustmentFilter } from "@pixi/filter-adjustment";
|
|
9
10
|
import * as PIXI from "pixi.js";
|
|
10
11
|
import gsap from "gsap";
|
|
11
12
|
import { useWorkerParser, usePlayerState } from "@react-gifs/tools";
|
|
@@ -71,6 +72,15 @@ type PixiGifSpriteProps = {
|
|
|
71
72
|
onAnchorTransformationEnd?: (endData: any) => void;
|
|
72
73
|
};
|
|
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
|
+
|
|
74
84
|
/**
|
|
75
85
|
* PixiGifSprite Component is used to render gif image
|
|
76
86
|
* @param props Gif Sprite props
|
|
@@ -79,7 +89,7 @@ type PixiGifSpriteProps = {
|
|
|
79
89
|
const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
80
90
|
//// State
|
|
81
91
|
const [gifFrame, setGifFrame] = React.useState<PIXI.Texture[]>([]);
|
|
82
|
-
const [
|
|
92
|
+
const [, setGifDuration] = React.useState<number>(0);
|
|
83
93
|
const [gifFrameObject, setGifFrameObject] = React.useState<
|
|
84
94
|
PIXI.FrameObject[]
|
|
85
95
|
>([]);
|
|
@@ -92,7 +102,6 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
92
102
|
const [gifState, update] = usePlayerState({ autoPlay: false });
|
|
93
103
|
const graphicRef = React.useRef<PIXI.Graphics>(null);
|
|
94
104
|
|
|
95
|
-
console.log("allProps", props);
|
|
96
105
|
//// Refs
|
|
97
106
|
const animatedSpriteRef = useRef<PIXI.AnimatedSprite>(null);
|
|
98
107
|
const containerRef = useRef<PIXI.Container>(null);
|
|
@@ -104,8 +113,6 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
104
113
|
const { tl, play: tlPlay } = useContext(GsapPixieContext);
|
|
105
114
|
|
|
106
115
|
/// 1001
|
|
107
|
-
console.log("contxt Values", tl);
|
|
108
|
-
console.log("gifState", gifState, gifDuration);
|
|
109
116
|
const { frames: gifFrames, delays: gifDelays, loaded } = gifState;
|
|
110
117
|
|
|
111
118
|
const {
|
|
@@ -124,6 +131,8 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
124
131
|
rotation = 0,
|
|
125
132
|
scale,
|
|
126
133
|
animation,
|
|
134
|
+
colorCorrection,
|
|
135
|
+
effect,
|
|
127
136
|
},
|
|
128
137
|
pointerdown,
|
|
129
138
|
pointerup,
|
|
@@ -138,6 +147,21 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
138
147
|
} = props;
|
|
139
148
|
|
|
140
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
|
+
};
|
|
141
165
|
|
|
142
166
|
const app = useApp();
|
|
143
167
|
|
|
@@ -319,38 +343,62 @@ const PixiGifSprite: React.FC<PixiGifSpriteProps> = (props) => {
|
|
|
319
343
|
</Container>
|
|
320
344
|
)}
|
|
321
345
|
{gifFrame && gifFrame.length > 0 && (
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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>
|
|
354
402
|
)}
|
|
355
403
|
</Container>
|
|
356
404
|
</Container>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { PixiImageSprite } from ".";
|
|
3
3
|
import { AppStateContextProvider } from "../../utils/AppStateProvider";
|
|
4
|
+
import { Effects } from "../../types/Effects";
|
|
4
5
|
|
|
5
6
|
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
|
|
6
7
|
const meta = {
|
|
@@ -35,9 +36,18 @@ const meta = {
|
|
|
35
36
|
scale: { control: "number", description: "scale of the sprite" },
|
|
36
37
|
tint: { control: "number", description: "tint of the sprite" },
|
|
37
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
|
+
},
|
|
38
44
|
colorCorrection: {
|
|
39
45
|
control: "object",
|
|
40
46
|
description: "colorCorrection of the sprite",
|
|
47
|
+
enabled: {
|
|
48
|
+
control: "boolean",
|
|
49
|
+
description: "enabled of the sprite with color filter mode applied.",
|
|
50
|
+
},
|
|
41
51
|
brightness: {
|
|
42
52
|
control: "number",
|
|
43
53
|
description: "brightness of the sprite",
|
|
@@ -84,9 +94,12 @@ export const Normal: Story = {
|
|
|
84
94
|
args: {
|
|
85
95
|
uniqueId: "surya001", // uniqueId of the sprite
|
|
86
96
|
src: "https://assets.codepen.io/693612/surya.svg",
|
|
97
|
+
applyTransformer: false,
|
|
98
|
+
startAt: 0,
|
|
99
|
+
endAt: 10,
|
|
87
100
|
transformation: {
|
|
88
|
-
x:
|
|
89
|
-
y:
|
|
101
|
+
x: 200,
|
|
102
|
+
y: 200,
|
|
90
103
|
width: 150,
|
|
91
104
|
height: 150,
|
|
92
105
|
anchor: 0.5,
|
|
@@ -95,11 +108,15 @@ export const Normal: Story = {
|
|
|
95
108
|
scale: 1,
|
|
96
109
|
tint: 0xffffff,
|
|
97
110
|
blendMode: 0,
|
|
98
|
-
|
|
111
|
+
effect: Effects.None,
|
|
112
|
+
colorCorrection: {
|
|
113
|
+
enabled: false,
|
|
114
|
+
contrast: 1,
|
|
115
|
+
saturation: 1,
|
|
116
|
+
exposure: 1,
|
|
117
|
+
blurRadius: 0,
|
|
118
|
+
},
|
|
99
119
|
},
|
|
100
|
-
applyTransformer: false,
|
|
101
|
-
startAt: 0,
|
|
102
|
-
endAt: 10,
|
|
103
120
|
initialAlpha: 1,
|
|
104
121
|
},
|
|
105
122
|
};
|
|
@@ -113,6 +130,9 @@ export const FadeIn: Story = {
|
|
|
113
130
|
args: {
|
|
114
131
|
uniqueId: "surya002", // uniqueId of the sprite
|
|
115
132
|
src: "https://assets.codepen.io/693612/surya.svg",
|
|
133
|
+
applyTransformer: false,
|
|
134
|
+
startAt: 0,
|
|
135
|
+
endAt: 10,
|
|
116
136
|
transformation: {
|
|
117
137
|
x: 100,
|
|
118
138
|
y: 100,
|
|
@@ -124,12 +144,77 @@ export const FadeIn: Story = {
|
|
|
124
144
|
scale: 1,
|
|
125
145
|
tint: 0xffffff,
|
|
126
146
|
blendMode: 0,
|
|
147
|
+
effect: Effects.None,
|
|
127
148
|
animation: "FADE_IN",
|
|
128
149
|
colorCorrection: {},
|
|
129
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",
|
|
130
165
|
applyTransformer: false,
|
|
131
166
|
startAt: 0,
|
|
132
167
|
endAt: 10,
|
|
133
|
-
|
|
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,
|
|
134
219
|
},
|
|
135
220
|
};
|