Author Topic: Spilling Paint Non-Stop  (Read 4191 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Spilling Paint Non-Stop
« on: January 11, 2020, 05:39:49 pm »
Code: QB64: [Select]
  1. _TITLE "Spilling Paint Non-Stop by SierraKen"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.     a = INT(RND * 300) + 60
  4.     st = INT(RND * 1000)
  5.     st = st / 900
  6.     IF st < .1 THEN st = .1
  7.     c1 = INT(RND * 200) + 54
  8.     c2 = INT(RND * 200) + 54
  9.     c3 = INT(RND * 200) + 54
  10.     s = 0
  11.     FOR d = 0 TO 250 STEP st
  12.         _LIMIT 2000
  13.         s = s + .5
  14.         x = COS(s * 3.141592 / a) * d
  15.         y = SIN(s * 3.151492 / a) * d
  16.         CIRCLE (x + 400, y + 300), 30, _RGB32(c1, c2, c3)
  17.         PAINT (x + 400, y + 300), _RGB32(c1, c2, c3)
  18.     NEXT d
  19.  
« Last Edit: January 11, 2020, 05:42:17 pm by SierraKen »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #1 on: January 12, 2020, 06:04:24 am »
"Cleanup on aisle #3"... lol

Cool...
Logic is the beginning of wisdom.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #2 on: January 12, 2020, 10:42:38 am »
Hi Sierraken, try it with Steve' s CircleFill:

Code: QB64: [Select]
  1. _TITLE "Spilling Paint Non-Stop by SierraKen"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.     a = INT(RND * 300) + 60
  4.     st = INT(RND * 1000)
  5.     st = st / 900
  6.     IF st < .1 THEN st = .1
  7.     c1 = INT(RND * 200) + 54
  8.     c2 = INT(RND * 200) + 54
  9.     c3 = INT(RND * 200) + 54
  10.     s = 0
  11.     FOR d = 0 TO 250 STEP st
  12.         _LIMIT 2000
  13.         s = s + .5
  14.         x = COS(s * 3.141592 / a) * d
  15.         y = SIN(s * 3.151492 / a) * d
  16.         '   CIRCLE (x + 400, y + 300), 30, _RGB32(c1, c2, c3)
  17.         '   PAINT (x + 400, y + 300), _RGB32(c1, c2, c3)
  18.         CircleFill x + 400, y + 300, 30, _RGB32(c1, c2, c3)
  19.     NEXT d
  20.  
  21.  
  22. SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  23.     ' CX = center x coordinate
  24.     ' CY = center y coordinate
  25.     '  R = radius
  26.     '  C = fill color
  27.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  28.     DIM X AS INTEGER, Y AS INTEGER
  29.     Radius = ABS(R)
  30.     RadiusError = -Radius
  31.     X = Radius
  32.     Y = 0
  33.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  34.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  35.     WHILE X > Y
  36.         RadiusError = RadiusError + Y * 2 + 1
  37.         IF RadiusError >= 0 THEN
  38.             IF X <> Y + 1 THEN
  39.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  40.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  41.             END IF
  42.             X = X - 1
  43.             RadiusError = RadiusError - X * 2
  44.         END IF
  45.         Y = Y + 1
  46.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  47.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  48.     WEND
  49.  
  50.  
  51.  


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #3 on: January 12, 2020, 05:07:03 pm »
Here is my try at slinging paint, wear your goggles:
Code: QB64: [Select]
  1. _TITLE "Splats" 'b+ 2020-01-12
  2. ' from eRATication/cheese wedge tests/ multiple explosions.bas 2018-07-28 translated from
  3. 'bomb.bas for SmallBASIC 0.12.2 [B+=MGA] 2016-05-09 from explosion study
  4.  
  5. CONST xmax = 1300, ymax = 760, pi2 = 6.283185
  6. TYPE particle
  7.     x AS SINGLE
  8.     y AS SINGLE
  9.     dx AS SINGLE
  10.     dy AS SINGLE
  11.     size AS SINGLE
  12.     spread AS SINGLE
  13.     'tf AS INTEGER
  14. REDIM SHARED dots(1) AS particle
  15. SCREEN _NEWIMAGE(xmax, ymax, 32)
  16.  
  17.     COLOR , _RGB32(RND * 255, RND * 255, RND * 255)
  18.     CLS
  19.     stopit = (RND * 100) \ 1 + 15
  20.     FOR i = 1 TO stopit
  21.         dx = RND * 60 - 30: dy = RND * 60 - 30: a = 7 * (RND * 10 - 5): b = 7 * (RND * 10 - 5)
  22.         x = xmax * RND: y = ymax * RND
  23.         kolor = _RGB32(RND * 255, RND * 255, RND * 255)
  24.         WHILE x > -100 AND x < xmax + 100 AND y > -100 AND y < ymax + 100
  25.             splat x, y, kolor
  26.             x = x + dx: y = y + dy
  27.             dx = dx + a: dy = dy + b
  28.             _DISPLAY
  29.             '_LIMIT 5
  30.         WEND
  31.         '_DELAY 1
  32.     NEXT
  33.     _DELAY 5
  34.  
  35. SUB splat (x, y, kolor AS _UNSIGNED LONG)
  36.     round = 5
  37.     nRounds = (RND * 10) \ 1 + 1
  38.     nDots = nRounds * round
  39.  
  40.     REDIM dots(1 TO nDots) AS particle
  41.     FOR i = 1 TO round
  42.         NewDot i, x, y
  43.     NEXT
  44.     rounds = round
  45.     FOR loopCount = 0 TO 20
  46.         IF _KEYDOWN(27) THEN END
  47.         FOR i = 1 TO rounds
  48.             dots(i).x = dots(i).x + dots(i).dx
  49.             dots(i).y = dots(i).y + dots(i).dy
  50.             dots(i).dx = dots(i).dx * dots(i).spread
  51.             dots(i).dy = dots(i).dy * dots(i).spread
  52.             fcirc dots(i).x, dots(i).y, dots(i).size / 2, kolor
  53.             dots(i).size = dots(i).size * dots(i).spread
  54.         NEXT
  55.         IF rounds < nDots THEN
  56.             FOR i = 1 TO round
  57.                 NewDot i, x, y
  58.             NEXT
  59.             rounds = rounds + round
  60.         END IF
  61.         _DISPLAY
  62.     NEXT
  63.  
  64. SUB NewDot (i, x, y)
  65.     angle = RND * pi2
  66.     r = RND * 5
  67.     dots(i).x = x + r * COS(angle)
  68.     dots(i).y = y + r * SIN(angle)
  69.     dots(i).size = RND * 15 + 5
  70.     r = RND * 3
  71.     dots(i).dx = r * (15 - dots(i).size) * COS(angle)
  72.     dots(i).dy = r * (15 - dots(i).size) * SIN(angle)
  73.     dots(i).spread = RND * .3 + .2
  74.  
  75. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  76.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  77.     DIM X AS INTEGER, Y AS INTEGER
  78.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  79.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  80.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  81.     WHILE X > Y
  82.         RadiusError = RadiusError + Y * 2 + 1
  83.         IF RadiusError >= 0 THEN
  84.             IF X <> Y + 1 THEN
  85.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  86.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  87.             END IF
  88.             X = X - 1
  89.             RadiusError = RadiusError - X * 2
  90.         END IF
  91.         Y = Y + 1
  92.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  93.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  94.     WEND
  95.  
  96.  
  97.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #4 on: January 12, 2020, 05:28:16 pm »
I don't think goggles are going to be enough! Cool...
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #5 on: January 12, 2020, 10:25:30 pm »
Thanks Petr! I need to learn how to use that code.

LOL B+! Great job.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Spilling Paint Non-Stop
« Reply #6 on: January 13, 2020, 12:00:41 am »
Thanks Petr! I need to learn how to use that code.

LOL B+! Great job.
Code: [Select]
        ‘ CIRCLE (x + 400, y + 300), 30, _RGB32(c1, c2, c3)
        CircleFill x + 400, y + 300, 30, _RGB32(c1, c2, c3)

As you can see from Petr’s replacement above, it’s usually just as simple as using the sub name CircleFill instead of using Circle.  Just don’t put the X/Y coordinates in parentheses.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Spilling Paint Non-Stop
« Reply #7 on: January 13, 2020, 02:44:24 am »
I added a toggle with space bar to go between color and shades of gray fro white to black which looks better less color is more sometimes:
Code: QB64: [Select]
  1. _TITLE "Splats" 'b+ 2020-01-12
  2. ' from eRATication/cheese wedge tests/ multiple explosions.bas 2018-07-28 translated from
  3. 'bomb.bas for SmallBASIC 0.12.2 [B+=MGA] 2016-05-09 from explosion study
  4.  
  5. CONST xmax = 1300, ymax = 760, pi2 = 6.283185
  6. TYPE particle
  7.     x AS SINGLE
  8.     y AS SINGLE
  9.     dx AS SINGLE
  10.     dy AS SINGLE
  11.     size AS SINGLE
  12.     spread AS SINGLE
  13.     'tf AS INTEGER
  14. REDIM SHARED dots(1) AS particle
  15. SCREEN _NEWIMAGE(xmax, ymax, 32)
  16.  
  17.     COLOR , _RGB32(RND * 255, RND * 255, RND * 255)
  18.     CLS
  19.     stopit = (RND * 100) \ 1 + 15
  20.     FOR i = 1 TO stopit
  21.         dx = RND * 60 - 30: dy = RND * 60 - 30: a = 7 * (RND * 10 - 5): b = 7 * (RND * 10 - 5)
  22.         x = xmax * RND: y = ymax * RND
  23.         r = RND * 255
  24.         IF INKEY$ = " " THEN toggle = 1 - toggle
  25.         IF toggle THEN
  26.             kolor = _RGB32(r, r, r)
  27.         ELSE
  28.             kolor = _RGB32(RND * 255, RND * 255, RND * 255)
  29.         END IF
  30.         WHILE x > -100 AND x < xmax + 100 AND y > -100 AND y < ymax + 100
  31.             splat x, y, kolor
  32.             x = x + dx: y = y + dy
  33.             dx = dx + a: dy = dy + b
  34.             _DISPLAY
  35.         WEND
  36.     NEXT
  37.     _DELAY 5
  38.  
  39. SUB splat (x, y, kolor AS _UNSIGNED LONG)
  40.     round = 5
  41.     nRounds = (RND * 10) \ 1 + 1
  42.     nDots = nRounds * round
  43.  
  44.     REDIM dots(1 TO nDots) AS particle
  45.     FOR i = 1 TO round
  46.         NewDot i, x, y
  47.     NEXT
  48.     rounds = round
  49.     FOR loopCount = 0 TO 20
  50.         IF _KEYDOWN(27) THEN END
  51.         FOR i = 1 TO rounds
  52.             dots(i).x = dots(i).x + dots(i).dx
  53.             dots(i).y = dots(i).y + dots(i).dy
  54.             dots(i).dx = dots(i).dx * dots(i).spread
  55.             dots(i).dy = dots(i).dy * dots(i).spread
  56.             fcirc dots(i).x, dots(i).y, dots(i).size / 2, kolor
  57.             dots(i).size = dots(i).size * dots(i).spread
  58.         NEXT
  59.         IF rounds < nDots THEN
  60.             FOR i = 1 TO round
  61.                 NewDot i, x, y
  62.             NEXT
  63.             rounds = rounds + round
  64.         END IF
  65.         _DISPLAY
  66.     NEXT
  67.  
  68. SUB NewDot (i, x, y)
  69.     angle = RND * pi2
  70.     r = RND * 5
  71.     dots(i).x = x + r * COS(angle)
  72.     dots(i).y = y + r * SIN(angle)
  73.     dots(i).size = RND * 15 + 5
  74.     r = RND * 3
  75.     dots(i).dx = r * (15 - dots(i).size) * COS(angle)
  76.     dots(i).dy = r * (15 - dots(i).size) * SIN(angle)
  77.     dots(i).spread = RND * .3 + .2
  78.  
  79. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  80.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  81.     DIM X AS INTEGER, Y AS INTEGER
  82.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  83.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  84.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  85.     WHILE X > Y
  86.         RadiusError = RadiusError + Y * 2 + 1
  87.         IF RadiusError >= 0 THEN
  88.             IF X <> Y + 1 THEN
  89.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  90.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  91.             END IF
  92.             X = X - 1
  93.             RadiusError = RadiusError - X * 2
  94.         END IF
  95.         Y = Y + 1
  96.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  97.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  98.     WEND
  99.  
  100.  
  101.  

shades of grey.PNG
* shades of grey.PNG (Filesize: 84.14 KB, Dimensions: 1046x765, Views: 170)