Skip to content

Effect

Effect 描述节点或效果样式上的特效。

typescript
type Effect = DropShadowEffect | InnerShadowEffect | BlurEffect | NoiseEffect | TextureEffect | GlassEffect | MotionBlurEffect | ZoomBlurEffect;

DropShadowEffect

typescript
interface DropShadowEffect {
  readonly type: "DROP_SHADOW";
  readonly color: RGBA;
  readonly offset: Vector;
  readonly radius: number;
  readonly spread?: number;
  readonly visible: boolean;
  readonly blendMode: BlendMode;
  readonly showShadowBehindNode?: boolean;
  readonly boundVariables?: {
    radius?: VariableAlias;
    color?: VariableAlias;
    spread?: VariableAlias;
    offsetX?: VariableAlias;
    offsetY?: VariableAlias;
  };
}

InnerShadowEffect

typescript
interface InnerShadowEffect {
  readonly type: "INNER_SHADOW";
  readonly color: RGBA;
  readonly offset: Vector;
  readonly radius: number;
  readonly spread?: number;
  readonly visible: boolean;
  readonly blendMode: BlendMode;
  readonly boundVariables?: {
    radius?: VariableAlias;
    color?: VariableAlias;
    spread?: VariableAlias;
    offsetX?: VariableAlias;
    offsetY?: VariableAlias;
  };
}

BlurEffect

typescript
type BlurEffect = BlurEffectNormal | BlurEffectProgressive;

interface BlurEffectNormal {
  readonly type: "LAYER_BLUR" | "BACKGROUND_BLUR";
  readonly radius: number;
  readonly visible: boolean;
  readonly blurType?: "NORMAL";
  readonly saturation?: number;
  readonly boundVariables?: {
    radius?: VariableAlias;
  };
}

interface BlurEffectProgressive {
  readonly type: "LAYER_BLUR" | "BACKGROUND_BLUR";
  readonly radius: number;
  readonly visible: boolean;
  readonly blurType: "PROGRESSIVE";
  readonly startRadius: number;
  readonly startOffset: Vector;
  readonly endOffset: Vector;
  readonly progressiveStops?: ReadonlyArray<ProgressiveStop>;
  readonly saturation?: number;
  readonly boundVariables?: {
    radius?: VariableAlias;
  };
}

interface ProgressiveStop {
  readonly position: number;
  readonly radius: number;
}

progressiveStops 用于描述渐进模糊的控制点数组。每个控制点通过 position 表示在渐进路径上的位置,通过 radius 表示该位置的模糊半径。

NoiseEffect

typescript
type NoiseEffect = NoiseEffectMonotone | NoiseEffectDuotone | NoiseEffectMultitone;

interface NoiseEffectBase {
  readonly type: "NOISE";
  readonly color: RGBA;
  readonly visible: boolean;
  readonly blendMode: BlendMode;
  readonly noiseSize: number;
  readonly density: number;
  readonly boundVariables?: {};
}

interface NoiseEffectMonotone extends NoiseEffectBase {
  readonly noiseType: "MONOTONE";
}

interface NoiseEffectDuotone extends NoiseEffectBase {
  readonly noiseType: "DUOTONE";
  readonly secondaryColor: RGBA;
}

interface NoiseEffectMultitone extends NoiseEffectBase {
  readonly noiseType: "MULTITONE";
  readonly opacity: number;
}

noiseSize 在插件 API 中是 number。Pixso 内部的 { x, y } 形态不会返回。

TextureEffect

typescript
interface TextureEffect {
  readonly type: "TEXTURE";
  readonly visible: boolean;
  readonly noiseSize: number;
  readonly radius: number;
  readonly clipToShape: boolean;
  readonly boundVariables?: {};
}

纹理编辑用到的内部 transform 不会返回到插件 API。

GlassEffect

typescript
interface GlassEffect {
  readonly type: "GLASS";
  readonly visible: boolean;
  readonly lightIntensity: number;
  readonly lightAngle: number;
  readonly refraction: number;
  readonly depth: number;
  readonly dispersion: number;
  readonly radius: number;
  readonly brightness?: number;
  readonly saturation?: number;
  readonly uniformLight?: boolean;
  readonly isImpact?: boolean;
  readonly samplingRange?: number;
  readonly isConvex?: boolean;
  readonly splay?: number;
  readonly boundVariables?: {};
}

液态玻璃字段说明:

  • lightIntensity / lightAngle:光源亮度和光源角度。
  • refraction / depth / dispersion:折射强度、深度和色散。
  • brightness / saturation:亮度和饱和度。
  • uniformLight:是否使用均匀光照。
  • isImpact:是否受环境影响。
  • samplingRange:环境影响开启时的采样范围,取值范围为 020
  • isConvex:透镜形状,true 表示凸透镜,false 表示凹透镜。
  • splay:曲面扩散,取值范围为 01

MotionBlurEffect

typescript
interface MotionBlurEffect {
  readonly type: "MOTION_BLUR";
  readonly visible: boolean;
  readonly radius?: number;
  readonly motionAngle?: number;
  readonly boundVariables?: {
    radius?: VariableAlias;
  };
}

motionAngle 表示运动模糊角度。

ZoomBlurEffect

typescript
interface ZoomBlurEffect {
  readonly type: "ZOOM_BLUR";
  readonly visible: boolean;
  readonly radius: number;
  readonly center?: Vector;
  readonly boundVariables?: {
    radius?: VariableAlias;
  };
}

center 表示缩放模糊中心点,使用相对坐标;未传入时默认 { x: 0.5, y: 0.5 }