public override void SetupStrokeTool(Windows.Devices.Input.PointerDevice device) { PathPointLayout layout = mActiveTool.GetLayout(device.PointerDeviceType); Calculator calculator = mActiveTool.GetCalculator(device.PointerDeviceType); RasterInkBuilder.UpdatePipeline(layout, calculator, mActiveTool.ParticleSpacing); }
public InkDataModel CreateWill3Document() { IPathCollection paths = GetComponentInChildren <IPathCollection>(); if (paths == null) { return(null); } InkDataModel will3Doc = new InkDataModel(); PathGroupNode root = new PathGroupNode(Identifier.FromNewGuid()); will3Doc.InkTree.Root = root; PathPointLayout layoutXYZS = new PathPointLayout(PathPoint.Property.X, PathPoint.Property.Y, PathPoint.Property.Z, PathPoint.Property.Size); List <System.Numerics.Vector3> brushPolyhedron = CreateDummyBrush(); VectorBrush brush = new VectorBrush(Identifier.FromNewGuid(), brushPolyhedron); brush.RenderModeUri = "will3://rendering//pen"; brush.RenderingProperties = new RenderingProperties() { Red = 0.0f, Green = 0.0f, Blue = 0.0f, Alpha = 1.0f }; will3Doc.Brushes.AddVectorBrush(brush); Style style = new Style(brush); int pathsCount = paths.GetPathsCount(); for (int i = 0; i < pathsCount; i++) { Spline spline = new Spline(); spline.Ts = 0.0f; spline.Tf = 1.0f; spline.Data = paths.GetPathAt(i); Wacom.Ink.Serialization.Model.Path will3Path = new Wacom.Ink.Serialization.Model.Path(Identifier.FromNewGuid(), spline, style, layoutXYZS, Identifier.Empty); PathNode pathNode = new PathNode(Identifier.FromNewGuid(), will3Path); root.Add(pathNode); } return(will3Doc); }
public PipelineData AddWholePath(Spline path, PathPointLayout layout, Wacom.Ink.Geometry.VectorBrush vectorBrush) { var splineInterpolator = new CurvatureBasedInterpolator(layout); var brushApplier = new BrushApplier(layout, vectorBrush); var points = splineInterpolator.Add(true, true, path, null); var polys = brushApplier.Add(true, true, points.Addition, points.Prediction); var hulls = mConvexHullChainProducer.Add(true, true, polys.Addition, polys.Prediction); var merged = mPolygonMerger.Add(true, true, hulls.Addition, hulls.Prediction); return(new PipelineData(polys, merged)); }
public void UpdatePipeline(PathPointLayout layout, Calculator calculator, float spacing) { bool layoutChanged = false; bool otherChange = false; if ((Layout == null) || (layout.ChannelMask != Layout.ChannelMask)) { Layout = layout; layoutChanged = true; } if (mPathProducer == null || calculator != mPathProducer.PathPointCalculator || layoutChanged) { mPathProducer = new PathProducer(Layout, calculator, true); otherChange = true; } if (mSmoothingFilter == null || layoutChanged) { mSmoothingFilter = new SmoothingFilter(Layout.Count) { KeepAllData = true }; otherChange = true; } if (SplineProducer == null || layoutChanged) { SplineProducer = new SplineProducer(Layout, true); otherChange = true; } if (SplineInterpolator == null || layoutChanged) { SplineInterpolator = new DistanceBasedInterpolator(Layout, spacing, splitCount, true, true, true); otherChange = true; } ((DistanceBasedInterpolator)SplineInterpolator).Spacing = spacing; if (layoutChanged || otherChange) { LayoutUpdated?.Invoke(this, EventArgs.Empty); } }
private void EncodeCurrentStrokeCommon(string pointerDeviceType, InkBuilder inkBuilder, Style style) { // Create the ink input provider using the pointer device type InkInputProvider inkInputProvider = CreateAndAddInkProvider(pointerDeviceType); // Create the input device using EasClientDeviceInformation or any other class providing relevant info InputDevice inputDevice = CreateAndAddInputDevice(); // Create the sensor context SensorContext sensorContext = CreateAndAddSensorContext(inkInputProvider, inputDevice); // Create the input context using the environment and the sensor context Identifier inputContextId = CreateAndAddInputContext(sensorContext.Id); // Create sensor data using the input context SensorData sensorData = new SensorData( Identifier.FromNewGuid(), inputContextId, Wacom.Ink.Serialization.InkState.Plane); // Get the sensor data from the ink builders List <PointerData> pointerDataList = inkBuilder.GetPointerDataList(); // Fill the default channels with the sensor data FillDefaultChannels(sensorData, sensorContext, pointerDataList); InkDocument.SensorData.Add(sensorData); Spline spline = inkBuilder.SplineProducer.AllData; PathPointLayout layout = inkBuilder.Layout; Stroke stroke = new Stroke( Identifier.FromNewGuid(), spline.Clone(), style, layout, sensorData.Id); StrokeNode strokeNode = new StrokeNode(Identifier.FromNewGuid(), stroke); InkDocument.InkTree.Root.Add(strokeNode); }
private void EncodeStrokeCommon(Identifier id, Spline spline, PathPointLayout layout, Identifier sensorDataId, Style style) { Stroke stroke = new Stroke( id, spline.Clone(), style, layout, sensorDataId); StrokeNode strokeNode = new StrokeNode(Identifier.FromNewGuid(), stroke); InkDocument.InkTree.Root.Add(strokeNode); if (sensorDataId != Identifier.Empty) { SensorData sensorData = mSensorDataMap[sensorDataId]; AddSensorDataToModel(sensorData); } }
public static Spline TransformSplineXY(Spline spline, PathPointLayout layout, Matrix3x2 matrix3x2) { var transformedSpline = spline.Clone(); int xIndex = layout.IndexOf(PathPoint.Property.X); int yIndex = layout.IndexOf(PathPoint.Property.Y); for (int i = 0; i < transformedSpline.Data.Count; i += layout.Count) { int xCurIndex = xIndex + i; int yCurIndex = yIndex + i; Vector2 position = new Vector2(transformedSpline.Data[xCurIndex], transformedSpline.Data[yCurIndex]); Vector2 transformed = Vector2.Transform(position, matrix3x2); transformedSpline.Data[xCurIndex] = transformed.X; transformedSpline.Data[yCurIndex] = transformed.Y; } return(transformedSpline); }
public ProcessorResult <List <float> > AddWholePath(List <float> path, float spacing, PathPointLayout layout) { if (path.Count == 0) { throw new Exception("Path has no points!"); } SplineInterpolator = new DistanceBasedInterpolator(layout, spacing, splitCount, true, true); var iterpolatedPoints = SplineInterpolator.Add(true, true, new Spline(layout.ChannelMask, path), new Spline(layout.ChannelMask)); return(iterpolatedPoints); }
public void UpdatePipeline(PathPointLayout layout, Calculator calculator, VectorBrush brush) { bool layoutChanged = false; if ((Layout == null) || (layout.ChannelMask != Layout.ChannelMask)) { Layout = layout; layoutChanged = true; } if (mPathProducer == null || calculator != mPathProducer.PathPointCalculator || layoutChanged) { mPathProducer = new PathProducer(Layout, calculator) { KeepAllData = true }; } if (mSmoothingFilter == null || layoutChanged) { mSmoothingFilter = new SmoothingFilter(Layout.Count) { KeepAllData = true }; } if (SplineProducer == null || layoutChanged) { SplineProducer = new SplineProducer(Layout) { KeepAllData = true }; } if (SplineInterpolator == null || layoutChanged) { SplineInterpolator = new CurvatureBasedInterpolator(Layout) { KeepAllData = true }; } if (BrushApplier == null || (brush != BrushApplier.Prototype) || layoutChanged) { BrushApplier = new BrushApplier(Layout, brush) { KeepAllData = true }; } if (ConvexHullChainProducer == null) { ConvexHullChainProducer = new ConvexHullChainProducer() { KeepAllData = true }; } if (mPolygonMerger == null) { mPolygonMerger = new PolygonMerger() { KeepAllData = true }; } if (PolygonSimplifier == null) { PolygonSimplifier = new PolygonSimplifier(0.1f) { KeepAllData = true }; } }