#reader(lib "htdp-beginner-reader.ss" "lang")((modname clock-img) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
(require 2htdp/image)
(define (max-dimension background)
(max (image-width background) (image-height background)))
(define (minutes->angle mins)
(* -6 mins))
(define (hour->angle hour mins)
(floor (* -30 (+ hour (/ mins 60)))))
(define (make-12oclock-hand radius arm-prop tip-prop color frame?)
(place-image/align
(above (isosceles-triangle (* tip-prop radius) 50 "solid" color)
(isosceles-triangle (* arm-prop radius) 350 "solid" color))
radius radius "middle" "bottom"
(circle radius "outline" (if frame? "black" (make-color 0 0 0 0)))))
(define (make-12oclock-big-hand background color frame?)
(make-12oclock-hand (/ (max-dimension background) 2) .8 .16 color frame?))
(define (make-12oclock-small-hand background color frame?)
(make-12oclock-hand (/ (max-dimension background) 2) .4 .08 color frame?))
(define (time-clock background hour minutes hour-color min-color frame?)
(overlay/align "left" "middle"
(rotate (minutes->angle minutes)
(make-12oclock-big-hand background min-color frame?))
(rotate (hour->angle hour minutes)
(make-12oclock-small-hand background hour-color frame?))
background))
(require (planet nah22/racketui))
(require (planet nah22/racketui/common))
(web-launch
"Clock Image Generator"
(function "Generates an image of a clock on a background of your choice (should be round'ish)."
(time-clock ["Background image" image]
["Hour" number]
["Minutes" number]
["Hour hand color" color/web]
["Minute hand color" color/web]
["Draw outside frame" boolean]
-> ["Clock image" image])))