forked from 4ian/GDevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulge-pinch-pixi-filter.ts
91 lines (91 loc) · 2.94 KB
/
bulge-pinch-pixi-filter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
namespace gdjs {
interface BulgePinchFilterNetworkSyncData {
cx: number;
cy: number;
r: number;
s: number;
}
gdjs.PixiFiltersTools.registerFilterCreator(
'BulgePinch',
new (class extends gdjs.PixiFiltersTools.PixiFilterCreator {
makePIXIFilter(target: EffectsTarget, effectData) {
const bulgePinchFilter = new PIXI.filters.BulgePinchFilter();
return bulgePinchFilter;
}
updatePreRender(filter: PIXI.Filter, target: EffectsTarget) {}
updateDoubleParameter(
filter: PIXI.Filter,
parameterName: string,
value: number
) {
const bulgePinchFilter = (filter as unknown) as PIXI.filters.BulgePinchFilter;
if (parameterName === 'centerX') {
bulgePinchFilter.center[0] = value;
} else if (parameterName === 'centerY') {
bulgePinchFilter.center[1] = value;
} else if (parameterName === 'radius') {
bulgePinchFilter.radius = value;
} else if (parameterName === 'strength') {
bulgePinchFilter.strength = gdjs.PixiFiltersTools.clampValue(
value,
-1,
1
);
}
}
getDoubleParameter(filter: PIXI.Filter, parameterName: string): number {
const bulgePinchFilter = (filter as unknown) as PIXI.filters.BulgePinchFilter;
if (parameterName === 'centerX') {
return bulgePinchFilter.center[0];
}
if (parameterName === 'centerY') {
return bulgePinchFilter.center[1];
}
if (parameterName === 'radius') {
return bulgePinchFilter.radius;
}
if (parameterName === 'strength') {
return bulgePinchFilter.strength;
}
return 0;
}
updateStringParameter(
filter: PIXI.Filter,
parameterName: string,
value: string
) {}
updateColorParameter(
filter: PIXI.Filter,
parameterName: string,
value: number
): void {}
getColorParameter(filter: PIXI.Filter, parameterName: string): number {
return 0;
}
updateBooleanParameter(
filter: PIXI.Filter,
parameterName: string,
value: boolean
) {}
getNetworkSyncData(filter: PIXI.Filter): BulgePinchFilterNetworkSyncData {
const bulgePinchFilter = (filter as unknown) as PIXI.filters.BulgePinchFilter;
return {
cx: bulgePinchFilter.center[0],
cy: bulgePinchFilter.center[1],
r: bulgePinchFilter.radius,
s: bulgePinchFilter.strength,
};
}
updateFromNetworkSyncData(
filter: PIXI.Filter,
data: BulgePinchFilterNetworkSyncData
) {
const bulgePinchFilter = (filter as unknown) as PIXI.filters.BulgePinchFilter;
bulgePinchFilter.center[0] = data.cx;
bulgePinchFilter.center[1] = data.cy;
bulgePinchFilter.radius = data.r;
bulgePinchFilter.strength = data.s;
}
})()
);
}