Author Topic: Donut with Code Sprinkles looking for Coffee Maker  (Read 11676 times)

0 Members and 1 Guest are viewing this topic.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Donut with Code Sprinkles looking for Coffee Maker
« Reply #15 on: March 11, 2018, 01:00:12 pm »
Cool! ;D
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Donut with Code Sprinkles looking for Coffee Maker
« Reply #16 on: March 20, 2018, 08:59:09 am »
[banned user], looks like someone ate too many spiral sprinkled donuts!

Here is donut sprinkled with deliciousness not using file:
Code: QB64: [Select]
  1. _TITLE "Donut code spiral by bplus mod by bplus 2018-03-20"
  2. CONST xmax = 700
  3. CONST ymax = 700
  4. SCREEN _NEWIMAGE(xmax, ymax, 32)
  5. CONST cx = xmax / 2
  6. CONST cy = ymax / 2
  7. CONST tw = 8
  8. CONST th = 16
  9. sprinkle$ = "bplus "
  10. lenF = 1240
  11. tArea = tw * th * lenF / 2
  12. r = SQR(10 / 4 * tArea / _PI)
  13. FOR y = 0 TO ymax
  14.     FOR x = 0 TO xmax
  15.         d = ((x - cx) ^ 2 + (y - cy) ^ 2) ^ .5
  16.         IF r / 3 < d + 20 AND d - 20 < r THEN
  17.             midInk 180, 90, 55, 80, 40, 20, 1 - ABS(2 / 3 * r - d) / (.335 * r), 0
  18.             PSET (x + 5, y + 10)
  19.         END IF
  20.     NEXT
  21. idx = 0: rr = r / 3
  22. WHILE idx < lenF
  23.     idx = idx + 1
  24.     rr = r / 3.6 + idx / (rr ^ .4) + 32
  25.     a = a + 12 / rr
  26.     x = cx + rr * COS(a)
  27.     y = cy + rr * SIN(a)
  28.     midInk 180, 90, 55, 80, 40, 20, ABS(2 / 3 * r - d) / (.335 * r), 1
  29.     COLOR , 0
  30.     _PRINTSTRING (x, y), MID$(sprinkle$, idx MOD 6 + 1, 1)
  31. FUNCTION rand% (lo%, hi%)
  32.     rand% = INT(RND * (hi% - lo% + 1)) + lo%
  33. FUNCTION rclr&&
  34.     rclr&& = _RGB32(rand%(64, 255), rand%(64, 255), rand%(64, 255))
  35. SUB midInk (r1, g1, b1, r2, g2, b2, fr, tf)
  36.     IF tf THEN
  37.         fc&& = rclr&&
  38.     ELSE
  39.         fc&& = _RGB32(r1 + (r2 - r1) * (1 - fr), g1 + (g2 - g1) * (1 - fr), b1 + (b2 - b1) * (1 - fr))
  40.     END IF
  41.     bc&& = _RGB32(r1 + (r2 - r1) * fr, g1 + (g2 - g1) * fr, b1 + (b2 - b1) * fr)
  42.     COLOR fc&&, bc&&
  43. 'XOXOXOXO
  44.  
  45.  
donut mod bplus.PNG
* donut mod bplus.PNG (Filesize: 161.29 KB, Dimensions: 705x730, Views: 537)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Donut with Code Sprinkles looking for Coffee Maker
« Reply #17 on: March 20, 2018, 10:23:17 am »
Here it is with lettering reversed so it will play right on record player with needle at edge of donut.

Code: QB64: [Select]
  1. _TITLE "Donut code spiral by bplus mod by bplus 2018-03-20"
  2. CONST xmax = 700
  3. CONST ymax = 700
  4. SCREEN _NEWIMAGE(xmax, ymax, 32)
  5. CONST cx = xmax / 2
  6. CONST cy = ymax / 2
  7. CONST tw = 8
  8. CONST th = 16
  9. sprinkle$ = "bplus "
  10. lenF = 1240
  11. tArea = tw * th * lenF / 2
  12. r = SQR(10 / 4 * tArea / _PI)
  13. FOR y = 0 TO ymax
  14.     FOR x = 0 TO xmax
  15.         d = ((x - cx) ^ 2 + (y - cy) ^ 2) ^ .5
  16.         IF r / 3 < d + 20 AND d - 20 < r THEN
  17.             midInk 180, 90, 55, 80, 40, 20, 1 - ABS(2 / 3 * r - d) / (.335 * r), 0
  18.             PSET (x + 5, y + 10)
  19.         END IF
  20.     NEXT
  21. idx = 0: rr = r / 3
  22. WHILE idx < lenF
  23.     idx = idx + 1
  24.     rr = r / 3.6 + idx / (rr ^ .4) + 32
  25.     a = a + 12 / rr
  26.     x = cx + rr * COS(a)
  27.     y = cy + rr * SIN(a)
  28.     midInk 180, 90, 55, 80, 40, 20, ABS(2 / 3 * r - d) / (.335 * r), 1
  29.     COLOR , 0
  30.     _PRINTSTRING (x, y), MID$(sprinkle$, idx MOD 6 + 1, 1)
  31. FUNCTION rand% (lo%, hi%)
  32.     rand% = INT(RND * (hi% - lo% + 1)) + lo%
  33. FUNCTION rclr&&
  34.     rclr&& = _RGB32(rand%(64, 255), rand%(64, 255), rand%(64, 255))
  35. SUB midInk (r1, g1, b1, r2, g2, b2, fr, tf)
  36.     IF tf THEN
  37.         fc&& = rclr&&
  38.     ELSE
  39.         fc&& = _RGB32(r1 + (r2 - r1) * (1 - fr), g1 + (g2 - g1) * (1 - fr), b1 + (b2 - b1) * (1 - fr))
  40.     END IF
  41.     bc&& = _RGB32(r1 + (r2 - r1) * fr, g1 + (g2 - g1) * fr, b1 + (b2 - b1) * fr)
  42.     COLOR fc&&, bc&&
  43. 'XOXOXOXO
  44.  
  45.  

Might be a bit hypnotic because doing it with code file WAS much more interesting.
revise for record player.PNG
* revise for record player.PNG (Filesize: 161.72 KB, Dimensions: 702x723, Views: 473)