Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Shimmer

Shimmer creates an independent animation where each character is coloured based on its position in a sweeping gradient wave.

Shimmer demo

// Default gradient
clog.Shimmer("Indexing documents").
  Wait(ctx, action).
  Msg("Indexed")

// Custom gradient with direction
clog.Shimmer("Synchronizing",
  clog.ColorStop{Position: 0, Color: colorful.Color{R: 0.3, G: 0.3, B: 0.8}},
  clog.ColorStop{Position: 0.5, Color: colorful.Color{R: 1, G: 1, B: 1}},
  clog.ColorStop{Position: 1, Color: colorful.Color{R: 0.3, G: 0.3, B: 0.8}},
).
  ShimmerDirection(clog.DirectionMiddleIn).
  Wait(ctx, action).
  Msg("Synchronized")

Use DefaultShimmerGradient() to get the default gradient stops.

Directions

ConstantDescription
DirectionRightLeft to right (default)
DirectionLeftRight to left
DirectionMiddleInInward from both edges
DirectionMiddleOutOutward from the center
DirectionBounceInInward from both edges, then bounces out
DirectionBounceOutOutward from center, then bounces in

Shimmer directions

Speed

Control how fast the animation cycles with Speed(cyclesPerSecond). The default is 0.5 (one full cycle every two seconds) for both Shimmer and Pulse. Values ≤ 0 are treated as the default.

clog.Shimmer("Fast shimmer").
  Speed(2.0).  // 2 gradient cycles per second
  Wait(ctx, action).
  Msg("Done")

clog.Pulse("Quick pulse").
  Speed(1.5).  // 1.5 oscillations per second
  Wait(ctx, action).
  Msg("Done")

Both pulse and shimmer use ColorStop for gradient definitions:

type ColorStop struct {
  Position float64        // 0.0-1.0
  Color    colorful.Color // from github.com/lucasb-eyer/go-colorful
}