희미한 시계

6221 단어 guidesktoprubydsl
Glimmer DSL for SWT 4.20.15.1(JRuby 데스크탑 개발 GUI 프레임워크)은 Glimmer Clock elaborate sample과 함께 제공됩니다.



암호:

# 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


해피Glimmering !

좋은 웹페이지 즐겨찾기