Author Topic: Clock variation one billion and something....  (Read 4091 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Clock variation one billion and something....
« on: February 29, 2020, 11:24:03 am »
This type of watch had a unique hand style.  No doubt someone can make it prettier. 
Comment out the  $EXEICON to skip downloading the attachment.

Code: QB64: [Select]
  1. _TITLE "Wittnauer Watch"
  2. $EXEICON:'c1.ico'
  3.  
  4. DEFINT A-Z
  5. q = 31000: z = 10
  6. DIM g1(q), g2(q), hx(z), hy(z), r!(z), p(13, 4)
  7. FOR n = 0 TO 10
  8.     READ g$
  9.     FOR i = 0 TO 4
  10.         READ z
  11.         p(n, i) = z * 4096
  12.     NEXT i
  13.  
  14. SCREEN 12 '                                      640*480*16
  15. FOR i = 5 TO 15 '                                make shades of red
  16.     p& = i * 4 + 3
  17.     PALETTE i, p&
  18. p& = CDBL(30) * 256 '                            green, less bright than default
  19. PALETTE 2, p&
  20. q = 32 '                                         background
  21. p& = 65536 * CDBL(q) + 256 * CDBL(q) + q
  22. PALETTE 4, p&
  23. CLS , 4
  24. pi! = 4 * ATN(1): lm = -1
  25. hc = 10: mc = 2: sc = 1 '                        colors hour, minute, second
  26. xc = 320: yc = 220 '                             center
  27. FOR a = 0 TO 360 STEP 6 '                        clock face
  28.     x2 = xc + 192 * SIN(_D2R(a))
  29.     y2 = yc - 192 * COS(_D2R(a))
  30.     IF (a MOD 30) = 0 THEN '                     hour
  31.         FOR d = 0 TO 10
  32.             CIRCLE (x2, y2), d, 15 - d
  33.             CIRCLE (x2 + 1, y2), d, 15 - d
  34.         NEXT d
  35.     ELSE '                                       minute or second
  36.         CIRCLE (x2, y2), 1, 1
  37.         PSET (x2, y2), 1
  38.     END IF
  39. s = 175
  40. nx1 = xc - s: nx2 = xc + s
  41. ny1 = yc - s: ny2 = yc + s
  42. GET (nx1, ny1)-(nx2, ny2), g1(0)
  43.     t$ = TIME$
  44.     GOSUB timetext
  45.     IF lm > -1 THEN PUT (nx1, ny1), g2(0), PSET
  46.     m = VAL(MID$(t$, 4, 2))
  47.     IF m <> lm THEN
  48.         PUT (nx1, ny1), g1(0), PSET
  49.         h = VAL(MID$(t$, 1, 2)): h = h + (h > 12) * 12
  50.         a = (h + m / 60) * 30 - 90: r! = _D2R(a): GOSUB hour
  51.         a = m * 6 - 90: r! = _D2R(a): GOSUB minute
  52.         lm = m: GET (nx1, ny1)-(nx2, ny2), g2(0)
  53.     END IF
  54.     a = VAL(MID$(t$, 7, 2)) * 6 - 90: r! = _D2R(a): GOSUB second
  55.     DO: _LIMIT 10
  56.         i$ = INKEY$
  57.         IF i$ = CHR$(27) THEN SYSTEM
  58.     LOOP UNTIL t$ <> TIME$
  59. second:
  60. tx = xc + 170 * COS(r!)
  61. ty = yc + 170 * SIN(r!)
  62. FOR ta2! = a - 4 TO a + 4 STEP .25
  63.     r! = _D2R(ta2! + 180)
  64.     x = xc + 45 * COS(r!)
  65.     y = yc + 45 * SIN(r!)
  66.     LINE (tx, ty)-(x, y), sc
  67.     LINE (tx, ty)-(x + 1, y), sc
  68. NEXT ta2!
  69. r! = r! + pi!
  70. tx = xc - 70 * COS(r!)
  71. ty = yc - 70 * SIN(r!)
  72. FOR ta2! = a + 5 TO a + 16 STEP .25
  73.     x = xc - 40 * COS(_D2R(ta2!))
  74.     y = yc - 40 * SIN(_D2R(ta2!))
  75.     LINE (tx, ty)-(x, y), sc
  76. NEXT ta2!
  77. minute:
  78. FOR ta2! = a - 4 TO a STEP .25
  79.     x = xc + 130 * COS(_D2R(ta2!))
  80.     y = yc + 130 * SIN(_D2R(ta2!))
  81.     LINE (xc, yc)-(x, y), mc
  82.     LINE (xc + 1, yc)-(x, y), mc
  83.     LINE (xc, yc)-(x + 1, y), mc
  84. NEXT ta2!
  85. tx = xc + 160 * COS(r!)
  86. ty = yc + 160 * SIN(r!)
  87. FOR ta2! = a TO a + 6 STEP .25
  88.     x = xc + 120 * COS(_D2R(ta2!))
  89.     y = yc + 120 * SIN(_D2R(ta2!))
  90.     LINE (tx, ty)-(x, y), mc
  91.     LINE (tx + 1, ty)-(x, y), mc
  92.     LINE (tx, ty)-(x + 1, y), mc
  93. NEXT ta2!
  94. FOR x = 1 TO 8
  95.     IF x > 6 THEN tc = mc ELSE tc = 0
  96.     CIRCLE (xc, yc), x, tc
  97.     CIRCLE (xc + 1, yc), x, tc
  98.     CIRCLE (xc, yc + 1), x, tc
  99. hour:
  100. FOR c = 0 TO 1 '                                 near and far of diamond, 0 and 2
  101.     i = c * 2
  102.     r!(i) = _D2R(a)
  103.     hx(i) = xc + (100 + (c - .5) * 70) * COS(r!(i))
  104.     hy(i) = yc + (100 + (c - .5) * 70) * SIN(r!(i))
  105. FOR c = 0 TO 1 ' edges of diamond, 1 and 3
  106.     i = 1 + c * 2
  107.     r!(i) = _D2R(a + (c - .5) * 10)
  108.     hx(i) = xc + 100 * COS(r!(i))
  109.     hy(i) = yc + 100 * SIN(r!(i))
  110. xt = xc + 50 * COS(r!(0)) '                      hour circle center
  111. yt = yc + 50 * SIN(r!(0))
  112. FOR c = 0 TO 1 '                                 start & end angle
  113.     ta = (360 - a) MOD 360
  114.     r!(c) = _D2R(ta + (c - .5) * 22)
  115.     IF r!(c) < 0 THEN r!(c) = r!(c) + 2 * pi!
  116. FOR c = -1 TO 1 '                                draw circles
  117.     CIRCLE (xt, yt), 50 + c, hc, r!(1), r!(0)
  118.     CIRCLE (xt + 1, yt), 50 + c, hc, r!(1), r!(0)
  119.     CIRCLE (xt, yt + 1), 50 + c, hc, r!(1), r!(0)
  120. FOR i = 0 TO 2 STEP 2 '                          near and far diamond
  121.     FOR j = 1 TO 3 STEP 2 '                      diamond edges
  122.         FOR k = -1 TO 1 '                        make thicker
  123.             LINE (hx(i), hy(i))-(hx(j) + k, hy(j) + k), hc
  124.         NEXT k
  125.     NEXT j
  126. timetext: '                                      tiny font digital clock
  127. xt = 304: yt = 440: c = 15
  128. d$ = TIME$
  129. LINE (xt - 3, yt - 3)-(xt + 36, yt + 7), 0, BF
  130. FOR z = 1 TO LEN(d$)
  131.     z$ = MID$(d$, z, 1)
  132.     IF z$ = ":" THEN d = 10 ELSE d = VAL(z$)
  133.     FOR i = 0 TO 4
  134.         xt2 = xt + z * 4 - 4
  135.         LINE (xt2, yt + i)-(xt2 + 4, yt + i), c, , p(d, i)
  136.     NEXT i
  137.  
  138. DATA 0,7,5,5,5,7
  139. DATA 1,2,6,2,2,7
  140. DATA 2,7,1,7,4,7
  141. DATA 3,7,1,7,1,7
  142. DATA 4,5,5,7,1,1
  143. DATA 5,7,4,7,1,7
  144. DATA 6,7,4,7,5,7
  145. DATA 7,7,1,1,1,1
  146. DATA 8,7,5,7,5,7
  147. DATA 9,7,5,7,1,7
  148. DATA ":",0,2,0,2,0
  149.  
  150.  

* c1.ico (Filesize: 167.93 KB, Dimensions: 16x16, Views: 298)
« Last Edit: February 29, 2020, 11:54:02 am by Richard Frost »
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Clock variation one billion and something....
« Reply #1 on: February 29, 2020, 11:48:22 am »
Quote
No doubt someone can make it prettier.

That's quite an hour hand and the other hands are cool too. Have we seen this before or deja vu?

BTW why are they called "hands" and not "arms"? Have I asked this before? ;-))

