List <Vector2> DrawLine(Vector2 _start, Vector2 _end, float _thickness, bool reverseDrawOrder = false) { List <Vector2> _points = new List <Vector2>(); Vector2 direction = (_end - _start).normalized; direction = ShapesMath.Rotate90CW(direction); _points.Add(_start + (direction * _thickness)); _points.Add(_end + (direction * _thickness)); if (reverseDrawOrder) { _points.Reverse(); } return(_points); }
// Draws a circle/arc List <Vector2> GetCircle(float _radius, float _angRadStart, float _angRadEnd, bool flip = false, bool reverseDrawOrder = false) { List <Vector2> points = new List <Vector2>(); // Account for negative from thiccness if (_radius < 0) { _radius = 0; } float angle = -_angRadStart; float arcLength = Mathf.Clamp(Mathf.Abs(_angRadEnd - _angRadStart), 0, 2 * Mathf.PI); int direction = (int)Mathf.Sign(_angRadEnd - _angRadStart) * (flip == true?-1:1); int stepCount; if (flexible) { stepCount = Mathf.Max(Mathf.FloorToInt((arcLength / qualityLevel) * (flexWithRadius == true && _radius > 1?_radius:1)), 2); } else { stepCount = fixedCount; } for (int i = 0; i <= stepCount; i++) { float x = Mathf.Sin(angle) * _radius; float y = Mathf.Cos(angle) * _radius; Vector2 point = new Vector2(x, y); //Rotate so 0 rad = right point = ShapesMath.Rotate90CW(point); points.Add(point); // Add angle step evenly spaced for length in arc angle += (arcLength / stepCount) * -direction; } // Reverse draw order for connecting inner/outer rings if (reverseDrawOrder) { points.Reverse(); } return(points); }