From 0c611e9c4e995bfc56598ad400eee84d77070045 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Fri, 28 Jun 2013 15:05:51 +0000 Subject: [PATCH] fpvectorial: Advances the radial gradient code, not yet working git-svn-id: trunk@41932 - --- components/fpvectorial/fpvectorial.pas | 2 +- components/fpvectorial/svgvectorialreader.pas | 72 ++++++++++++++++--- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/components/fpvectorial/fpvectorial.pas b/components/fpvectorial/fpvectorial.pas index 2f4bff8b0b..cc880b77a8 100644 --- a/components/fpvectorial/fpvectorial.pas +++ b/components/fpvectorial/fpvectorial.pas @@ -103,8 +103,8 @@ type TvBrush = record Color: TFPColor; Style: TFPBrushStyle; - // Gradient filling support Kind: TvBrushKind; + // Gradient filling support Gradient_cx, Gradient_cy, Gradient_r, Gradient_fx, Gradient_fy: Double; Gradient_cx_Unit, Gradient_cy_Unit, Gradient_r_Unit, Gradient_fx_Unit, Gradient_fy_Unit: TvCoordinateUnit; Gradient_colors: array of TFPColor; diff --git a/components/fpvectorial/svgvectorialreader.pas b/components/fpvectorial/svgvectorialreader.pas index 82ea2bcaf4..1981a015a4 100644 --- a/components/fpvectorial/svgvectorialreader.pas +++ b/components/fpvectorial/svgvectorialreader.pas @@ -65,7 +65,7 @@ type FSVGPathTokenizer: TSVGPathTokenizer; FLayerStylesKeys, FLayerStylesValues: TFPList; // of TStringList; // Defs section - DefsBrushes: TFPList; // of TvBrush + FBrushDefs: TFPList; // of TvEntityWithPenAndBrush; // debug symbols FPathNumber: Integer; function ReadSVGColor(AValue: string): TFPColor; @@ -937,17 +937,71 @@ var lEntityName: DOMString; lBlock: TvBlock; lPreviousLayer: TvEntityWithSubEntities; - lNodeName: DOMString; + lAttrName, lAttrValue, lNodeName: DOMString; lLayerName: String; i: Integer; - lCurNode: TDOMNode; + lCurNode, lCurSubNode: TDOMNode; + lBrushEntity: TvEntityWithPenAndBrush; begin lCurNode := ANode.FirstChild; while Assigned(lCurNode) do begin lEntityName := LowerCase(lCurNode.NodeName); case lEntityName of - //'RadialGradient': + 'RadialGradient': + begin + lBrushEntity := TvEntityWithPenAndBrush.Create; + lBrushEntity.Brush.Kind := bkRadialGradient; + + // + for i := 0 to lCurNode.Attributes.Length - 1 do + begin + lAttrName := lCurNode.Attributes.Item[i].NodeName; + lAttrValue := lCurNode.Attributes.Item[i].NodeValue; + if lAttrName = 'id' then + begin + lBrushEntity.Name := lAttrValue; + end; + {else if lAttrName = 'cx' then + begin + lLayerName := lCurNode.Attributes.Item[i].NodeValue; + lBlock.Name := lLayerName; + end; + } + end; + +{ Gradient_cx, Gradient_cy, Gradient_r, Gradient_fx, Gradient_fy: Double; + Gradient_cx_Unit, Gradient_cy_Unit, Gradient_r_Unit, Gradient_fx_Unit, Gradient_fy_Unit: TvCoordinateUnit; + Gradient_colors: array of TFPColor;} + + // + // + //} + lCurSubNode := lCurNode.FirstChild; + while Assigned(lCurSubNode) do + begin + {lNodeName := LowerCase(lCurSubNode.NodeName); + + for i := 0 to lCurSubNode.Attributes.Length - 1 do + begin + lAttrName := lCurSubNode.Attributes.Item[i].NodeName; + lAttrValue := lCurSubNode.Attributes.Item[i].NodeValue; + if lAttrName = 'offset' then + begin + //lOffset := lAttrName; + end; + else if lAttrName = 'cx' then + begin + lLayerName := lCurNode.Attributes.Item[i].NodeValue; + lBlock.Name := lLayerName; + end; + end;} + + lCurSubNode := lCurSubNode.NextSibling; + end; + + FBrushDefs.Add(lBrushEntity); + end; // Sometime entities are also put in the defs 'circle', 'ellipse', 'g', 'line', 'path', 'polygon', 'polyline', 'rect', 'text', 'use': @@ -957,8 +1011,8 @@ begin // pre-load attribute reader, to get the block name for i := 0 to lCurNode.Attributes.Length - 1 do begin - lNodeName := lCurNode.Attributes.Item[i].NodeName; - if lNodeName = 'id' then + lAttrName := lCurNode.Attributes.Item[i].NodeName; + if lAttrName = 'id' then begin lLayerName := lCurNode.Attributes.Item[i].NodeValue; lBlock.Name := lLayerName; @@ -1937,16 +1991,14 @@ begin FSVGPathTokenizer := TSVGPathTokenizer.Create; FLayerStylesKeys := TFPList.Create; FLayerStylesValues := TFPList.Create; - - DefsBrushes := TFPList.Create; + FBrushDefs := TFPList.Create; end; destructor TvSVGVectorialReader.Destroy; begin - DefsBrushes.Free; - FLayerStylesKeys.Free; FLayerStylesValues.Free; + FBrushDefs.Free; FSVGPathTokenizer.Free; inherited Destroy;