VgVisualElement CreateGroup(VgVisualElement parentNode, SvgVisualSpec visSpec) { VgVisualElement vgVisElem = new VgVisualElement(WellknownSvgElementName.Group, visSpec, _vgVisualDoc); AssignAttributes(visSpec); return(vgVisElem); }
void AssignAttributes(SvgVisualSpec spec, VgVisualElement visualElem = null) { BuildDefinitionNodes(); if (spec.ClipPathLink != null) { //resolve this clip if (_registeredElemsById.TryGetValue(spec.ClipPathLink.Value, out VgVisualElement clip)) { spec.ResolvedClipPath = clip; //cmds.Add(clip); } else { if (_registeredElemsById.TryGetValue(spec.ClipPathLink.Value, out VgVisualElement clipElem)) { spec.ResolvedClipPath = clipElem; } else { } } } if (spec.HasFillColor && spec.FillPathLink != null) { if (_registeredElemsById.TryGetValue(spec.FillPathLink.Value, out VgVisualElement fillElem)) { spec.ResolvedFillBrush = fillElem; } else { } } if (spec.MaskPathLink != null) { //TODO: resolve this later if (_registeredElemsById.TryGetValue(spec.MaskPathLink.Value, out VgVisualElement maskElem)) { spec.ResolvedMask = maskElem; } else { } } if (spec.FilterPathLink != null) { if (_registeredElemsById.TryGetValue(spec.FilterPathLink.Value, out VgVisualElement filterElem)) { spec.ResolvedFilter = filterElem; } else { } } }
protected static void AssignValues(SvgPart svgPart, SvgVisualSpec spec) { if (spec.HasFillColor) { svgPart.FillColor = spec.FillColor; } if (spec.HasStrokeColor) { svgPart.StrokeColor = spec.StrokeColor; } if (spec.HasStrokeWidth) { //assume this is in pixel unit svgPart.StrokeWidth = spec.StrokeWidth.Number; } if (spec.Transform != null) { svgPart.AffineTx = spec.Transform; } }
public static void ParseTransform(string value, SvgVisualSpec spec) { //TODO: .... int openParPos = value.IndexOf('('); if (openParPos > -1) { string right = value.Substring(openParPos + 1, value.Length - (openParPos + 1)).Trim(); string left = value.Substring(0, openParPos); switch (left) { default: break; case "matrix": { //read matrix args spec.Transform = new SvgTransformMatrix(ParseMatrixArgs(right)); } break; case "translate": { //translate matrix float[] matrixArgs = ParseMatrixArgs(right); spec.Transform = new SvgTranslate(matrixArgs[0], matrixArgs[1]); } break; case "rotate": { float[] matrixArgs = ParseMatrixArgs(right); if (matrixArgs.Length == 1) { spec.Transform = new SvgRotate(matrixArgs[0]); } else if (matrixArgs.Length == 3) { //rotate around the axis spec.Transform = new SvgRotate(matrixArgs[0], matrixArgs[1], matrixArgs[2]); } } break; case "scale": { float[] matrixArgs = ParseMatrixArgs(right); spec.Transform = new SvgScale(matrixArgs[0], matrixArgs[1]); } break; case "skewX": { float[] matrixArgs = ParseMatrixArgs(right); spec.Transform = new SvgSkew(matrixArgs[0], 0); } break; case "skewY": { float[] matrixArgs = ParseMatrixArgs(right); spec.Transform = new SvgSkew(0, matrixArgs[1]); } break; } } else { //? } }
static void ParseTransform(string value, SvgVisualSpec spec) { //TODO: .... int openParPos = value.IndexOf('('); if (openParPos > -1) { string right = value.Substring(openParPos + 1, value.Length - (openParPos + 1)).Trim(); string left = value.Substring(0, openParPos); switch (left) { default: break; case "matrix": { //read matrix args double[] matrixArgs = ParseMatrixArgs(right); //create affine matrix spec.Transform = Affine.NewCustomMatrix( matrixArgs[0], matrixArgs[1], matrixArgs[2], matrixArgs[3], matrixArgs[4], matrixArgs[5] ); } break; case "translate": { double[] matrixArgs = ParseMatrixArgs(right); } break; case "rotate": { double[] matrixArgs = ParseMatrixArgs(right); } break; case "scale": { double[] matrixArgs = ParseMatrixArgs(right); } break; case "skewX": { double[] matrixArgs = ParseMatrixArgs(right); } break; case "skewY": { double[] matrixArgs = ParseMatrixArgs(right); } break; } } else { //? } }
void ParseStyle(SvgVisualSpec spec, string cssStyle) { if (!String.IsNullOrEmpty(cssStyle)) { #if DEBUG s_dbugIdCount++; #endif //*** CssRuleSet cssRuleSet = _ownerParser._cssParser.ParseCssPropertyDeclarationList(cssStyle.ToCharArray()); foreach (CssPropertyDeclaration propDecl in cssRuleSet.GetAssignmentIter()) { switch (propDecl.UnknownRawName) { default: break; case "fill": { int valueCount = propDecl.ValueCount; //1 string value = propDecl.GetPropertyValue(0).ToString(); if (value != "none") { spec.FillColor = ConvToActualColor(CssValueParser2.GetActualColor(value)); } } break; case "fill-opacity": { //TODO: //adjust fill opacity } break; case "stroke-width": { int valueCount = propDecl.ValueCount; //1 string value = propDecl.GetPropertyValue(0).ToString(); spec.StrokeWidth = UserMapUtil.ParseGenericLength(value); } break; case "stroke": { //TODO: //if (attr.Value != "none") //{ // spec.StrokeColor = ConvToActualColor(CssValueParser2.GetActualColor(attr.Value)); //} } break; case "stroke-linecap": //set line-cap and line join again //TODO: break; case "stroke-linejoin": //TODO: break; case "stroke-miterlimit": //TODO: break; case "stroke-opacity": //TODO: break; case "transform": { ////parse trans //ParseTransform(attr.Value, spec); } break; } } } }
public virtual void VisitContext() { spec = new SvgVisualSpec(); }