private void LoopScribbleTool(CallbackLoopScribbleTool callback) { for (int i = 0; i < _listScribbleTool.Count; i++) { ScribbleTool tool = _listScribbleTool[i]; callback.Invoke(tool); } }
public void Init(BeardModelHandler model) { _toolScribble = GetComponent <ScribbleTool>(); _toolScribble.Init(new RenderTexturePainter[] { model._beardFrontPainter, model._beardMiddlePainter, model._beardBackPainter }, null); _toolCollider = GetComponent <ColliderTool>(); _toolCollider.Init(new GameObject[] { model._beardMessy, model._beardRed, model._beardScar }); _model = model; ToolScribble.OnToolStart.AddListener(OnToolStart); ToolScribble.OnToolEnd.AddListener(OnToolEnd); }
public void Init(BeardModelHandler model) { _toolCollider = GetComponent <ColliderTool>(); _toolCollider.Init(new GameObject[] { model._beardMessy }); _toolScribble = GetComponent <ScribbleTool>(); _toolScribble.Init(); _markScissorLeftRotate = _scissorLeft.localEulerAngles; _markScissorRightRotate = _scissorRight.localEulerAngles; _model = model; ToolCollider.OnToolStart.AddListener(OnToolStart); ToolCollider.OnToolEnd.AddListener(OnToolEnd); }
private void HandleUpdate(int index, bool isSuccess, SpriteData data) { if (data._targetType == TargetType.DragonBones) { } else if (data._targetType == TargetType.UIMask) { } else if (data._targetType == TargetType.ScribbleTool) { ScribbleTool scribbleTool = data._targetScribbleTool; if (scribbleTool._operation == ScribbleTool.Operation.Replace) { scribbleTool.UpdateTexture(data._obj as Texture2D); } } }
public void Init(BeardModelHandler model) { _toolScribble = GetComponent <ScribbleTool>(); _toolScribble.Init(new RenderTexturePainter[] { model._hairMainPainter, model._hairTempPainter }, null); List <SpriteHandler.SpriteData> listSpriteData = new List <SpriteHandler.SpriteData>(); //string url = "Beard/Dye/" + model.gameObject.name + "/{0}.png"; //listSpriteData.Add(new SpriteHandler.SpriteData(_toolScribble, _formatUrl, "", SpriteHandler.LoadType.StreamingAsset)); string url = string.Format("{0}/{1}_{2}_dye.unity3d", AppConst.AppName, AppConst.AppName, model.gameObject.name).ToLower(); string fileName = "{0}.png"; listSpriteData.Add(new SpriteHandler.SpriteData(_toolScribble, url, fileName, SpriteHandler.LoadType.AssetBundle)); _spriteHandler = GetComponent <SpriteHandler>(); _spriteHandler.Init(listSpriteData); _model = model; ToolScribble.OnToolStart.AddListener(OnToolStart); ToolScribble.OnToolEnd.AddListener(OnToolEnd); }
public void Init(BeardModelHandler model) { _toolScribble = GetComponent <ScribbleTool>(); RenderTexturePainter[] arrayPainter = null; if (_shape == Shape.Round) { arrayPainter = new RenderTexturePainter[] { model._beardFrontPainter, model._beardMiddlePainter }; } else if (_shape == Shape.Sharp) { arrayPainter = new RenderTexturePainter[] { model._beardFrontPainter }; } _toolScribble.Init(arrayPainter, null); _toolCollider = GetComponent <ColliderTool>(); _toolCollider.Init(new GameObject[] { model._beardMessy }); _model = model; ToolScribble.OnToolStart.AddListener(OnToolStart); ToolScribble.OnToolEnd.AddListener(OnToolEnd); }
public void Init(BeardModelHandler model) { _toolScribble = GetComponent <ScribbleTool>(); _toolScribble.Init(null, new PainterChecker[] { model._beardBubbleChecker }); _model = model; }
public IToolContext CreateToolContext() { var editorToolContext = new EditorToolContext() { ContainerFactory = this }; var hitTest = new HitTest(); var tools = new ObservableCollection <ITool>(); var noneTool = new NoneTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = false, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } }, new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = false, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } } }, Settings = new NoneToolSettings() }; var selectionTool = new SelectionTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = false, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new SelectionToolSettings() { Mode = SelectionMode.Point | SelectionMode.Shape, Targets = SelectionTargets.Shapes, SelectionModifier = Modifier.Control, ConnectionModifier = Modifier.Shift, SelectionStyle = "Selection", ClearSelectionOnClean = false, HitTestRadius = 7.0, ConnectPoints = true, ConnectTestRadius = 10.0, DisconnectPoints = true, DisconnectTestRadius = 10.0 } }; var pointTool = new PointTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new PointToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var lineTool = new LineTool() { Intersections = new ObservableCollection <IPointIntersection> { new LineLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new LineLineSettings() { IsEnabled = true } }, new RectangleLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new RectangleLineSettings() { IsEnabled = true } }, new EllipseLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new EllipseLineSettings() { IsEnabled = true } } }, Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new LineToolSettings() { ConnectPoints = true, HitTestRadius = 7.0, SplitIntersections = false } }; var polyLineTool = new PolyLineTool() { Intersections = new ObservableCollection <IPointIntersection> { new LineLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new LineLineSettings() { IsEnabled = true } }, new RectangleLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new RectangleLineSettings() { IsEnabled = true } }, new EllipseLineIntersection() { Intersections = new ObservableCollection <IPointShape>(), Settings = new EllipseLineSettings() { IsEnabled = true } } }, Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new PolyLineToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var cubicBezierTool = new CubicBezierTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new CubicBezierToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var quadraticBezierTool = new QuadraticBezierTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new QuadraticBezierToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var conicTool = new ConicTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new ConicToolSettings() { ConnectPoints = true, HitTestRadius = 7.0, Weight = 1.0 } }; var pathTool = new PathTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new PathToolSettings() { ConnectPoints = true, HitTestRadius = 7.0, FillType = PathFillType.Winding, IsFilled = true, IsClosed = true } }; pathTool.Settings.Tools = new ObservableCollection <ITool> { new LineTool(), new CubicBezierTool(), new QuadraticBezierTool(), new ConicTool(), new MoveTool(pathTool) }; pathTool.Settings.CurrentTool = pathTool.Settings.Tools[0]; var scribbleTool = new ScribbleTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = false, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new ScribbleToolSettings() { Simplify = true, Epsilon = 1.0, FillType = PathFillType.Winding, IsFilled = false, IsClosed = false } }; var rectangleTool = new RectangleTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new RectangleToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var ellipseTool = new EllipseTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new EllipseToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var textTool = new TextTool() { Intersections = new ObservableCollection <IPointIntersection>(), Filters = new ObservableCollection <IPointFilter> { new GridSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = "Guide" } }, new LineSnapPointFilter() { Guides = new ObservableCollection <IBaseShape>(), Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = "Guide" } } }, Settings = new TextToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; void SetToolDefaults(ITool tool) { tool.CurrentIntersection = tool.Intersections.Count > 0 ? tool.Intersections[0] : null; tool.CurrentFilter = tool.Filters.Count > 0 ? tool.Filters[0] : null; } SetToolDefaults(noneTool); SetToolDefaults(selectionTool); SetToolDefaults(pointTool); SetToolDefaults(lineTool); SetToolDefaults(polyLineTool); SetToolDefaults(cubicBezierTool); SetToolDefaults(quadraticBezierTool); SetToolDefaults(conicTool); SetToolDefaults(pathTool); SetToolDefaults(scribbleTool); SetToolDefaults(rectangleTool); SetToolDefaults(ellipseTool); SetToolDefaults(textTool); tools.Add(noneTool); tools.Add(selectionTool); tools.Add(pointTool); tools.Add(lineTool); tools.Add(polyLineTool); tools.Add(cubicBezierTool); tools.Add(quadraticBezierTool); tools.Add(conicTool); tools.Add(pathTool); tools.Add(scribbleTool); tools.Add(rectangleTool); tools.Add(ellipseTool); tools.Add(textTool); editorToolContext.Selection = selectionTool; editorToolContext.HitTest = hitTest; editorToolContext.CurrentDirectory = null; editorToolContext.Files = new ObservableCollection <string>(); editorToolContext.StyleLibrary = null; editorToolContext.GroupLibrary = null; var pointTemplate = new RectangleShape(new PointShape(-4, -4, null), new PointShape(4, 4, null)) { Points = new ObservableCollection <IPointShape>(), Text = new Text(), StyleId = "PointTemplate" }; pointTemplate.StartPoint.Owner = pointTemplate; pointTemplate.Point.Owner = pointTemplate; editorToolContext.PointTemplate = pointTemplate; editorToolContext.ContainerViews = new ObservableCollection <IContainerView>(); editorToolContext.ContainerView = null; editorToolContext.Tools = tools; editorToolContext.CurrentTool = selectionTool; editorToolContext.EditMode = EditMode.Mouse; return(editorToolContext); }
public LayerContainerViewModel CreateDemoViewModel() { var hitTest = new HitTest(); hitTest.Register(new PointHitTest()); hitTest.Register(new LineHitTest()); hitTest.Register(new CubicBezierHitTest()); hitTest.Register(new QuadraticBezierHitTest()); hitTest.Register(new GroupHitTest()); hitTest.Register(new PathHitTest()); hitTest.Register(new RectangleHitTest()); hitTest.Register(new EllipseHitTest()); hitTest.Register(new TextHitTest()); var gridSnapPointFilter = new GridSnapPointFilter() { Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = new ShapeStyle(new ArgbColor(128, 0, 255, 255), new ArgbColor(128, 0, 255, 255), 2.0, true, true) } }; var lineSnapPointFilter = new LineSnapPointFilter() { Settings = new LineSnapSettings() { IsEnabled = true, EnableGuides = false, Target = LineSnapTarget.Guides | LineSnapTarget.Shapes, Mode = LineSnapMode.Point | LineSnapMode.Middle | LineSnapMode.Nearest | LineSnapMode.Intersection | LineSnapMode.Horizontal | LineSnapMode.Vertical, Threshold = 10.0, GuideStyle = new ShapeStyle(new ArgbColor(128, 0, 255, 255), new ArgbColor(128, 0, 255, 255), 2.0, true, true) } }; var tools = new ObservableCollection <ToolBase>(); var noneTool = new NoneTool() { Settings = new NoneToolSettings() }; var selectionTool = new SelectionTool() { Filters = new List <PointFilter> { new GridSnapPointFilter() { Settings = new GridSnapSettings() { IsEnabled = true, EnableGuides = false, Mode = GridSnapMode.Horizontal | GridSnapMode.Vertical, GridSizeX = 15.0, GridSizeY = 15.0, GuideStyle = new ShapeStyle(new ArgbColor(128, 0, 255, 255), new ArgbColor(128, 0, 255, 255), 2.0, true, true) } } }, Settings = new SelectionToolSettings() { Mode = SelectionMode.Point | SelectionMode.Shape, Targets = SelectionTargets.Shapes | SelectionTargets.Guides, SelectionModifier = Modifier.Control, ConnectionModifier = Modifier.Shift, SelectionStyle = new ShapeStyle(new ArgbColor(255, 0, 120, 215), new ArgbColor(60, 170, 204, 238), 2.0, true, true), ClearSelectionOnClean = false, HitTestRadius = 7.0, ConnectPoints = true, ConnectTestRadius = 10.0, DisconnectPoints = true, DisconnectTestRadius = 10.0 } }; var guideTool = new GuideTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new GuideToolSettings() { GuideStyle = new ShapeStyle(new ArgbColor(128, 0, 255, 255), new ArgbColor(128, 0, 255, 255), 2.0, true, true) } }; var pointTool = new PointTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new PointToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var lineTool = new LineTool() { Intersections = new List <PointIntersection> { new LineLineIntersection() { Settings = new LineLineSettings() { IsEnabled = true } }, new RectangleLineIntersection() { Settings = new RectangleLineSettings() { IsEnabled = true } }, new EllipseLineIntersection() { Settings = new EllipseLineSettings() { IsEnabled = true } } }, Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new LineToolSettings() { ConnectPoints = true, HitTestRadius = 7.0, SplitIntersections = false } }; var polyLineTool = new PolyLineTool() { Intersections = new List <PointIntersection> { new LineLineIntersection() { Settings = new LineLineSettings() { IsEnabled = true } }, new RectangleLineIntersection() { Settings = new RectangleLineSettings() { IsEnabled = true } }, new EllipseLineIntersection() { Settings = new EllipseLineSettings() { IsEnabled = true } } }, Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new PolyLineToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var cubicBezierTool = new CubicBezierTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new CubicBezierToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var quadraticBezierTool = new QuadraticBezierTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new QuadraticBezierToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var pathTool = new PathTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new PathToolSettings() { ConnectPoints = true, HitTestRadius = 7.0, FillRule = PathFillRule.EvenOdd, IsFilled = true, IsClosed = true } }; pathTool.Settings.Tools = new ObservableCollection <ToolBase> { new LineTool(), new CubicBezierTool(), new QuadraticBezierTool(), new MoveTool(pathTool) }; pathTool.Settings.CurrentTool = pathTool.Settings.Tools[0]; var scribbleTool = new ScribbleTool() { Filters = new List <PointFilter> { lineSnapPointFilter }, Settings = new ScribbleToolSettings() { Simplify = true, Epsilon = 1.0, FillRule = PathFillRule.EvenOdd, IsFilled = false, IsClosed = false } }; var rectangleTool = new RectangleTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new RectangleToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var ellipseTool = new EllipseTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new EllipseToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; var textTool = new TextTool() { Filters = new List <PointFilter> { lineSnapPointFilter, gridSnapPointFilter }, Settings = new TextToolSettings() { ConnectPoints = true, HitTestRadius = 7.0 } }; tools.Add(noneTool); tools.Add(selectionTool); tools.Add(guideTool); tools.Add(pointTool); tools.Add(lineTool); tools.Add(polyLineTool); tools.Add(cubicBezierTool); tools.Add(quadraticBezierTool); tools.Add(pathTool); tools.Add(scribbleTool); tools.Add(rectangleTool); tools.Add(ellipseTool); tools.Add(textTool); var currentTool = tools.FirstOrDefault(t => t.Title == "Selection"); var presenter = new DefaultShapePresenter() { Helpers = new Dictionary <Type, ShapeHelper> { { typeof(PointShape), new PointHelper() }, { typeof(LineShape), new LineHelper() }, { typeof(CubicBezierShape), new CubicBezierHelper() }, { typeof(QuadraticBezierShape), new QuadraticBezierHelper() }, { typeof(PathShape), new PathHelper() }, { typeof(RectangleShape), new RectangleHelper() }, { typeof(EllipseShape), new EllipseHelper() }, { typeof(TextShape), new TextHelper() } } }; return(new LayerContainerViewModel() { Tools = tools, CurrentTool = currentTool, Mode = EditMode.Mouse, Presenter = presenter, Renderer = null, HitTest = hitTest, CurrentContainer = null, WorkingContainer = null, CurrentStyle = null, PointShape = null, Capture = null, Release = null, Invalidate = null, Reset = null, AutoFit = null, StretchNone = null, StretchFill = null, StretchUniform = null, StretchUniformToFill = null }); }
public SpriteData(ScribbleTool target, string formatUrl, string fileName, LoadType loadType, bool isReadable = false, bool isKeepLastAsset = false, bool isAutoShowAfterUpdate = true) { _targetScribbleTool = target; _targetType = TargetType.ScribbleTool; Init(formatUrl, fileName, loadType, isReadable, isKeepLastAsset, isAutoShowAfterUpdate); }
private void InitPainterAndChecker(RenderTexturePainter[] arrayPainter = null, PainterChecker[] arrayChecker = null) { _listPainter.Clear(); RenderTexturePainter[] arrayTempPainter = _arrayPainter; if (null != arrayPainter) { arrayTempPainter = _arrayPainter.Concat(arrayPainter).ToArray(); } for (int i = 0; i < arrayTempPainter.Length; i++) { _listPainter.Add(arrayTempPainter[i]); } if (_operation == Operation.Erase && true == _isCleanOtherPaintTool) { _listScribbleTool.Clear(); for (int i = 0; i < _arrayScribbleTool.Length; i++) { ScribbleTool tool = _arrayScribbleTool[i]; for (int j = 0; j < tool.ListPainter.Count; j++) { _listPainter.Add(tool.ListPainter[j]); } _listScribbleTool.Add(tool); } } if (_operation == Operation.Replace && _listPainter.Count == 2) { RenderTexturePainter mainPainter = _listPainter[0]; RenderTexturePainter tempPainter = _listPainter[1]; if (false == mainPainter.IsInited) { mainPainter.Init(); } tempPainter.SourceTex = mainPainter.SourceTex; } LoopPainter((RenderTexturePainter painter) => { if (false == painter.IsInited) { painter.Init(); } UpdatePainterSetting(painter); if (false == painter._isShowSource) { painter.ResetCanvas(); } PainterChecker checker = painter.GetComponent <PainterChecker>(); if (null != checker) { checker.Init(); checker.SetDataByTexture(painter.SourceTex.ToTexture2D(), painter._penTex, painter._brushScale, 0); _listChecker.Add(checker); _dicCheckerIndex.Add(painter, _listChecker.IndexOf(checker)); } }); PainterChecker[] arrayTempChecker = _arrayChecker; if (null != arrayChecker) { arrayTempChecker = _arrayChecker.Concat(arrayChecker).ToArray(); } for (int i = 0; i < arrayTempChecker.Length; i++) { PainterChecker checker = arrayTempChecker[i]; checker.Init(); _listChecker.Add(checker); } }