DEV Community

Cover image for Glimmer Clock
Andy Maleh
Andy Maleh

Posted on

1 1

Glimmer Clock

Glimmer DSL for SWT 4.20.15.1 (JRuby Desktop Development GUI Framework) shipped with a Glimmer Clock elaborate sample.

Glimmer Clock

Code:

# From: https://github.com/AndyObtiva/glimmer-dsl-swt/blob/master/docs/reference/GLIMMER_SAMPLES.md#clock

class Clock
  include Glimmer::UI::CustomShell

  body {
    shell {
      text 'Glimmer Clock'
      minimum_size 400, 430

      canvas {
        initial_time = Time.now
        background :black

        animation {
          every 0.01 # every hundredth of a second to ensure higher accuracy

          frame { |index|
            time = Time.now

            oval(0, 0, 400, 400) {
              background :white
            }
            polygon(-5, -5, 180, 0, -5, 5) {
              background :black

              transform {
                translate 200, 200
                rotate(time.sec*6 - 90)
              }
            }
            polygon(-5, -5, 135, 0, -5, 5) {
              background :dark_gray

              transform {
                translate 200, 200
                rotate(time.min*6 - 90)
              }
            }
            polygon(-5, -5, 90, 0, -5, 5) {
              background :gray

              transform {
                translate 200, 200
                rotate((time.hour - 12)*30 - 90)
              }
            }
          }
        }
      }
    }
  }
end

Clock.launch
Enter fullscreen mode Exit fullscreen mode

Happy Glimmering!

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay