AutoPatientInfoRecorder/src/AntdUI/Lib/SVG/Transforms/SvgTransformConverter.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// THIS FILE IS PART OF SVG PROJECT
// THE SVG PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MS-PL License.
// COPYRIGHT (C) svg-net. ALL RIGHTS RESERVED.
// GITHUB: https://github.com/svg-net/SVG
using System;
using System.Collections.Generic;
using System.Globalization;
namespace AntdUI.Svg.Transforms
{
internal class SvgTransformConverter
{
static IEnumerable<string> SplitTransforms(string transforms)
{
int transformEnd = 0;
for (int i = 0; i < transforms.Length; i++)
{
if (transforms[i] == ')')
{
yield return transforms.Substring(transformEnd, i - transformEnd + 1).Trim();
while (i < transforms.Length && !char.IsLetter(transforms[i])) i++;
transformEnd = i;
}
}
}
public static SvgTransformCollection Parse(string value)
{
SvgTransformCollection transformList = new SvgTransformCollection();
foreach (string transform in SplitTransforms(value))
{
if (string.IsNullOrEmpty(transform)) continue;
var parts = transform.Split('(', ')');
string transformName = parts[0].Trim(), contents = parts[1].Trim();
switch (transformName)
{
case "translate":
var coords = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (coords.Length == 0 || coords.Length > 2) throw new FormatException("Translate transforms must be in the format 'translate(x [,y])'");
float x = float.Parse(coords[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
if (coords.Length > 1)
{
float y = float.Parse(coords[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture);
transformList.Add(new SvgTranslate(x, y));
}
else transformList.Add(new SvgTranslate(x));
break;
case "rotate":
var args = contents.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (args.Length != 1 && args.Length != 3) throw new FormatException("Rotate transforms must be in the format 'rotate(angle [cx cy ])'");
float angle = float.Parse(args[0], NumberStyles.Float, CultureInfo.InvariantCulture);
if (args.Length == 1) transformList.Add(new SvgRotate(angle));
else
{
float cx = float.Parse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture);
float cy = float.Parse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture);
transformList.Add(new SvgRotate(angle, cx, cy));
}
后面还有 44 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。