I have been curiously interested in a certain type of coloring since _vince did bplus avatar and Diagonal Eggs code from BASIC-256, so I accept your challenge :)
« Last Edit: February 29, 2020, 11:51:12 am by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Clock variation one billion and something....
« Reply #2 on: February 29, 2020, 12:55:31 pm »
Richard, you must be Chronos, our God of Time.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Clock variation one billion and something....
« Reply #3 on: February 29, 2020, 12:57:23 pm »
Oh crap, did I post this before?  Sorry.

I did do a search for it first, but not thoroughly enough.

It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Clock variation one billion and something....
« Reply #4 on: February 29, 2020, 01:01:18 pm »
Oh crap, did I post this before?  Sorry.

I did do a search for it first, but not thoroughly enough.



Possibly under [banned user] clock thing? possibly in BIN file from IRC chat? possibly bplus mind is outside of time?

Update: another bunch found with Ken's clock, I made similar dial.
« Last Edit: February 29, 2020, 01:11:58 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Clock variation one billion and something....
« Reply #5 on: February 29, 2020, 02:00:31 pm »
Digital with color, fade, and LCD option.  I'm not too good at finding icons online,
and pick the first one that looks half decent.   Maybe the other way, loading a
regular image and using _ICON is better?  Sure get a better selection of images
when not a ready made ICO.

