Author Topic: Easter Egg Decorating  (Read 20042 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Easter Egg Decorating
« Reply #45 on: April 01, 2022, 07:05:34 pm »
Both @CharlieJV and @dbox if you want to be rid of those dots try changing this:
Code: QB64: [Select]
  1. PSet (int(xc + d * Cos(a + radianAngle)), int(yc + d * Sin(a + radianAngle))), thisColor
  2.  

to
Code: QB64: [Select]
  1. line (int(xc + d * Cos(a + radianAngle)), int(yc + d * Sin(a + radianAngle)))- step(1,1), thisColor, BF

So instead of a pixel it is a box fill a bit larger than a pixel. But some of those dot patterns are kinda cool.

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: Easter Egg Decorating
« Reply #46 on: April 01, 2022, 08:41:26 pm »
Both @CharlieJV and @dbox if you want to be rid of those dots try changing this:
Code: QB64: [Select]
  1. PSet (int(xc + d * Cos(a + radianAngle)), int(yc + d * Sin(a + radianAngle))), thisColor
  2.  

to
Code: QB64: [Select]
  1. line (int(xc + d * Cos(a + radianAngle)), int(yc + d * Sin(a + radianAngle)))- step(1,1), thisColor, BF

So instead of a pixel it is a box fill a bit larger than a pixel. But some of those dot patterns are kinda cool.

It is pretty neat how much of a difference it makes.  I like both equally for different reasons.  The smooth eggs are really nice, the other ones look textured, which is pretty cool.

The first one with pset: view source code, run program

The alternative one with line: view source code, run program



Screenshot 2022-04-01 9.39.14 PM.png
* Screenshot 2022-04-01 9.39.14 PM.png (Filesize: 868.81 KB, Dimensions: 1561x618, Views: 239)
« Last Edit: April 01, 2022, 08:52:44 pm by CharlieJV »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Easter Egg Decorating
« Reply #47 on: April 01, 2022, 10:54:47 pm »
Yeah here are some cherry picked Textured Eggs:
Code: QB64: [Select]
  1. _Title "drawEasterEgg Textured" 'b+ 2022-03-30 mod 2022-04-01 add r,g,b parameter
  2. Const Xmax = 500, Ymax = 500, Pi = _Pi
  3. Screen _NewImage(Xmax, Ymax, 32)
  4. _ScreenMove 100, 100
  5. scale = 100
  6.     Cls
  7.     drawEasterEgg 250, 250, Rnd * scale + scale, Rnd * 2 * Pi, Rnd, Rnd, Rnd
  8.     Sleep
  9.  
  10.  
  11. Sub drawEasterEgg (xc, yc, scale, radianAngle, r, g, b) ' add rgb so can draw the same
  12.     For x = -1 To 1 Step .01
  13.         For y = -1 To 1 Step .01
  14.             If x < 0 Then c = c + .0005 Else c = c - .0005
  15.             If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then ' 1.6 * y orig
  16.                 If y > 0 Then
  17.                     Color _RGB32(128 * (1 - y) + 128 * (1 - y) * Sin(c * r), 128 * (1 - y) + 128 * (1 - y) * Sin(c * g), 127 * (1 - y) + 127 * (1 - y) * Sin(c * b))
  18.                 Else
  19.                     Color _RGB32(128 + 128 * Sin(c * r), 128 + 128 * Sin(c * g), 127 + 127 * Sin(c * b))
  20.                 End If
  21.                 a = _Atan2(y, x)
  22.                 d = scale * Sqr(x * x + y * y)
  23.                 PSet (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))
  24.             End If
  25.         Next
  26.     Next
  27.  
  28.  

 
