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); }
public DryStroke(ParticleList path, uint seed, StrokeConstants StrokeParams, ParticleBrush particleBrush) { Path = path; RandomSeed = seed; StrokeConstants = StrokeParams; ParticleBrush = particleBrush; }
public RasterInkStroke(RasterInkBuilder inkBuilder, PointerDeviceType pointerDeviceType, List <float> points, uint seed, RasterBrush rasterBrush, ParticleBrush particleBrush, StrokeConstants StrokeParams, Identifier sensorDataId) { Id = Identifier.FromNewGuid(); PointerDeviceType = pointerDeviceType; uint channelMask = (uint)inkBuilder.SplineInterpolator.InterpolatedSplineLayout.ChannelMask; Path = new ParticleList(); Path.Assign(points, channelMask); RandomSeed = seed; StrokeConstants = StrokeParams; SensorDataId = sensorDataId; RasterBrush = rasterBrush; ParticleBrush = particleBrush; // Cloning is needed, otherwise the spatial data is corrupted Spline = inkBuilder.SplineProducer.AllData.Clone(); Layout = inkBuilder.Layout; }
protected override void RenderNewStrokeSegment() { ProcessorResult <List <float> > result; lock (mInkBuilderLock) { if (mInkBuilder.HasNewPoints) { result = mInkBuilder.GetPath(); } else { return; } } uint channelMask = (uint)mInkBuilder.SplineInterpolator.InterpolatedSplineLayout.ChannelMask; mAddedInterpolatedSpline.Assign(result.Addition, channelMask); mPredictedInterpolatedSpline.Assign(result.Prediction, channelMask); ParticleBrush brush = mInkBuilder.Brush; // Draw the added stroke mRenderingContext.SetTarget(mCurrentStrokeLayer); mDrawStrokeResult = mRenderingContext.DrawParticleStroke(mAddedInterpolatedSpline, mStrokeConstants, brush, Ink.Rendering.BlendMode.SourceOver, mDrawStrokeResult.RandomGeneratorSeed); // Measure the predicted stroke Rect predictedStrokeRect = mRenderingContext.MeasureParticleStrokeBounds(mPredictedInterpolatedSpline, mStrokeConstants, brush.Scattering); // Calculate the update rect for this frame Rect updateRect = mDirtyRectManager.GetUpdateRect(mDrawStrokeResult.DirtyRect, predictedStrokeRect); // Draw the predicted stroke mRenderingContext.SetTarget(mPrelimPathLayer); mRenderingContext.DrawLayerAtPoint(mCurrentStrokeLayer, updateRect, new Point(updateRect.X, updateRect.Y), Ink.Rendering.BlendMode.Copy); mRenderingContext.DrawParticleStroke(mPredictedInterpolatedSpline, mStrokeConstants, brush, Ink.Rendering.BlendMode.SourceOver, mDrawStrokeResult.RandomGeneratorSeed); // Reconstruct the scene under the current stroke (only within the updated rect) mRenderingContext.SetTarget(mSceneLayer, updateRect); mRenderingContext.ClearColor(BackgroundColor); mRenderingContext.DrawLayerAtPoint(mAllStrokesLayer, updateRect, new Point(updateRect.X, updateRect.Y), Ink.Rendering.BlendMode.SourceOver); // Blend the current stroke on top (only within the updated rect) mRenderingContext.DrawLayerAtPoint(mPrelimPathLayer, updateRect, new Point(updateRect.X, updateRect.Y), Ink.Rendering.BlendMode.SourceOver); }
public RasterInkStroke(Stroke stroke, RasterBrush rasterBrush, ParticleList particleList, ParticleBrush particleBrush) { Id = stroke.Id; Path = particleList; RandomSeed = stroke.Style.RandomSeed; RasterBrush = rasterBrush; ParticleBrush = particleBrush; PathPointProperties ppp = stroke.Style.PathPointProperties; StrokeConstants = new StrokeConstants { Color = 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) }; SensorDataId = stroke.SensorDataId; Spline = stroke.Spline; Layout = stroke.Layout; }
private DryStroke 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); PathPointProperties ppp = stroke.Style.PathPointProperties; StrokeConstants strokeConstants = new StrokeConstants { Color = 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) }; ParticleBrush particleBrush = new ParticleBrush { FillTexture = mGraphics.CreateTexture(Utils.GetPixelData(rasterBrush.FillTexture)), FillTileSize = new Size(rasterBrush.FillWidth, rasterBrush.FillHeight), RotationMode = (ParticleRotationMode)rasterBrush.RotationMode, Scattering = rasterBrush.Scattering, ShapeTexture = mGraphics.CreateTexture(Utils.GetPixelData(rasterBrush.ShapeTextures[0])) }; DryStroke dryStroke = new DryStroke(particleList, stroke.Style.RandomSeed, strokeConstants, particleBrush); return(dryStroke); }