Code: QB64: [Select]
  1. _TITLE "Digital Clock"
  2. $EXEICON:'c8.ico'
  3.  
  4. DEFINT A-Z
  5. qs = 2200: q = qs * 10
  6. DIM gb(q), segxy(7, 4), seglit$(9), nlast(10)
  7. GOSUB init
  8.     t$ = TIME$
  9.     t$ = LEFT$(t$, 2) + MID$(t$, 4, 2) + RIGHT$(t$, 2)
  10.     x = 60
  11.     FOR i = 1 TO 6
  12.         c$ = MID$(t$, i, 1)
  13.         nu = VAL(c$)
  14.         IF nu <> nlast(i) THEN
  15.             IF invert = 0 THEN
  16.                 PUT (x, 150), gb(nu * qs), PSET
  17.             ELSE
  18.                 PUT (x, 150), gb(nu * qs), PRESET
  19.             END IF
  20.             nlast(i) = nu
  21.         END IF
  22.         x = x + 74 - (i = 2) * 40 - (i = 4) * 40
  23.     NEXT i
  24.     i$ = INKEY$
  25.     IF (i$ > "") AND (INSTR("lwrgbpy", i$) > 0) THEN GOSUB mcolor
  26.     t$ = " fs" + CHR$(13)
  27.     IF (i$ > "") AND (INSTR(t$, i$) > 0) THEN fade = 1 - fade: GOSUB init2
  28.     IF i$ = "i" THEN invert = 1 - invert: GOSUB init2
  29.     IF i$ = "z" THEN doabox = 1 - doabox: GOSUB init2
  30.     IF doabox THEN
  31.         LINE (45, 130)-(585, 310), 15, B
  32.     END IF
  33. LOOP UNTIL i$ = CHR$(27)
  34.  
  35. plot:
  36. IF fade THEN q = 11 ELSE q = 7
  37. FOR j = 1 TO LEN(seglit$(n))
  38.     sn = ASC(MID$(seglit$(n), j, 1)) - 96
  39.     x1 = 8 + segxy(sn, 1) * 40
  40.     x2 = 8 + segxy(sn, 3) * 40
  41.     y1 = 128 + segxy(sn, 2) * 60
  42.     y2 = 128 + segxy(sn, 4) * 60
  43.     IF y1 = y2 THEN ' horizontal
  44.         x1 = x1 + 1: x2 = x2 - 1
  45.         FOR k = -q TO q
  46.             IF fade THEN c = 15 - ABS(k) ELSE c = 15
  47.             LINE (x1 + ABS(k), y1 + k)-(x2 - ABS(k), y2 + k), c
  48.         NEXT k
  49.     ELSE ' vertical
  50.         y1 = y1 + 1: y2 = y2 - 1
  51.         FOR k = -q TO q
  52.             IF fade THEN c = 15 - ABS(k) ELSE c = 15
  53.             LINE (x1 + k, y1 + ABS(k))-(x2 + k, y2 - ABS(k)), c
  54.         NEXT k
  55.     END IF
  56.  
  57. init:
  58.  
  59. FOR i = 1 TO 7
  60.     READ g$
  61.     FOR j = 1 TO 4
  62.         READ segxy(i, j)
  63.     NEXT j
  64. FOR i = 0 TO 9
  65.     READ g$, seglit$(i)
  66. fade = 1 '                                                      segment effect on
  67. sc$ = "b" '                                                     blue for initial state
  68.  
  69. init2:
  70. FOR i = 1 TO 15
  71.     PALETTE i, 0
  72. FOR n = 0 TO 9
  73.     GOSUB plot
  74.     i = n * qs
  75.     GET (0, 0)-(56, 136), gb(i)
  76.     CLS
  77.     nlast(n) = -1
  78. i$ = sc$
  79.  
  80. t$ = "red green blue yellow purple white lcd fade invert"
  81. tc = 40 - LEN(t$) \ 2
  82. LOCATE 29, tc: PRINT t$;
  83.  
  84. mcolor:
  85. r = 0: ri = 0: g = 0: gi = 0: B = 0: bi = 0
  86. IF INSTR("rwpy", i$) THEN ri = 4 '                              red white purple yellow
  87. IF INSTR("gwy", i$) THEN gi = 4 '                               green white yellow
  88. IF INSTR("bwp", i$) THEN bi = 4 '                               blue white purple
  89. FOR i = 0 TO 15
  90.     p& = CDBL(B) * 65536 + CDBL(g) * 256 + r
  91.     PALETTE i, p&
  92.     r = r + ri: g = g + gi: B = B + bi
  93.  
  94. IF i$ = "l" THEN ' LCD
  95.     q = 30
  96.     p& = CDBL(q) * 65536 + CDBL(q) * 256 + q
  97.     PALETTE 0, p&
  98.     PALETTE 15, 0
  99.  
  100. sc$ = i$
  101.  
  102. DATA a,0,-2,1,-2,b,1,-2,1,-1,c,1,-1,1,0,d,0,0,1,0
  103. DATA e,0,-1,0,0,f,0,-2,0,-1,g,0,-1,1,-1
  104.  
  105. DATA 0,abcdef,1,bc,2,abged,3,abgcd,4,fgbc
  106. DATA 5,acdfg,6,acdefg,7,abc,8,abcdefg,9,abcdfg
  107.  
  108.  

* c8.ico (Filesize: 158.07 KB, Dimensions: 16x16, Views: 266)
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Clock variation one billion and something....
« Reply #6 on: February 29, 2020, 02:47:48 pm »
« Last Edit: February 29, 2020, 03:47:30 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Clock variation one billion and something....
« Reply #7 on: February 29, 2020, 03:19:57 pm »
Aye, way back when.

Having the option to change the colors ain't much of a change, is it?

And why am I still using SCREEN 12?  Can you say "senile"?
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Clock variation one billion and something....
« Reply #8 on: February 29, 2020, 03:46:38 pm »
Quote
And why am I still using SCREEN 12?  Can you say "senile"?

I am trying a mod and WTH? why isn't anything working?

Oh Screen 12 and DEFINT A-Z heh-heh