// Use this for initialization void Start() { if (path == null) { path = "Paints/paing.png"; } start = none; end = start; press = start; currentStamp = stamp; boardSize = gameObject.GetComponent <RectTransform>(); SetBoard(); brushSetting = new ECBrush[6]; brushSetting[0] = new ECBrush(ECBrush.Tool.Pen, 6, 0.75f, Color.black); brushSetting[1] = new ECBrush(ECBrush.Tool.Eraser, 12, 0.9f, Color.black); brushSetting[2] = new ECBrush(ECBrush.Tool.Line, 3, 0.9f, Color.black); brushSetting[3] = new ECBrush(ECBrush.Tool.Rectangle, 3, 0.75f, Color.black); brushSetting[4] = new ECBrush(ECBrush.Tool.Ellipse, 3, 0.75f, Color.black); if (stamp == null) { brushSetting[5] = new ECBrush(ECBrush.Tool.Stamp, 6, 0.75f, Color.white); } else { brushSetting[5] = new ECBrush(ECPainting.ScaleTexture(stamp, 10), 10, 0.75f, Color.white); } SetECBrush(); }
public ECBrush(Tool tool, int size, float hardness, Color color) { this.tool = tool; this.size = size; this.hardness = hardness; this.color = color; stamp = new ECPainting(Color.clear, size * 2 + 17, size * 2 + 17); Outline(); }
public ECBrush(ECPainting stamp, int size, float hardness, Color color) { this.tool = Tool.Stamp; this.size = size; this.hardness = hardness; this.color = color; this.stamp = stamp; ColorChange(color); Outline(); }
public ECBrush(Texture2D texture, int size, float hardness, Color color) { this.tool = Tool.Stamp; this.size = size; this.hardness = hardness; this.color = color; ECPainting stamp = new ECPainting(texture); this.stamp = stamp; ColorChange(color); Outline(); }
public void SetBoard() { currentBG = bg; if (bg != null) { paint = new ECPainting(bg, boardSize.sizeDelta.x, boardSize.sizeDelta.y); } else { paint = new ECPainting(boardSize.sizeDelta.x, boardSize.sizeDelta.y); } board.texture = paint.texture; preview.texture = paint.preview; }
public void SetECBrush(int tool) { if (tool == this.tool) { brushSetting[tool] = new ECBrush(brushSetting[tool].tool, brush.size, brush.hardness, brush.color); } if (stamp != currentStamp) { currentStamp = stamp; brushSetting[5] = new ECBrush(ECPainting.ScaleTexture(stamp, brushSetting[5].size), brushSetting[5].size, brushSetting[5].hardness, brushSetting[5].color); } if (tool < 0) { tool = 0; } this.tool = tool; brush = brushSetting[tool]; brushOutline.texture = brush.outline; brushOutline.GetComponent <RectTransform>().sizeDelta = new Vector2(brush.width, brush.height); Reset(); }
public void Paint(bool isECBrush) { if (brush.tool == ECBrush.Tool.Pen || brush.tool == ECBrush.Tool.Eraser) { paint.Draw(start, end, brush); } else if (brush.tool == ECBrush.Tool.Stamp) { paint.FillStamp(end, brush); } else if (brush.tool == ECBrush.Tool.Line) { Vector2[] pos = new Vector2[2]; pos[0] = ECPainting.LockPoint(press, end); pos[1] = ECPainting.LockPoint(press, start); if (isShift) { paint.Line(press, pos[1], Color.clear); if (isECBrush) { paint.Line(press, pos[0], brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.Line(press, pos[0], 10); } else { paint.Line(press, end, 10); } } else { paint.Line(press, start, Color.clear); if (isECBrush) { paint.Line(press, end, brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.Line(press, end, 10); } else { paint.Line(press, pos[0], 10); } } } else if (brush.tool == ECBrush.Tool.Rectangle) { if (isShift) { paint.StrokeRect(ECPainting.TwoPointSquare(press, start), Color.clear); if (isECBrush) { paint.StrokeRect(ECPainting.TwoPointSquare(press, end), brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.StrokeRect(ECPainting.TwoPointSquare(press, end), 10); } else { paint.StrokeRect(ECPainting.TwoPointRect(press, end), 10); } } else { paint.StrokeRect(ECPainting.TwoPointRect(press, start), Color.clear); if (isECBrush) { paint.StrokeRect(ECPainting.TwoPointRect(press, end), brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.StrokeRect(ECPainting.TwoPointRect(press, end), 10); } else { paint.StrokeRect(ECPainting.TwoPointSquare(press, end), 10); } } } else if (brush.tool == ECBrush.Tool.Ellipse) { if (isShift) { paint.StrokeEllipse(ECPainting.TwoPointCircle(press, start).ellipse, Color.clear); if (isECBrush) { paint.StrokeCircle(ECPainting.TwoPointCircle(press, end), brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.StrokeEllipse(ECPainting.TwoPointCircle(press, end).ellipse, 10); } else { paint.StrokeEllipse(ECPainting.TwoPointEllipse(press, end), 10); } } else { paint.StrokeEllipse(ECPainting.TwoPointEllipse(press, start), Color.clear); if (isECBrush) { paint.StrokeEllipse(ECPainting.TwoPointEllipse(press, end), brush); } else if (Input.GetKey(KeyCode.LeftShift) == isShift) { paint.StrokeEllipse(ECPainting.TwoPointEllipse(press, end), 10); } else { paint.StrokeEllipse(ECPainting.TwoPointCircle(press, end).ellipse, 10); } } } if (!isECBrush) { paint.Preview(); } else { paint.Apply(); paint.Done(); } }