Skip to content

AnimationExtensions

Namespace: Hex1b

Assembly: Hex1b.dll

Extension methods for animation and timed redraws.

csharp
public static class AnimationExtensions

Inheritance

ObjectAnimationExtensions

Methods

RedrawAfter<TWidget>(TWidget, int)

Requests a redraw of this widget after the specified delay in milliseconds.

Parameters:

  • widget (<TWidget>): The widget to redraw.
  • milliseconds (Int32): The delay in milliseconds before redrawing. Clamped to minimum of 16ms (60 FPS cap).

Returns: <TWidget>

The widget with the redraw delay set.

csharp
public static TWidget RedrawAfter<TWidget>(this TWidget widget, int milliseconds) where TWidget : Hex1bWidget

RedrawAfter<TWidget>(TWidget, TimeSpan)

Requests a redraw of this widget after the specified delay.

Parameters:

  • widget (<TWidget>): The widget to redraw.
  • delay (TimeSpan): The delay before redrawing. Clamped to minimum of 16ms (60 FPS cap).

Returns: <TWidget>

The widget with the redraw delay set.

csharp
public static TWidget RedrawAfter<TWidget>(this TWidget widget, TimeSpan delay) where TWidget : Hex1bWidget

Remarks

These methods enable widgets to request periodic redraws for animations. Timers are one-shot - for continuous animation, call one of the RedrawAfter methods on each widget tree build.

Examples

csharp
// Animate at ~20 FPS
ctx.Surface(s => [...])
    .RedrawAfter(TimeSpan.FromMilliseconds(50))

// Or using milliseconds shorthand
ctx.Surface(s => [...])
    .RedrawAfter(50)

Released under the MIT License.