public void HandleMultiTouch(FTouch[] touches) { foreach(FTouch touch in touches) { if (touch.phase == TouchPhase.Ended) { if (_draw!=null) { _draw.Flush(); } } else if (touch.phase == TouchPhase.Began) { if (_draw!=null) { _draw.RemoveFromContainer(); _draw=null; } _draw=new FDrawingSprite("Futile_White"); AddChild(_draw); _draw.SetLineThickness(RXRandom.Range(4f,10f)); Color color=RandomUtils.RandomColor(); color.a=1f; _draw.SetLineColor(color); _draw.PushBorder (RXRandom.Range(2f,5f),RandomUtils.RandomColor(),RXRandom.Float()<0.5f?true:false); _draw.PushTopBorder (RXRandom.Range(2f,5f),RandomUtils.RandomColor(),RXRandom.Float()<0.5f?true:false); //_draw.PushBorder (4,new Color(1f,1f,0f,1f),false); if (RXRandom.Float()<0.5f) { _draw.PushBorder (RXRandom.Range(1f,4f),RandomUtils.RandomColor(),RXRandom.Float()<0.5f?true:false); if (RXRandom.Float()<0.5f) { _draw.PushBorder (RXRandom.Range(1f,4f),RandomUtils.RandomColor(),RXRandom.Float()<0.5f?true:false); if (RXRandom.Float()<0.5f) { _draw.PushBorder (RXRandom.Range(1f,4f),RandomUtils.RandomColor(),RXRandom.Float()<0.5f?true:false); } } } _draw.MoveTo(touch.position.x,touch.position.y); } else if (touch.phase == TouchPhase.Moved) { if (_draw==null) return; _draw.LineTo(touch.position.x,touch.position.y); } } }
public static void LineAngle(Vector2 start, float angle, float length, Color color, float thickness) { FDrawingSprite _draw=new FDrawingSprite("Draw_Pixel_White"); SpriteBatch.AddChild(_draw); _draw.SetLineThickness(thickness); //_draw.SetLineColor(new Color(1,0,1,0.5f)); _draw.SetLineCapStyle(FTDrawingCapStyle.NONE); _draw.SetLineJointStyle(FTDrawingJointStyle.MITER); _draw.MoveTo(start.x, start.y); Vector2 dest = new Vector2(start.x + length * Mathf.Cos(angle) - length * Mathf.Sin(angle), start.y + length * Mathf.Sin(angle) + length * Mathf.Cos(angle)); _draw.LineTo(dest.x, dest.y); _draw.Flush(); // Stop the line, add caps //SpriteBatch.Draw(Pixel, start, Pixel.sourceRect, color, angle, new Vector2(0, .5f), new Vector2(length, thickness), SpriteEffects.None, 0); }
public static void Line(Vector2 start, Vector2 end, Color color, float thickness) { FDrawingSprite _draw=new FDrawingSprite("Draw_Pixel_White"); SpriteBatch.AddChild(_draw); _draw.SetLineThickness(1); //_draw.SetLineColor(new Color(1,0,1,0.5f)); _draw.SetLineCapStyle(FTDrawingCapStyle.NONE); _draw.SetLineJointStyle(FTDrawingJointStyle.MITER); //_draw.MoveTo(start.x + Mathf.Cos(angle) - Mathf.Sin(angle), start.y + Mathf.Sin(angle) + Mathf.Cos(angle)); //Vector2 dest = new Vector2(start.x + length * Mathf.Cos(angle) - length * Mathf.Sin(angle), start.y + length * Mathf.Sin(angle) + length * Mathf.Cos(angle)); //_draw.LineTo(dest.x, dest.y); _draw.MoveTo(start.x, start.y); _draw.LineTo(end.x, end.y); _draw.Flush(); // Stop the line, add caps //LineAngle(start, Vector2.Angle(start, end), Vector2.Distance(start, end), color, thickness); }