元素参考

Image 元素

1. 结构

interface ImageClip extends BaseClip {
  type: "image";
  src: string | { $ref: string };
}

2. 支持的参数

src

  • 类型:string | { $ref: string }
  • 必填:是
  • 用途:图片地址或图片素材引用

3. 当前真实行为

  • src 支持直接 URL
  • src 支持 $ref
  • transform 可用
  • style.borderRadius 可用
  • style.objectFit 可用
  • style.filters 可用

4. style.objectFit

支持:

  • fill
  • cover
  • contain

说明:

  • fill:强制拉伸铺满目标区域,可能变形
  • cover:等比铺满,可能裁切
  • contain:等比完整显示,可能留白

示例:

{
  "style": {
    "objectFit": "cover"
  }
}

也可以与滤镜一起使用:

{
  "style": {
    "objectFit": "cover",
    "filters": [
      { "type": "blur", "value": 24 }
    ]
  }
}

5. 示例

{
  "type": "image",
  "start": 0.5,
  "duration": 4,
  "src": { "$ref": "logo" },
  "transform": {
    "x": "85%",
    "y": "10%",
    "width": 220,
    "height": 80
  },
  "style": {
    "borderRadius": 16,
    "objectFit": "contain"
  },
  "animations": [
    {
      "type": "fadeIn",
      "duration": 0.5
    }
  ]
}