[frontend/mfm] Implement crop fn node
This commit is contained in:
parent
db5d6f469f
commit
fec60a6b69
1 changed files with 11 additions and 1 deletions
|
@ -270,7 +270,7 @@ public static class MfmRenderer
|
|||
"sparkle" => throw new NotImplementedException($"{node.Name}"),
|
||||
"rotate" => MfmFnRotate(args, document),
|
||||
"fade" => throw new NotImplementedException($"{node.Name}"),
|
||||
"crop" => throw new NotImplementedException($"{node.Name}"),
|
||||
"crop" => MfmFnCrop(args, document),
|
||||
"position" => throw new NotImplementedException($"{node.Name}"),
|
||||
"scale" => throw new NotImplementedException($"{node.Name}"),
|
||||
"fg" => throw new NotImplementedException($"{node.Name}"),
|
||||
|
@ -345,4 +345,14 @@ public static class MfmRenderer
|
|||
|
||||
return el;
|
||||
}
|
||||
|
||||
private static INode MfmFnCrop(Dictionary<string, string?> args, IDocument document)
|
||||
{
|
||||
var el = document.CreateElement("span");
|
||||
|
||||
var inset = $"{args.GetValueOrDefault("top") ?? "0"}% {args.GetValueOrDefault("right") ?? "0"}% {args.GetValueOrDefault("bottom") ?? "0"}% {args.GetValueOrDefault("left") ?? "0"}%";
|
||||
el.SetAttribute("style", $"display: inline-block; clip-path: inset({inset});");
|
||||
|
||||
return el;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue