public void Draw(GuiWidget sender, IObject3D item, bool isSelected, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world) { if (isSelected && scene.DrawSelection) { var frustum = world.GetClippingFrustum(); var selectionColor = Color.White; double secondsSinceSelectionChanged = (UiThread.CurrentTimerMs - lastSelectionChangedMs) / 1000.0; if (secondsSinceSelectionChanged < .5) { var accentColor = Color.LightGray; if (secondsSinceSelectionChanged < .25) { selectionColor = Color.White.Blend(accentColor, Quadratic.InOut(secondsSinceSelectionChanged * 4)); } else { selectionColor = accentColor.Blend(Color.White, Quadratic.InOut((secondsSinceSelectionChanged - .25) * 4)); } guiWidget.Invalidate(); } this.RenderSelection(item, frustum, selectionColor, world); } }
public static float CalculateLerpValueClamp01(float lerpValue, Type easingType, bool isZeroToOne) { switch (easingType) { case Type.Linear: lerpValue = Linear.InOut(lerpValue); break; case Type.Quadratic: lerpValue = Quadratic.InOut(lerpValue); break; case Type.Cubic: lerpValue = Cubic.InOut(lerpValue); break; case Type.Quartic: lerpValue = Quartic.InOut(lerpValue); break; case Type.Quintic: lerpValue = Quintic.InOut(lerpValue); break; case Type.Sinusoidal: lerpValue = Sinusoidal.InOut(lerpValue); break; case Type.Exponential: lerpValue = Exponential.InOut(lerpValue); break; case Type.Circular: lerpValue = Circular.InOut(lerpValue); break; case Type.Elastic: lerpValue = Elastic.InOut(lerpValue); break; case Type.Back: lerpValue = Back.InOut(lerpValue); break; case Type.Bounce: lerpValue = Bounce.InOut(lerpValue); break; default: return(-1f); } lerpValue = ClampMinMax(0f, 1f, lerpValue); return(lerpValue); }
public void InOut_InputAboveRange_ReturnsDestination() { Ease ease = new Quadratic(); float x = 1.5f; float expected = ease.Scale.Y; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
public void InOut_InputBelowRange_ReturnsOrigin() { Ease ease = new Quadratic(); float x = -0.5f; float expected = 0; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
public void InOut_InputInRange2_ReturnsExpectedValue() { Ease ease = new Quadratic(); float x = 0.4f; float expected = 0.32f; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
public void InOut_ChangedScaleInputAboveRange_ReturnsDestination() { Vector scale = new Vector(4, 6); Ease ease = new Quadratic(scale); float x = 11.1f; float expected = ease.Scale.Y; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
public void InOut_ChangedScaleInputBelowRange_ReturnsOrigin() { Vector scale = new Vector(4, 6); Ease ease = new Quadratic(scale); float x = -1.1f; float expected = 0; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
public void InOut_ChangedScaleInputInRange2_ReturnsExpectedValue() { Vector scale = new Vector(4, 6); Ease ease = new Quadratic(scale); float x = 1.5f; float expected = 1.688f; float actual = ease.InOut(x); Assert.AreEqual(expected, actual, 0.001f); }
private void ChangeBackgroundColor() { if (widgetToHighlight != null) { double time = GetFadeInOutPulseRatio(timeSinceStart.Elapsed.TotalSeconds, pulseTime); double lightnessMultiplier = Quadratic.InOut(time); widgetToHighlight.BackgroundColor = startColor.AdjustLightness(1 + lightnessChange * lightnessMultiplier).ToColor(); if (widgetToHighlight.HasBeenClosed || timeSinceStart.Elapsed.TotalSeconds > cycles * pulseTime) { widgetToHighlight.BackgroundColor = startColor; widgetToHighlight.AfterDraw -= ConnectToWidget; RunningAttentions.Remove(widgetToHighlight); widgetToHighlight = null; return; } } }
//------------------------------------------------------------------------------------------------------------ public static float GetEasingFunction(Type easingFunction, float t) { // Quad if (easingFunction == Type.EaseInQuad) { return(Quadratic.In(t)); } if (easingFunction == Type.EaseOutQuad) { return(Quadratic.Out(t)); } if (easingFunction == Type.EaseInOutQuad) { return(Quadratic.InOut(t)); } // Cubic if (easingFunction == Type.EaseInCubic) { return(Cubic.In(t)); } if (easingFunction == Type.EaseOutCubic) { return(Cubic.Out(t)); } if (easingFunction == Type.EaseInOutCubic) { return(Cubic.InOut(t)); } // Quart if (easingFunction == Type.EaseInQuart) { return(Quartic.In(t)); } if (easingFunction == Type.EaseOutQuart) { return(Quartic.Out(t));; } if (easingFunction == Type.EaseInOutQuart) { return(Quartic.InOut(t));; } // Quint if (easingFunction == Type.EaseInQuint) { return(Quintic.In(t)); } if (easingFunction == Type.EaseOutQuint) { return(Quintic.Out(t)); } if (easingFunction == Type.EaseInOutQuint) { return(Quintic.InOut(t)); } // Sine if (easingFunction == Type.EaseInSine) { return(Sinusoidal.In(t)); } if (easingFunction == Type.EaseOutSine) { return(Sinusoidal.Out(t)); } if (easingFunction == Type.EaseInOutSine) { return(Sinusoidal.InOut(t)); } // Expo if (easingFunction == Type.EaseInExpo) { return(Exponential.In(t)); } if (easingFunction == Type.EaseOutExpo) { return(Exponential.Out(t)); } if (easingFunction == Type.EaseInOutExpo) { return(Exponential.InOut(t)); } // CirC if (easingFunction == Type.EaseInCirc) { return(Circular.In(t)); } if (easingFunction == Type.EaseOutCirc) { return(Circular.Out(t)); } if (easingFunction == Type.EaseInOutCirc) { return(Circular.InOut(t)); } // Linear if (easingFunction == Type.Linear) { return(Linear(t)); } // Bounce if (easingFunction == Type.EaseInBounce) { return(Bounce.In(t)); } if (easingFunction == Type.EaseOutBounce) { return(Bounce.Out(t)); } if (easingFunction == Type.EaseInOutBounce) { return(Bounce.InOut(t)); } // Back if (easingFunction == Type.EaseInBack) { return(Back.In(t)); } if (easingFunction == Type.EaseOutBack) { return(Back.Out(t)); } if (easingFunction == Type.EaseInOutBack) { return(Back.InOut(t)); } // Elastic if (easingFunction == Type.EaseInElastic) { return(Elastic.In(t)); } if (easingFunction == Type.EaseOutElastic) { return(Elastic.Out(t)); } if (easingFunction == Type.EaseInOutElastic) { return(Elastic.InOut(t)); } return(0); }
private void DrawObject(IObject3D object3D, List <Object3DView> transparentMeshes, bool parentSelected, DrawEventArgs e) { foreach (var item in object3D.VisibleMeshes()) { // check for correct persistable rendering if (MeshViewerWidget.ViewOnlyTexture != null && item.Mesh.Faces.Count > 0) { ImageBuffer faceTexture = null; item.Mesh.FaceTexture.TryGetValue((item.Mesh.Faces[0], 0), out faceTexture); bool hasPersistableTexture = faceTexture == MeshViewerWidget.ViewOnlyTexture; if (item.WorldPersistable()) { if (hasPersistableTexture) { // make sure it does not have the view only texture item.Mesh.RemoveTexture(ViewOnlyTexture, 0); } } else { if (!hasPersistableTexture) { // make sure it does have the view only texture var aabb = item.Mesh.GetAxisAlignedBoundingBox(); var matrix = Matrix4X4.CreateScale(.5, .5, 1); matrix *= Matrix4X4.CreateRotationZ(MathHelper.Tau / 8); item.Mesh.PlaceTexture(ViewOnlyTexture, matrix); } } } Color drawColor = GetItemColor(item); bool isDebugItem = (item == scene.DebugItem); if (!sceneContext.ViewState.ModelView) { if (modelRenderStyle == ModelRenderStyle.WireframeAndSolid) { drawColor = gCodeMeshColor; } else if (modelRenderStyle == ModelRenderStyle.None) { drawColor = Color.Transparent; } } if ((drawColor.alpha == 255 && !item.Mesh.FaceTexture.Where((ft) => ft.Value.HasTransparency).Any()) || isDebugItem) { // Render as solid GLHelper.Render(item.Mesh, drawColor, item.WorldMatrix(), sceneContext.ViewState.RenderType, item.WorldMatrix() * World.ModelviewMatrix, darkWireframe); } else if (drawColor != Color.Transparent) { // Queue for transparency transparentMeshes.Add(new Object3DView(item, drawColor)); } var selectedItem = scene.SelectedItem; bool isSelected = selectedItem != null && (selectedItem.DescendantsAndSelf().Any((i) => i == item) || selectedItem.Parents <ModifiedMeshObject3D>().Any((mw) => mw == item)); if (isSelected && scene.DrawSelection) { var frustum = World.GetClippingFrustum(); var selectionColor = Color.White; double secondsSinceSelectionChanged = (UiThread.CurrentTimerMs - lastSelectionChangedMs) / 1000.0; if (secondsSinceSelectionChanged < .5) { //var accentColor = ApplicationController.Instance.Theme.Colors.PrimaryAccentColor; var accentColor = Color.LightGray; if (secondsSinceSelectionChanged < .25) { selectionColor = Color.White.Blend(accentColor, Quadratic.InOut(secondsSinceSelectionChanged * 4)); } else { selectionColor = accentColor.Blend(Color.White, Quadratic.InOut((secondsSinceSelectionChanged - .25) * 4)); } Invalidate(); } RenderSelection(item, frustum, selectionColor); } #if DEBUG if (isDebugItem) { var frustum = World.GetClippingFrustum(); var aabb = object3D.GetAxisAlignedBoundingBox(Matrix4X4.Identity); World.RenderAabb(aabb, Matrix4X4.Identity, debugBorderColor, 1); if (item.Mesh != null) { GLHelper.Render(item.Mesh, debugBorderColor, item.WorldMatrix(), RenderTypes.Wireframe, item.WorldMatrix() * World.ModelviewMatrix); } } #endif // RenderNormals(renderData); // turn lighting back on after rendering selection outlines GL.Enable(EnableCap.Lighting); } }
public static float GetTerpedPosition(float time, float totalTime, Function function, Direction direction) { switch (function) { case Function.Quadratic: switch (direction) { case Direction.In: return(Quadratic.In(time / totalTime)); case Direction.Out: return(Quadratic.Out(time / totalTime)); default: return(Quadratic.InOut(time / totalTime)); } case Function.Cubic: switch (direction) { case Direction.In: return(Cubic.In(time / totalTime)); case Direction.Out: return(Cubic.Out(time / totalTime)); default: return(Cubic.InOut(time / totalTime)); } case Function.Quartic: switch (direction) { case Direction.In: return(Quartic.In(time / totalTime)); case Direction.Out: return(Quartic.Out(time / totalTime)); default: return(Quartic.InOut(time / totalTime)); } case Function.Quintic: switch (direction) { case Direction.In: return(Quintic.In(time / totalTime)); case Direction.Out: return(Quintic.Out(time / totalTime)); default: return(Quintic.InOut(time / totalTime)); } case Function.Sinusoidal: switch (direction) { case Direction.In: return(Sinusoidal.In(time / totalTime)); case Direction.Out: return(Sinusoidal.Out(time / totalTime)); default: return(Sinusoidal.InOut(time / totalTime)); } case Function.Exponential: switch (direction) { case Direction.In: return(Exponential.In(time / totalTime)); case Direction.Out: return(Exponential.Out(time / totalTime)); default: return(Exponential.InOut(time / totalTime)); } case Function.Circular: switch (direction) { case Direction.In: return(Circular.In(time / totalTime)); case Direction.Out: return(Circular.Out(time / totalTime)); default: return(Circular.InOut(time / totalTime)); } case Function.Elastic: switch (direction) { case Direction.In: return(Elastic.In(time / totalTime)); case Direction.Out: return(Elastic.Out(time / totalTime)); default: return(Elastic.InOut(time / totalTime)); } case Function.Back: switch (direction) { case Direction.In: return(Back.In(time / totalTime)); case Direction.Out: return(Back.Out(time / totalTime)); default: return(Back.InOut(time / totalTime)); } default: //Function.Bounce: switch (direction) { case Direction.In: return(Bounce.In(time / totalTime)); case Direction.Out: return(Bounce.Out(time / totalTime)); default: return(Bounce.InOut(time / totalTime)); } } }
public static float Ease(EasingType easingFunction, float k) { switch (easingFunction) { case EasingType.Linear: return(Linear(k)); case EasingType.QuadraticIn: return(Quadratic.In(k)); case EasingType.QuadraticOut: return(Quadratic.Out(k)); case EasingType.QuadraticInOut: return(Quadratic.InOut(k)); case EasingType.CubicIn: return(Cubic.In(k)); case EasingType.CubicOut: return(Cubic.Out(k)); case EasingType.CubicInOut: return(Cubic.InOut(k)); case EasingType.QuarticIn: return(Quartic.In(k)); case EasingType.QuarticOut: return(Quartic.Out(k)); case EasingType.QuarticInOut: return(Quartic.InOut(k)); case EasingType.QuinticIn: return(Quintic.In(k)); case EasingType.QuinticOut: return(Quintic.Out(k)); case EasingType.QuinticInOut: return(Quintic.InOut(k)); case EasingType.SinusoidalIn: return(Sinusoidal.In(k)); case EasingType.SinusoidalOut: return(Sinusoidal.Out(k)); case EasingType.SinusoidalInOut: return(Sinusoidal.InOut(k)); case EasingType.ExponentialIn: return(Exponential.In(k)); case EasingType.ExponentialOut: return(Exponential.Out(k)); case EasingType.ExponentialInOut: return(Exponential.InOut(k)); case EasingType.CircularIn: return(Circular.In(k)); case EasingType.CircularOut: return(Circular.Out(k)); case EasingType.CircularInOut: return(Circular.InOut(k)); case EasingType.ElasticIn: return(Elastic.In(k)); case EasingType.ElasticOut: return(Elastic.Out(k)); case EasingType.ElasticInOut: return(Elastic.InOut(k)); case EasingType.BackIn: return(Back.In(k)); case EasingType.BackOut: return(Back.Out(k)); case EasingType.BackInOut: return(Back.InOut(k)); case EasingType.BounceIn: return(Bounce.In(k)); case EasingType.BounceOut: return(Bounce.Out(k)); case EasingType.BounceInOut: return(Bounce.InOut(k)); default: return(Linear(k)); } }
public static double Specify(EaseType easeType, EaseOption easeOption, double k) { switch (easeType) { case EaseType.Quadratic: switch (easeOption) { case EaseOption.In: return(Quadratic.In(k)); case EaseOption.Out: return(Quadratic.Out(k)); case EaseOption.InOut: return(Quadratic.InOut(k)); } break; case EaseType.Cubic: switch (easeOption) { case EaseOption.In: return(Cubic.In(k)); case EaseOption.Out: return(Cubic.Out(k)); case EaseOption.InOut: return(Cubic.InOut(k)); } break; case EaseType.Quartic: switch (easeOption) { case EaseOption.In: return(Quartic.In(k)); case EaseOption.Out: return(Quartic.Out(k)); case EaseOption.InOut: return(Quartic.InOut(k)); } break; case EaseType.Quintic: switch (easeOption) { case EaseOption.In: return(Quintic.In(k)); case EaseOption.Out: return(Quintic.Out(k)); case EaseOption.InOut: return(Quintic.InOut(k)); } break; case EaseType.Sinusoidal: switch (easeOption) { case EaseOption.In: return(Sinusoidal.In(k)); case EaseOption.Out: return(Sinusoidal.Out(k)); case EaseOption.InOut: return(Sinusoidal.InOut(k)); } break; } return(Linear(k)); }