Skip to content

Commit

Permalink
Chore: DropShadowFilter backward-compatibility (#422)
Browse files Browse the repository at this point in the history
* Chore: Drop Shadow Filter Deprecations

* Cleanup

---------

Co-authored-by: Baz Utsahajit <[email protected]>
  • Loading branch information
bbazukun123 and bbazukun123 authored Feb 14, 2024
1 parent 6fcc311 commit 89baaec
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/drop-shadow/DropShadowFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import source from './drop-shadow.wgsl';
export interface DropShadowFilterOptions
{
/**
* Set the offset position of the drop-shadow relative to the original image.
* The offset position of the drop-shadow relative to the original image.
* @default {x:4,y:4}
*/
offset?: PointData;
Expand Down Expand Up @@ -54,10 +54,15 @@ export interface DropShadowFilterOptions
*/
kernels?: number[];
/**
* Sets the pixelSize of the Kawase Blur filter
* The pixelSize of the Kawase Blur filter
* @default {x:1,y:1}
*/
pixelSize?: PointData;
pixelSize?: PointData | number[] | number;
/**
* The resolution of the Kawase Blur filter
* @default 1
*/
resolution?: number;
}

/**
Expand All @@ -79,6 +84,7 @@ export class DropShadowFilter extends Filter
blur: 2,
quality: 3,
pixelSize: { x: 1, y: 1 },
resolution: 1,
};

public uniforms: {
Expand Down Expand Up @@ -127,7 +133,8 @@ export class DropShadowFilter extends Filter
uColor: { value: new Float32Array(3), type: 'vec3<f32>' },
uOffset: { value: options.offset, type: 'vec2<f32>' },
}
}
},
resolution: options.resolution,
});

this.uniforms = this.resources.dropShadowUniforms.uniforms;
Expand Down Expand Up @@ -294,9 +301,19 @@ export class DropShadowFilter extends Filter
{
return this._blurFilter.pixelSize as PointData;
}
set pixelSize(value: PointData)
set pixelSize(value: PointData | number[] | number)
{
(this._blurFilter.pixelSize as PointData) = value;
if (typeof value === 'number')
{
value = { x: value, y: value };
}

if (Array.isArray(value))
{
value = { x: value[0], y: value[1] };
}

this._blurFilter.pixelSize = value;
}

/**
Expand Down

0 comments on commit 89baaec

Please sign in to comment.