Beispiel #1
0
 private void AddVectorBrushToInkDoc(string pointerDeviceType, Wacom.Ink.Serialization.Model.VectorBrush vectorBrush, Style style)
 {
     if (!InkDocument.Brushes.TryGetBrush(vectorBrush.Name, out Brush foundBrush))
     {
         InkDocument.Brushes.AddVectorBrush(vectorBrush);
     }
 }
Beispiel #2
0
        public void EncodeStroke(VectorInkStroke stroke)
        {
            var vectorBrush = new Wacom.Ink.Serialization.Model.VectorBrush(
                "will://examples/brushes/" + Guid.NewGuid().ToString(),
                stroke.VectorBrush.Polygons);

            var style = new Wacom.Ink.Serialization.Model.Style(vectorBrush.Name);

            style.PathPointProperties.Red   = stroke.Color.R / 255.0f;
            style.PathPointProperties.Green = stroke.Color.G / 255.0f;
            style.PathPointProperties.Blue  = stroke.Color.B / 255.0f;
            style.PathPointProperties.Alpha = stroke.Color.A / 255.0f;

            AddVectorBrushToInkDoc(stroke.PointerDeviceType.ToString(), vectorBrush, style);
            EncodeStrokeCommon(stroke.Id, stroke.Spline.Clone(), stroke.Layout, stroke.SensorDataId, style);
        }
        public void EncodeCurrentStroke(string pointerDeviceType, VectorInkBuilder inkBuilder, MediaColor brushColor)
        {
            var vectorBrush = new Wacom.Ink.Serialization.Model.VectorBrush(
                "will://examples/brushes/" + Guid.NewGuid().ToString(),
                inkBuilder.BrushApplier.Prototype.Polygons);

            var style = new Wacom.Ink.Serialization.Model.Style(vectorBrush.Name);

            style.PathPointProperties.Red   = brushColor.R / 255.0f;
            style.PathPointProperties.Green = brushColor.G / 255.0f;
            style.PathPointProperties.Blue  = brushColor.B / 255.0f;
            style.PathPointProperties.Alpha = brushColor.A / 255.0f;

            AddVectorBrushToInkDoc(pointerDeviceType, vectorBrush, style);
            EncodeCurrentStrokeCommon(pointerDeviceType, inkBuilder, style);
        }
        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));
        }
Beispiel #5
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);
        }