Author Topic: One page clock  (Read 6304 times)

0 Members and 1 Guest are viewing this topic.

Offline dajan

  • Newbie
  • Posts: 41
    • View Profile
Re: One page clock
« Reply #15 on: January 21, 2020, 05:49:18 am »
@bplus, awesome plasma, like the 3D shader effect a lot. Does the pattern repeat after a while, or it is completley random/fractaloid? I don't know a lot about this kind of math.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: One page clock
« Reply #16 on: January 21, 2020, 11:41:46 am »
@bplus, awesome plasma, like the 3D shader effect a lot. Does the pattern repeat after a while, or it is completley random/fractaloid? I don't know a lot about this kind of math.

Hope you don't mind, I answered your question in thread where I have worked on this effect:
https://www.qb64.org/forum/index.php?topic=1451.msg113440#msg113440

To show whose shoulders I am standing on and to show my source and give credit.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: One page clock
« Reply #17 on: January 21, 2020, 08:22:25 pm »
This is becoming an obsession, here I made crystal light digits and clock may be enlarged by + key and shrunk by - key, spacebar will still change color set:

Code: QB64: [Select]
  1. _TITLE "Plasmatic Digital Clock 2" ' b+ 2020-01-21 modified:
  2. ' Digital Plasmatic Clock b+ 2020-01-20 translated and modified from SmallBASIC
  3. ' Plasma Magnifico - updated 2015-11-26 for Android
  4. ' This program creates a plasma surface, which looks oily or silky.
  5.  
  6. '=====================================================================================================
  7. '
  8. '       Use spacebar to change color set, + to increase clock size and - to decrease clock size
  9. '
  10. '=====================================================================================================
  11.  
  12. CONST dat = "1110111000001101111100011111100101110111011111101001001111111111011011"
  13. TYPE xy
  14.     x AS SINGLE
  15.     y AS SINGLE
  16.     dx AS SINGLE
  17.     dy AS SINGLE
  18. DIM SHARED sq, xmax, ymax
  19. sq = 15: xmax = 34 * sq: ymax = 8 * sq
  20. SCREEN _NEWIMAGE(xmax, ymax, 32)
  21. DIM c(360) AS _UNSIGNED LONG, p(6) AS xy, f(6), clr AS _UNSIGNED LONG
  22. restart:
  23. r = RND: g = RND: b = RND: i = 0
  24. FOR n = 1 TO 5
  25.     r1 = r: g1 = g: b1 = b
  26.     DO: r = RND: LOOP UNTIL ABS(r - r1) > .2
  27.     DO: g = RND: LOOP UNTIL ABS(g - g1) > .2
  28.     DO: b = RND: LOOP UNTIL ABS(g - g1) > .2
  29.     FOR m = 0 TO 17: m1 = 17 - m
  30.         f1 = (m * r) / 18: f2 = (m * g) / 18: f3 = (m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1
  31.     NEXT
  32.     FOR m = 0 TO 17: m1 = 17 - m
  33.         f1 = (m + m1 * r) / 18: f2 = (m + m1 * g) / 18: f3 = (m + m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1
  34.     NEXT
  35.     FOR m = 0 TO 17: m1 = 17 - m
  36.         f1 = (m1 + m * r) / 18: f2 = (m1 + m * g) / 18: f3 = (m1 + m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1
  37.     NEXT
  38.     FOR m = 0 TO 17: m1 = 17 - m
  39.         f1 = (m1 * r) / 18: f2 = (m1 * g) / 18: f3 = (m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1
  40.     NEXT
  41.  
  42. FOR n = 0 TO 5
  43.     p(n).x = RND * xmax: p(n).y = RND * ymax: p(n).dx = RND * 2 - 1: p(n).dy = RND * 2 - 1
  44.     f(n) = RND * .1
  45.  
  46. WHILE _KEYDOWN(27) = 0
  47.     k$ = INKEY$
  48.     IF k$ = " " THEN GOTO restart
  49.     IF k$ = "+" AND sq < 40 THEN sq = sq + 1: xmax = 34 * sq: ymax = 8 * sq: SCREEN _NEWIMAGE(xmax, ymax, 32): GOTO restart
  50.     IF k$ = "-" AND sq > 3 THEN sq = sq - 1: xmax = 34 * sq: ymax = 8 * sq: SCREEN _NEWIMAGE(xmax, ymax, 32): GOTO restart
  51.     FOR i = 0 TO 5
  52.         p(i).x = p(i).x + p(i).dx
  53.         IF p(i).x > xmax OR p(i).x < 0 THEN p(i).dx = -p(i).dx
  54.         p(i).y = p(i).y + p(i).dy
  55.         IF p(i).y > ymax OR p(i).y < 0 THEN p(i).dy = -p(i).dy
  56.     NEXT
  57.     FOR y = 0 TO ymax - 1 STEP 2
  58.         FOR x = 0 TO xmax - 1 STEP 2
  59.             d = 0
  60.             FOR n = 0 TO 5
  61.                 dx = x - p(n).x: dy = y - p(n).y
  62.                 k = SQR(dx * dx + dy * dy)
  63.                 d = d + (SIN(k * f(n)) + 1) / 2
  64.             NEXT n: d = d * 60
  65.             LINE (x, y)-STEP(2, 2), c(d), BF
  66.         NEXT
  67.     NEXT
  68.     FOR n = 1 TO 8 'clock digits over background
  69.         IF MID$(TIME$, n, 1) = ":" THEN
  70.             FOR i = .5 * sq TO 0 STEP -.25
  71.                 clr = _RGBA32(255 - i * (255 / sq), (.5 * sq - i) * 255 / sq, 0, 380 / sq)
  72.                 LINE ((n - 1) * 4 * sq + 2 * sq + .5 * sq - i, sq + sq + .5 * sq - i)-STEP(2 * i, 2 * i), clr, BF
  73.                 LINE ((n - 1) * 4 * sq + 2 * sq + .5 * sq - i, 5 * sq + .5 * sq - i)-STEP(2 * i, 2 * i), clr, BF
  74.             NEXT
  75.         ELSE
  76.             drawC (n - 1) * 4 * sq + sq + offset, sq + offset, MID$(dat$, VAL(MID$(TIME$, n, 1)) * 7 + 1, 7)
  77.         END IF
  78.     NEXT
  79.     _LIMIT 60
  80.     _DISPLAY
  81.  
  82. FUNCTION rgbf~& (n1, n2, n3)
  83.     rgbf~& = _RGB32(n1 * 255, n2 * 255, n3 * 255)
  84.  
  85. SUB drawC (x, y, c$)
  86.     FOR m = 1 TO 7
  87.         IF VAL(MID$(c$, m, 1)) THEN
  88.             FOR i = .5 * sq TO 0 STEP -.25
  89.                 c = _RGBA32(255 - i * (255 / sq), (.5 * sq - i) * 255 / sq, 0, 380 / sq)
  90.                 SELECT CASE m
  91.                     CASE 1: LINE (x + .5 * sq - i, y + .5 * sq + i)-(x + .5 * sq + i, y + 2.5 * sq - i), c, BF
  92.                     CASE 2: LINE (x + .5 * sq - i, y + 2.5 * sq + i)-(x + .5 * sq + i, y + 5.5 * sq - i), c, BF
  93.                     CASE 3: LINE (x + .5 * sq + i, y + .5 * sq + i)-(x + 2.5 * sq - 2 - i, y + .5 * sq - i), c, BF
  94.                     CASE 4: LINE (x + .5 * sq + i, y + 2.5 * sq + i)-(x + 2.5 * sq - 2 - i, y + 2.5 * sq - i), c, BF
  95.                     CASE 5: LINE (x + .5 * sq + i, y + 5.5 * sq + i)-(x + 2.5 * sq - 2 - i, y + 5.5 * sq - i), c, BF
  96.                     CASE 6: LINE (x + 2.5 * sq - i, y + .5 * sq + i)-(x + 2.5 * sq + i, y + 2.5 * sq - i), c, BF
  97.                     CASE 7: LINE (x + 2.5 * sq - i, y + 2.5 * sq + i)-(x + 2.5 * sq + i, y + 5.5 * sq - i), c, BF
  98.                 END SELECT
  99.             NEXT
  100.         END IF
  101.     NEXT
  102.  

Plasmatic Digital Clock 2.PNG
* Plasmatic Digital Clock 2.PNG (Filesize: 300.84 KB, Dimensions: 1299x334, Views: 229)

* Plasmatic Digital Clock 2 small.PNG (Filesize: 3.37 KB, Dimensions: 106x54, Views: 240)