Beispiel #1
0
        private RasterInkStroke CreateDryStrokeFromRasterBrush(DecodedRasterInkBuilder decodedRasterInkBuilder, RasterBrush rasterBrush, Stroke stroke)
        {
            var result = decodedRasterInkBuilder.AddWholePath(stroke.Spline.Data, rasterBrush.Spacing, stroke.Layout);

            List <float> points = new List <float>(result.Addition);

            uint channelMask = (uint)decodedRasterInkBuilder.SplineInterpolator.InterpolatedSplineLayout.ChannelMask;

            ParticleList particleList = new ParticleList();

            particleList.Assign(points, channelMask);

            ParticleBrush particleBrush = new ParticleBrush
            {
                FillTexture  = mGraphics.CreateTexture(Task.Run(async() => await Utils.GetPixelDataAsync(rasterBrush.FillTexture)).Result),
                FillTileSize = new Size(rasterBrush.FillWidth, rasterBrush.FillHeight),
                RotationMode = (ParticleRotationMode)rasterBrush.RotationMode,
                Scattering   = rasterBrush.Scattering,
                ShapeTexture = mGraphics.CreateTexture(Task.Run(async() => await Utils.GetPixelDataAsync(rasterBrush.ShapeTextures[0])).Result)
            };

            RasterInkStroke dryStroke = new RasterInkStroke(stroke, rasterBrush, particleList, particleBrush);

            return(dryStroke);
        }
Beispiel #2
0
        /// <summary>
        /// Make the current stroke permanent
        /// </summary>
        /// <remarks>Copies the output of the render pipeline from InkBuilder to dry strokes</remarks>
        public override void StoreCurrentStroke(PointerDeviceType deviceType)
        {
            var allData = RasterInkBuilder.SplineInterpolator.AllData;
            var points  = new List <float>();

            if (allData != null)
            {
                for (int i = 0; i < allData.Count; i++)
                {
                    points.Add(allData[i]);
                }

                if (points.Count > 0)
                {
                    var dryStroke = new RasterInkStroke(RasterInkBuilder,
                                                        deviceType,
                                                        points,
                                                        mStartRandomSeed,
                                                        CreateSerializationBrush($"will://examples/brushes/{Guid.NewGuid().ToString()}"),
                                                        mActiveTool.Brush,
                                                        mStrokeConstants.Clone(),
                                                        mSerializer.AddSensorData(deviceType, InkBuilder.GetPointerDataList()));
                    mDryStrokes.Add(dryStroke);
                }
            }
        }
Beispiel #3
0
        public void EncodeStroke(RasterInkStroke stroke)
        {
            var rasterBrush = stroke.RasterBrush;
            var style       = new Wacom.Ink.Serialization.Model.Style(rasterBrush.Name);

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

            AddRasterBrushToInkDoc(stroke.PointerDeviceType, rasterBrush, style, stroke.StrokeConstants, stroke.RandomSeed);
            EncodeStrokeCommon(stroke.Id, stroke.Spline, stroke.Layout, stroke.SensorDataId, style);
        }
Beispiel #4
0
        /// <summary>
        /// Draw stroke
        /// </summary>
        /// <param name="renderingContext">RenderingContext to draw to</param>
        /// <param name="o">Cached stroke (as object)</param>
        public override void DoRenderStroke(RenderingContext renderingContext, object o, bool translationLayerPainted)
        {
            RasterInkStroke stroke = (RasterInkStroke)o;

            renderingContext.DrawParticleStroke(stroke.Path, stroke.StrokeConstants, stroke.ParticleBrush, Ink.Rendering.BlendMode.SourceOver, stroke.RandomSeed);
        }