public void PopulateMesh(VertexHelper vh, Matrix4x4 viewMatrix, Rect viewBounds) { if (showHandles) { var bounds = MathUtils.CenterSizeRect(position, 2 * Vector2.one * (_pointRadius + _pointSkin)); bounds = bounds.Encapsulate(MathUtils.CenterSizeRect(position + _inHandlePosition, 2 * Vector2.one * (_handleRadius + _handleSkin))); bounds = bounds.Encapsulate(MathUtils.CenterSizeRect(position + _outHandlePosition, 2 * Vector2.one * (_handleRadius + _handleSkin))); if (!viewBounds.Overlaps(bounds)) { return; } } else { if (!viewBounds.Overlaps(new Rect(position - Vector2.one * _pointRadius, 2 * Vector2.one * _pointRadius))) { return; } } if (showHandles) { vh.AddLine(position, position + _outHandlePosition, _handleThickness, lineColor, viewMatrix); vh.AddLine(position, position + _inHandlePosition, _handleThickness, lineColor, viewMatrix); } vh.AddCircle(position, _pointRadius, pointColor, viewMatrix); if (showHandles) { vh.AddCircle(position + _outHandlePosition, _handleRadius, outHandleColor, viewMatrix); vh.AddCircle(position + _inHandlePosition, _handleRadius, inHandleColor, viewMatrix); } }
private void PopulateGrid(VertexHelper vh, Rect viewBounds, CurveLine line) { if (line == null) { return; } var viewMin = viewBounds.min; var viewMax = viewBounds.max; var cellSize = GetGridCellSize(line, viewBounds); var minX = Mathf.Floor(viewMin.x / cellSize.x) * cellSize.x; var maxX = Mathf.Ceil(viewMax.x / cellSize.x) * cellSize.x; var minY = Mathf.Floor(viewMin.y / cellSize.y) * cellSize.y; var maxY = Mathf.Ceil(viewMax.y / cellSize.y) * cellSize.y; if ((maxX - minX) / cellSize.x < 100) { for (var x = minX; x <= maxX; x += cellSize.x) { vh.AddLine(new Vector2(x, viewMin.y), new Vector2(x, viewMax.y), 0.01f, _gridColor, _viewMatrix); } } if ((maxY - minY) / cellSize.x < 100) { for (var y = minY; y <= maxY; y += cellSize.y) { vh.AddLine(new Vector2(viewMin.x, y), new Vector2(viewMax.x, y), 0.01f, _gridColor, _viewMatrix); } } if (viewMin.y < 0 && viewMax.y > 0) { vh.AddLine(new Vector2(viewMin.x, 0), new Vector2(viewMax.x, 0), 0.04f, _girdAxisColor, _viewMatrix); } if (viewMin.x < 0 && viewMax.x > 0) { vh.AddLine(new Vector2(0, viewMin.y), new Vector2(0, viewMax.y), 0.04f, _girdAxisColor, _viewMatrix); } }
public void PopulateScrubberLine(VertexHelper vh, Matrix4x4 viewMatrix, Rect viewBounds, float x) { var min = _drawScale.inverse.Multiply(viewBounds.min); var max = _drawScale.inverse.Multiply(viewBounds.max); if (x < min.x || x > max.x) { return; } vh.AddLine(_drawScale.Multiply(new Vector2(x, min.y)), _drawScale.Multiply(new Vector2(x, max.y)), 0.02f, Color.black, viewMatrix); }
public void PopulateMesh(VertexHelper vh, Matrix4x4 viewMatrix, Rect viewBounds) { var min = _drawScale.inverse.Multiply(viewBounds.min); var max = _drawScale.inverse.Multiply(viewBounds.max); var curvePoints = new Vector2[evaluateCount]; for (var i = 0; i < evaluateCount; i++) { var x = Mathf.Lerp(min.x, max.x, (float)i / (evaluateCount - 1)); var y = curve.Evaluate(x); curvePoints[i] = _drawScale.Multiply(new Vector2(x, y)); } vh.AddLine(curvePoints, thickness, _colors.lineColor, viewMatrix); foreach (var point in points) { point.PopulateMesh(vh, viewMatrix, viewBounds); } }