texture but dark.PNG

 
Texture egg 2.PNG

 
Texture egg 3.PNG

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Easter Egg Decorating
« Reply #48 on: April 01, 2022, 11:06:23 pm »
Dang B+, you surprise me all the time. I wasted a couple hours trying to figure out how to make the Matrix symbols flow over a map of the world, but the map always disappears because of the LINE command. LOL I think it's impossible, even with the BLEND command. I tried DEST and SOURCE in different places, etc, no luck. The best I could do is show the map and make the symbols go over it but without deleting anything, so eventually the symbols fill up the screen.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Easter Egg Decorating
« Reply #49 on: April 01, 2022, 11:31:12 pm »
Ah but did you try with Rotozoom?
Code: QB64: [Select]
  1. _Title "Matrix Rain 4" 'B+ started 2019-03-16
  2. ' from Matrix Rain 2019-03-14
  3. ' or QB64 Purple Rain!
  4.  
  5. '>>> Save this file as: Matrix Rain 4.bas, so the program can load the strings from it.  <<<
  6.  
  7. '2019-03-15 This will attempt to spin the drops as they fall
  8. '2019-03-16  Don't need no damn Character Set.DAT file!!!
  9. '2019-03-16 Ijust want to see the vertical code strings dangle and twist.
  10.  
  11. '2019-03-19 Matrix Rain 4
  12. ' + added randWeight to weight the random sizes chosen so many more on small side than large
  13. ' + draw letters on a transparent background so the background of the letter does not cover
  14. '   the drops behind it.
  15.  
  16.  
  17. Const xmax = 1280
  18. Const ymax = 740
  19. Const nDrops = 500
  20. Type dropType
  21.     x As Single
  22.     sz As Single
  23.     curY As Integer
  24.     dxs As Single 'direction and change of spin some small fraction of 1, +-1/3, +-1/4, +-1/5...
  25.  
  26. Screen _NewImage(xmax, ymax, 32)
  27. _ScreenMove 80, 0 'for snap shot
  28. '_FULLSCREEN 'as screen saver
  29.  
  30. ReDim Shared fileStrings$(1000) 'container for these program lines that will be dangling
  31. Open "Matrix Rain 4.bas" For Input As #1
  32.     Line Input #1, fs$
  33.     If Len(LTrim$(fs$)) <> 0 Then 'less empty spaces
  34.         fileStrings$(i) = LTrim$(fs$)
  35.         i = i + 1
  36.     End If
  37. ReDim _Preserve fileStrings$(i - 1)
  38. ' check loading
  39. 'FOR i = 0 TO UBOUND(fileStrings$)
  40. '    PRINT i, fileStrings$(i)
  41. 'NEXT
  42. 'END
  43.  
  44. 'setup drops
  45. Dim Shared drop(nDrops) As dropType
  46. Dim Shared s$(nDrops)
  47.  
  48. For i = 0 To nDrops
  49.     newDrop i, 1
  50.  
  51. While _KeyDown(27) = 0
  52.     Cls
  53.     For i = 0 To nDrops
  54.         drawDrop (i)
  55.         drop(i).curY = drop(i).curY + 1
  56.         If drop(i).curY > Len(s$(i)) Then newDrop i, 0
  57.     Next
  58.     _Display
  59.     _Limit 25
  60.  
  61. Sub newDrop (i, start)
  62.     drop(i).x = Rnd * xmax 'set location
  63.     drop(i).sz = randWeight(.3, 5, 3) 'set size  weighted on small sizes
  64.     'length of text string can fit on screen
  65.     charLength = ymax \ (drop(i).sz * 16) + 1 'from size determine how many chars fit on screen
  66.     randLine = Int(Rnd * UBound(fileStrings$)) 'pick a random program line
  67.     s$(i) = Mid$(fileStrings$(randLine), 1, charLength) 'here is text string to dangle
  68.     While Len(s$(i)) < charLength
  69.         If randLine + 1 > UBound(fileStrings$) Then randLine = 0 Else randLine = randLine + 1
  70.         s$(i) = Mid$(s$(i) + " : " + fileStrings$(randLine), 1, charLength)
  71.     Wend
  72.     If start <> 0 Then drop(i).curY = Int(Rnd * (charLength)) + 1 Else drop(i).curY = 1 'flat and readable at curY
  73.     drop(i).dxs = 1 / (Int(Rnd * 7) + 3) 'change of spin rate +-1/3, +-1/4, ... +-1/9
  74.     If Rnd < .5 Then drop(i).dxs = -drop(i).dxs
  75.  
  76. Sub drawDrop (i)
  77.     For j = 1 To drop(i).curY
  78.         d = drop(i).curY - j
  79.         If d = 0 Then
  80.             c~& = _RGBA32(255, 100, 255, 225)
  81.         ElseIf d = 1 Then
  82.             c~& = _RGBA32(255, 50, 255, 205)
  83.         ElseIf d = 2 Then
  84.             c~& = _RGBA32(255, 25, 255, 180)
  85.         ElseIf d >= 3 Then
  86.             c~& = _RGBA32(255, 0, 255, 190 - d * 5)
  87.         End If
  88.         rot = 1: dir = -1
  89.         For k = 0 To d
  90.             rot = rot + drop(i).dxs * dir
  91.             If rot > 1 Then dir = -1 * dir: rot = 1 + drop(i).dxs * dir
  92.             If rot < -1 Then dir = dir * -1: rot = -1 + drop(i).dxs * dir
  93.         Next
  94.         drwChar Mid$(s$(i), j, 1), c~&, drop(i).x + 4 * drop(i).sz, drop(i).sz * 16 * (j - 1) + 8 * drop(i).sz, rot * drop(i).sz, drop(i).sz, 0
  95.     Next
  96.  
  97. Sub drwChar (char$, c As _Unsigned Long, midX, midY, xScale, yScale, Rotation) 'what ever the present color is set at
  98.     I& = _NewImage(8, 16, 32)
  99.     _Dest I&
  100.     Color c, _RGBA32(0, 0, 0, 0)
  101.     _PrintString (0, 0), char$
  102.     _Dest 0
  103.     RotoZoom2 midX, midY, I&, xScale, yScale, Rotation
  104.     _FreeImage I&
  105.  
  106. Sub RotoZoom2 (X As Long, Y As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
  107.     Dim px(3) As Single: Dim py(3) As Single
  108.     W& = _Width(Image&): H& = _Height(Image&)
  109.     px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
  110.     px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
  111.     sinr! = Sin(-Rotation): cosr! = Cos(-Rotation)
  112.     For i& = 0 To 3
  113.         x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + Y
  114.         px(i&) = x2&: py(i&) = y2&
  115.     Next
  116.     _MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  117.     _MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  118.  
  119. Function randWeight (manyValue, fewValue, power)
  120.     randWeight = manyValue + Rnd ^ power * (fewValue - manyValue)
  121.  
  122.  

BTW the letters, digits and symbols are the from the source QB64 code.
« Last Edit: April 01, 2022, 11:37:09 pm by bplus »

Offline dbox

  • Newbie
  • Posts: 80
    • View Profile
Re: Easter Egg Decorating
« Reply #50 on: April 01, 2022, 11:37:24 pm »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Easter Egg Decorating
« Reply #51 on: April 01, 2022, 11:49:51 pm »
Awesome stuff B+. Way beyond what I know. I'm still learning the basics of the Matrix example Steve posted.