private void AddRasterBrushToInkDoc(PointerDeviceType deviceType, RasterBrush rasterBrush, Style rasterStyle, StrokeConstants strokeConstants, uint startRandomSeed) { if (!InkDocument.Brushes.TryGetBrush(rasterBrush.Name, out Brush foundBrush)) { InkDocument.Brushes.AddRasterBrush(rasterBrush); } }
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; }
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 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); }
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); }