private VectorInkStroke CreateDryStrokeFromVectorBrush(DecodedVectorInkBuilder decodedVectorInkBuilder, Wacom.Ink.Serialization.Model.VectorBrush vectorBrush, Stroke stroke)
        {
            Wacom.Ink.Geometry.VectorBrush vb;

            if (vectorBrush.BrushPolygons.Count > 0)
            {
                vb = new Wacom.Ink.Geometry.VectorBrush(vectorBrush.BrushPolygons.ToArray());
            }
            else if (vectorBrush.BrushPrototypeURIs.Count > 0)
            {
                List <BrushPolygon> brushPolygons = new List <BrushPolygon>(vectorBrush.BrushPrototypeURIs.Count);

                foreach (var uri in vectorBrush.BrushPrototypeURIs)
                {
                    brushPolygons.Add(new BrushPolygon(uri.MinScale, ShapeUriResolver.ResolveShape(uri.ShapeUri)));
                }

                vb = new Wacom.Ink.Geometry.VectorBrush(brushPolygons.ToArray());
            }
            else
            {
                throw new ArgumentException("Missing vector brush information! Expected BrushPolygons, BrushPolyhedrons or BrushPrototypeURIs.");
            }
            var pipelineData = decodedVectorInkBuilder.AddWholePath(stroke.Spline, stroke.Layout, vb);

            return(new VectorInkStroke(stroke, vb, pipelineData));
        }
예제 #2
0
        private DryStroke CreateDryStrokeFromVectorBrush(DecodedVectorInkBuilder decodedVectorInkBuilder, Wacom.Ink.Serialization.Model.VectorBrush vectorBrush, Stroke stroke)
        {
            Wacom.Ink.Geometry.VectorBrush vb;

            if (vectorBrush.BrushPolygons.Count > 0)
            {
                vb = new Wacom.Ink.Geometry.VectorBrush(vectorBrush.BrushPolygons.ToArray());
            }
            else if (vectorBrush.BrushPrototypeURIs.Count > 0)
            {
                List <BrushPolygon> brushPolygons = new List <BrushPolygon>(vectorBrush.BrushPrototypeURIs.Count);

                foreach (var uri in vectorBrush.BrushPrototypeURIs)
                {
                    brushPolygons.Add(new BrushPolygon(uri.MinScale, ShapeUriResolver.ResolveShape(uri.ShapeUri)));
                }

                vb = new Wacom.Ink.Geometry.VectorBrush(brushPolygons.ToArray());
            }
            else
            {
                throw new ArgumentException("Missing vector brush information! Expected BrushPolygons, BrushPolyhedrons or BrushPrototypeURIs.");
            }
            var result = decodedVectorInkBuilder.AddWholePath(stroke.Spline, stroke.Layout, vb);
            var ppp    = stroke.Style.PathPointProperties;

            DryStroke dryStroke = new DryStroke
            {
                mPolygon = PolygonUtil.ConvertPolygon(result.Addition),
                mColor   = MediaColor.FromArgb(
                    ppp.Alpha.HasValue ? (byte)(ppp.Alpha * 255.0f) : byte.MinValue,
                    ppp.Red.HasValue ? (byte)(ppp.Red * 255.0f) : byte.MinValue,
                    ppp.Green.HasValue ? (byte)(ppp.Green * 255.0f) : byte.MinValue,
                    ppp.Blue.HasValue ? (byte)(ppp.Blue * 255.0f) : byte.MinValue)
            };

            return(dryStroke);
        }