public bool OnTouchBegan(DrawingSurface surface, Touch touch) { Line line = FindOrCreateLine(touch.Identifier); line.OnTouchBegan(surface, m_Color, touch, m_Options); return(true); }
/// <summary> /// Called by the <see cref="LineDrawingTool" /> when the touch associated with this line begins on the <see cref="DrawingSurface" />. /// </summary> public void OnTouchBegan(DrawingSurface surface, Color color, Touch touch, LineOptions options) { // get position Vector2 position = CameraUtils.TouchToWorldPoint(touch, surface.Transform, surface.Camera); position = surface.Transform.parent.InverseTransformPoint(position); // reset points m_Points = m_Points ?? new LinePoint[16]; m_PointCount = 0; m_SmoothPoints = m_SmoothPoints ?? new LinePoint[1024]; m_SmoothPointCount = 0; // reset m_Cap.Reset(options.Overdraw); m_Segment.Reset(options.Overdraw); m_Velocity.Reset(position, options.VelocityMin, options.VelocityMax, options.VelocitySmoothing); // add point LinePoint point = default(LinePoint); point.Color = color; point.Position = position; point.Weight = Mathf.Lerp(options.WeightMin, options.WeightMax, m_Velocity.Factor); AddPoint(point); // set flags m_IsDirty = true; m_CapRequired = true; }
/// <summary> /// Called by the <see cref="LineDrawingTool" /> when the touch associated with this line moves on the <see cref="DrawingSurface" />. /// </summary> public void OnTouchMoved(DrawingSurface surface, Color color, Touch touch, LineOptions options) { // get position Vector2 position = CameraUtils.TouchToWorldPoint(touch, surface.Transform, surface.Camera); position = surface.Transform.parent.InverseTransformPoint(position); // update m_Velocity.Update(position); // add point LinePoint point = default(LinePoint); point.Color = color; point.Position = position; point.Weight = Mathf.Lerp(options.WeightMin, options.WeightMax, m_Velocity.Factor); AddPoint(point); }
public void OnRender(DrawingSurface surface) { Debug.AssertFormat(surface != null, "Cannot render to surface: {0}", "surface is null"); Debug.AssertFormat(surface.RenderTexture != null, "Cannot render to surface: {0}", "render texture is null"); Debug.AssertFormat(Material != null, "Cannot render to surface: {0}", "material is null"); Geometry.Reset(); foreach (Line line in Lines.Values) { line.OnRender(m_Geometry, m_Options); } Geometry.CopyToMesh(Mesh); Matrix4x4 matrix = surface.Camera.transform.localToWorldMatrix; matrix.m23 = surface.transform.position.z; surface.Invoke(() => { surface.RenderTexture.MarkRestoreExpected(); Material.SetPass(0); Graphics.DrawMeshNow(Mesh, matrix, 0); }); }
public void OnTouchCancelled(DrawingSurface surface, Touch touch) { OnTouchEnded(surface, touch); }
public void OnTouchEnded(DrawingSurface surface, Touch touch) { Line line = FindLine(touch.Identifier); line.OnTouchEnded(surface, m_Color, touch, m_Options); }