diff --git a/src/shader/DoricImageNode.ts b/src/shader/DoricImageNode.ts index c1296f3c..a6d5f8fa 100644 --- a/src/shader/DoricImageNode.ts +++ b/src/shader/DoricImageNode.ts @@ -1,8 +1,17 @@ import { DoricViewNode, LEFT, RIGHT, CENTER_X, CENTER_Y, TOP, BOTTOM, toPixelString, toRGBAString } from "./DoricViewNode"; +enum ScaleType { + ScaleToFill = 0, + ScaleAspectFit, + ScaleAspectFill, +} + export class DoricImageNode extends DoricViewNode { + build(): HTMLElement { - return document.createElement('img') + const ret = document.createElement('img') + ret.style.objectFit = "fill" + return ret } blendProps(v: HTMLImageElement, propName: string, prop: any) { @@ -21,6 +30,19 @@ export class DoricImageNode extends DoricViewNode { }) } break + case 'scaleType': + switch (prop) { + case ScaleType.ScaleToFill: + v.style.objectFit = "fill" + break + case ScaleType.ScaleAspectFit: + v.style.objectFit = "contain" + break + case ScaleType.ScaleAspectFill: + v.style.objectFit = "cover" + break + } + break default: super.blendProps(v, propName, prop) break