scenic_clock v0.8.0 Scenic.Clock.Components View Source

A set of helper functions to make it easy to add, or modify, clocks to a graph.

Link to this section Summary

Functions

Add an analog clock to a graph

Add an digital clock to a graph

Link to this section Functions

Link to this function analog_clock(graph, options \\ []) View Source

Add an analog clock to a graph.

There is no required data, only styles.

Styles

Analog Clocks honor the following styles

  • :hidden - If false the clock is rendered. If true, it is skipped. The default is false.
  • :theme - The color set used to draw. See below. The default is :dark

Additional Styles

Analog clocks honor the following list of additional styles.

  • :radius - the radius of the clock’s main circle.
  • :timezone - which timezone to display the time in. Should be one of the timezones supported by the Timex Hex package. See Timex.timezones(). The default is whatever Timex says is the system timezone.
  • :seconds - true or false. Show the seconds hand. Note: Showing the seconds hand uses more energy by rendering the scene every second. The default is false.
  • :ticks - true or false. Show ticks marking the hour positions. Default is true if the radius is >= 30.

Theme

To pass in a custom theme, supply a map with at least the following entries:

  • :border - the color of the ring around the clock
  • :background - the normal background of the clock

The following theme colors are optional. If they are not supplied, :border will be used.

  • :hours - the color of the hours hand
  • :minutes - the color of the minutes hand
  • :seconds - the color of the seconds hand

Examples

The following example creates an analog clock it on the screen.

graph
|> analog_clock( translate: {20, 20} )

The next example makes the same clock as before, but shows the seconds hand.

graph
|> analog_clock( seconds: true, translate: {20, 20} )
Link to this function digital_clock(graph, options \\ []) View Source

Add an digital clock to a graph.

There is no required data, only configuration options.

Styles

Digital Clocks honors all the styles you would expect to render text.

Additional Styles

Digital clocks honor the following list of additional styles.

  • :timezone - which timezone to display the time in. Should be one of the timezones supported by the Timex Hex package. See Timex.timezones(). The default is whatever Timex sais is the system timexone.
  • :format - strftime format for the time string. Default is "%a %l:%M %p".

Theme

The Digital clock does not use the current theme for coloring. Add a :fill style instead, just as you would for a text primitive.

Examples

The following example creates an analog clock it on the screen.

graph
|> digital_clock( translate: {20, 20} )