// Update is called once per frame public void Render() { var isOpen = controller.sampler && controller.sampler.activePoints.Contains(point); var minDist = controller.sampler ? controller.sampler.minimumDistance : .5f; var radius = (isOpen ? .10f : .05f) * minDist; var hue = Mathf.PingPong(index * .01f, 1); var saturation = controller.renderColorized ? 1 : 0; var color = Color.HSVToRGB(hue, saturation, isOpen ? .5f : 1); var outlineColor = Color.HSVToRGB(0, 0, .8f); GeometryDraw.Clear(gameObject); GeometryDraw.DrawCircle(gameObject, point.x, point.y, radius, color, 0, .6f); if (controller.renderRadius) { GeometryDraw.DrawCircle(gameObject, point.x, point.y, minDist, outlineColor, 8, 0.2f); GeometryDraw.DrawCircle(gameObject, point.x, point.y, minDist - .02f, ColorSettings.instance.background, 1.5f, 0.2f); } GeometryDraw.Finalize(gameObject); lastOpenState = isOpen; }
void Update() { if (animateProgress) { time += Time.deltaTime * animationSpeed * animationSpeed; progress = Mathf.PingPong(time, 1); } var ad = Vector2.Lerp(a, d, progress); var ab = Vector2.Lerp(a, b, progress); var bc = Vector2.Lerp(b, c, progress); var cd = Vector2.Lerp(c, d, progress); var bd = Vector2.Lerp(b, d, progress); var abbc = Vector2.Lerp(ab, bc, progress); var bccd = Vector2.Lerp(bc, cd, progress); var abbd = Vector2.Lerp(ab, bd, progress); var abbcbccd = Vector2.Lerp(abbc, bccd, progress); GeometryDraw.Clear(gameObject); GeometryDraw.DrawCircle(gameObject, a.x, a.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierPrimaryLine, 0, 1f); GeometryDraw.DrawCircle(gameObject, d.x, d.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierPrimaryLine, 0, 1f); // draw simple lerp line if (drawSimpleLine) { GeometryDraw.DrawLine(gameObject, new [] { a, d }, ColorSettings.instance.bezierSimpleLerpThickness, ColorSettings.instance.bezierPrimaryLine); } // draw simple lerp dot if (drawSimpleLerp) { GeometryDraw.DrawCircle(gameObject, ad.x, ad.y, ColorSettings.instance.bezierSimpleLerpDotSize, ColorSettings.instance.bezierHandle, 0, 1f); } if (drawCubicHandle) { GeometryDraw.DrawCircle(gameObject, b.x, b.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierSecondaryHandle, 0, 1f); } if (drawCubicOutline) { GeometryDraw.DrawLine(gameObject, new[] { a, b }, ColorSettings.instance.bezierSecondaryLineThickness, ColorSettings.instance.bezierSecondaryLine, 1); GeometryDraw.DrawLine(gameObject, new[] { b, d }, ColorSettings.instance.bezierSecondaryLineThickness, ColorSettings.instance.bezierSecondaryLine, 1); } if (drawCubicLerps) { GeometryDraw.DrawCircle(gameObject, ab.x, ab.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierTertiaryLine, 0, 1f); GeometryDraw.DrawCircle(gameObject, bd.x, bd.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierTertiaryLine, 0, 1f); } if (drawCubicLines) { GeometryDraw.DrawLine(gameObject, new[] { ab, bd }, ColorSettings.instance.bezierTertiaryLineThickness, ColorSettings.instance.bezierTertiaryLine); } if (drawCubicCurveDot) { GeometryDraw.DrawCircle(gameObject, abbd.x, abbd.y, .1f, ColorSettings.instance.bezierCurve, -1f, 1f); } if (drawCubicCurve) { DrawCubicBezier(64, ColorSettings.instance.bezierCurveThickness, ColorSettings.instance.bezierCurveHandle); } // draw handles if (drawQuadraticHandles) { GeometryDraw.DrawCircle(gameObject, b.x, b.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierSecondaryHandle, 0, 1f); GeometryDraw.DrawCircle(gameObject, c.x, c.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierSecondaryHandle, 0, 1f); } // draw bezier lines if (drawQuadraticOutline) { GeometryDraw.DrawLine(gameObject, new[] { a, b }, ColorSettings.instance.bezierSecondaryLineThickness, ColorSettings.instance.bezierSecondaryLine, 1); GeometryDraw.DrawLine(gameObject, new[] { b, c }, ColorSettings.instance.bezierSecondaryLineThickness, ColorSettings.instance.bezierSecondaryLine, 1); GeometryDraw.DrawLine(gameObject, new[] { c, d }, ColorSettings.instance.bezierSecondaryLineThickness, ColorSettings.instance.bezierSecondaryLine, 1); } if (drawQuadraticLerps) { GeometryDraw.DrawCircle(gameObject, ab.x, ab.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierTertiaryLine, 0, 1f); GeometryDraw.DrawCircle(gameObject, bc.x, bc.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierTertiaryLine, 0, 1f); GeometryDraw.DrawCircle(gameObject, cd.x, cd.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierTertiaryLine, 0, 1f); } // draw bezier interpolation lines if (drawQuadraticSecondOrderLines) { GeometryDraw.DrawLine(gameObject, new[] { ab, bc }, ColorSettings.instance.bezierTertiaryLineThickness, ColorSettings.instance.bezierTertiaryLine); GeometryDraw.DrawLine(gameObject, new[] { bc, cd }, ColorSettings.instance.bezierTertiaryLineThickness, ColorSettings.instance.bezierTertiaryLine); } if (drawQuadraticThirdOrderHandles) { GeometryDraw.DrawCircle(gameObject, abbc.x, abbc.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierQuaternaryLine, 0, 1f); GeometryDraw.DrawCircle(gameObject, bccd.x, bccd.y, ColorSettings.instance.bezierHandleDotSize, ColorSettings.instance.bezierQuaternaryLine, 0, 1f); } if (drawQuadraticThirdOrderLines) { GeometryDraw.DrawLine(gameObject, new[] { abbc, bccd }, ColorSettings.instance.bezierQuarternaryLineThickness, ColorSettings.instance.bezierQuaternaryLine); } // draw bezier dot if (drawQuadraticCurveDot) { GeometryDraw.DrawCircle(gameObject, abbcbccd.x, abbcbccd.y, .1f, ColorSettings.instance.bezierCurve, -1, 1f); } // draw bezier curve if (drawQuadraticCurve) { DrawQuadraticBezier(64, ColorSettings.instance.bezierCurveThickness, ColorSettings.instance.bezierCurveHandle); } GeometryDraw.Finalize(gameObject); if (Input.GetMouseButtonDown(0)) { GrabHandle(); } else if (grabbedHandleIndex >= 0 && Input.GetMouseButton(0)) { MoveHandle(); } else { ReleaseHandle(); } }