QB64.org Forum

Active Forums => Programs => Topic started by: bplus on March 29, 2022, 09:03:33 pm

Title: Easter Egg Decorating
Post by: bplus on March 29, 2022, 09:03:33 pm
For Ken,

Code: QB64: [Select]
  1. _Title "Eggs o Dozens" 'b+ 2022-03-29
  2. Const Xmax = 1200, Ymax = 400, Pi = _Pi
  3. Screen _NewImage(Xmax, Ymax, 32)
  4. _ScreenMove 100, 100
  5. scale = 96
  6.     For y = 100 To 300 Step 200
  7.         For x = 100 To 1100 Step 200
  8.             drawEasterEgg x, y, scale, 0
  9.         Next
  10.     Next
  11.     _Delay 1
  12.  
  13. Sub drawEasterEgg (xc, yc, scale, radianAngle)
  14.     r = Rnd: g = Rnd: b = Rnd
  15.     For x = -1 To 1 Step .01
  16.         For y = -1 To 1 Step .01
  17.             If x < 0 Then c = c + .0005 Else c = c - .0005
  18.             If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then
  19.                 If y > 0 Then
  20.                     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))
  21.                 Else
  22.                     Color _RGB32(128 + 128 * Sin(c * r), 128 + 128 * Sin(c * g), 127 + 127 * Sin(c * b))
  23.                 End If
  24.                 a = _Atan2(y, x)
  25.                 d = scale * Sqr(x * x + y * y)
  26.                 PSet (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))
  27.             End If
  28.         Next
  29.     Next
  30.  
  31.  
  32.  

 

Title: Re: Easter Egg Decorating
Post by: bplus on March 30, 2022, 09:44:30 am
Show off more versatility of drawEasterEgg:
Code: QB64: [Select]
  1. _Title "Eggs o Dozens" 'b+ 2022-03-30 mod
  2. Const Xmax = 1200, Ymax = 400, Pi = _Pi
  3. Screen _NewImage(Xmax, Ymax, 32)
  4. _ScreenMove 100, 100
  5. scale = 96
  6.     Cls
  7.     For y = 100 To 300 Step 200
  8.         For x = 100 To 1100 Step 200
  9.             drawEasterEgg x, y, Rnd * .75 * scale + .25 * scale, Rnd * 2 * Pi
  10.         Next
  11.     Next
  12.     _Delay 1
  13.  
  14. Sub drawEasterEgg (xc, yc, scale, radianAngle)
  15.     r = Rnd: g = Rnd: b = Rnd
  16.     For x = -1 To 1 Step .01
  17.         For y = -1 To 1 Step .01
  18.             If x < 0 Then c = c + .0005 Else c = c - .0005
  19.             If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then
  20.                 If y > 0 Then
  21.                     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))
  22.                 Else
  23.                     Color _RGB32(128 + 128 * Sin(c * r), 128 + 128 * Sin(c * g), 127 + 127 * Sin(c * b))
  24.                 End If
  25.                 a = _Atan2(y, x)
  26.                 d = scale * Sqr(x * x + y * y)
  27.                 Line (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))-Step(1, 1)
  28.             End If
  29.         Next
  30.     Next
  31.  
Title: Re: Easter Egg Decorating
Post by: _vince on March 30, 2022, 11:27:40 am
Code: QB64: [Select]
  1. _Title "Eggs o Dozens" 'b+ 2022-03-29
  2.  
interesting funny title, extremely fluent in the english language

Code: QB64: [Select]
  1. Const Xmax = 1200, Ymax = 400, Pi = _Pi
  2.  
Pi = _Pi, the first piece of genius code one can observes.  A philosophical criticism of the language

Code: QB64: [Select]
  1. If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then
  2.  
wow what is this? 1.4 to the power of x times y times 1.6! Wait, this can be written more simply as
Code: QB64: [Select]
  1. If (x * x + (1.4 ^ x * 1.6 * y) ^ 2) <= 1.01 Then
  2.  
...wait a second, this looks like a distance formula.  If one changes it to x*x + y*y < 1 they become circles not eggs! What spectacular mathematical intuition!

Code: QB64: [Select]
  1. a = _Atan2(y, x)
  2. d = scale * Sqr(x * x + y * y)
  3. PSet (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))
  4.  
oh dear, polar coordinates again.  What are we doing, bplus? Why not just
Code: QB64: [Select]
  1. PSet (xc + scale * x, yc + scale * y)
  2.  
Title: Re: Easter Egg Decorating
Post by: bplus on March 30, 2022, 11:49:02 am
For Vince the analyst:

The egg shape formula comes from this:
Quote
Don M. Jacobs, M.D., from Daly City, USA developped a nice egg shape by changing the circle equation x²+y²=1 a little: x² + [1.4^x*1.6y]² = 1. The egg equation is an exponential equation of the type t3.

At LB tsh has nice shape derived from circles, see LB https://libertybasiccom.proboards.com/thread/1954/easter-eggs-anybody
or
JB (towards middle end)
https://justbasiccom.proboards.com/thread/789/graphics-fun?page=2

Pi = _PI  genius LOL! Just making it easier to translate JB code to QB64, only one change with Const instead of changing all Pi's to _Pi in code. Genius is pure laziness.

This:
Code: QB64: [Select]
  1. a = _Atan2(y, x)
  2. d = scale * Sqr(x * x + y * y)
  3. PSet (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))
Is for rotating our egg drawing about xc, yc (the middle point of where we want our egg) so the eggs may be angled by radianAngle and some angle besides radianAngle 0 = East

So imagine a little drawing of an egg pointed east from scale. Imagine taking each point around the center, measuring the angle to the center a = _Atan2(y, x)
d = distance x, y to center of plot with (0,0) as origin x -1 to 1, y -1 to 1
So we rotate and scale our image in a little Rotozoom example one pixel at a time.

What's Polar Coordinates about that?

Anyway, that's why it's not just:
Code: QB64: [Select]
  1. PSet (xc + scale * x, yc + scale * y)
  2.  

In fact in 2nd code I found it better to use a Line with a -Step(sq, sq), , BF
 and draw a colored square instead of a pixel.

PS the first post without using the last parameter to angle the eggs was mostly to show Aurel at his forum that the eggs (the coloring bands) had to be symmetric. I wasn't even going to post Easter eggs here but Ken seemed to be getting lonely doing a monolog on Neon Clocks ;-))
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 30, 2022, 02:32:01 pm
Those are incredible!!!! Thanks B+!!! :)
Title: Re: Easter Egg Decorating
Post by: bplus on March 30, 2022, 03:50:50 pm
Hey Ken, I am going to try and get a less "candy-corn" (Spriggsy's term but kinda right on) egg shape going later today. Lot's of time before Easter.
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 30, 2022, 05:24:34 pm
Sounds great, yeah I almost said they looked a little bit like guitar picks, but curved. :) But they are still awesome.
Title: Re: Easter Egg Decorating
Post by: johnno56 on March 30, 2022, 05:48:37 pm
Ken. Technically a "plectrum" is used to strum the strings of a guitar etc., where as a pick, is used to pluck individual strings. But that does not stop people from using either for both purposes...  But I knew what you meant...  ah... trivia.. ya just gotta love it...
Title: Re: Easter Egg Decorating
Post by: bplus on March 30, 2022, 09:17:03 pm
This pretty much matches the Cage Free Eggs I have in the fridge:
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Clearly no candy corn shape any more.

What do you think?
Title: Re: Easter Egg Decorating
Post by: SMcNeill on March 30, 2022, 10:45:09 pm
Here's my simple little try at a math formula to produce an egg:

Code: QB64: [Select]
  1. Screen _NewImage(320, 320, 32)
  2. Window (0, -1.5)-(_Pi, 1.5)
  3.  
  4. For x = 0 To _Pi Step 0.001
  5.     'y = Sqr(Abs(Sin(1.3 * x))) 'Try #1 change window to (0,-2)-(_PI, 2)
  6.     y = Sqr(Abs(Sin(x) + 0.1 * (Sin(2 * x))))
  7.     PSet (x, y), -1
  8.     PSet (x, -y), -1

I figure a SIN wave stretched on one end could produce an egg-like shape.  The trick is to figure out the best formula to stretch it properly to make a pretty little "egg" like oval.  ;)

EDIT: Crazy math guys have a whole paper dedicated to this whole egguation!  https://nyjp07.com/index_egg_E.html
Title: Re: Easter Egg Decorating
Post by: _vince on March 31, 2022, 12:11:37 am
EDIT: Crazy math guys have a whole paper dedicated to this whole egguation!  https://nyjp07.com/index_egg_E.html
hahaha, Steve, egguation!

I was curious if any of those curves have a mathematical biology argument because otherwise there has to be near infinite types of curves that could fit an egg shape.  The easiest is take a photo and fit a polynomial spline.  I found this article for, allegedly, the true egg formula:  https://www.kent.ac.uk/news/science/29620/research-finally-reveals-ancient-universal-equation-for-the-shape-of-an-egg (https://www.kent.ac.uk/news/science/29620/research-finally-reveals-ancient-universal-equation-for-the-shape-of-an-egg)
Title: Re: Easter Egg Decorating
Post by: _vince on March 31, 2022, 02:52:21 am
I looked a little further into egg philosophy and was wondering if there was anything more substantial than "that looks pretty damn close".  It seems you can make fundamental and profound arguments for certain geometric patterns in nature like hexagonal beehives or numerical sequences in phyllotaxis, but has anyone done the same for eggs?  Can you say that there is one fundamental principle that maximizes bird survival (flight dynamics? egg production rate? idk) and here are the geometric implications of it on the egg shape, I don't think anyone has done it.  Is there a 1:1 function matching bird DNA data to egg curve?

It seems what they did do is take some basic geometric shapes (ovoid) that can approximate most eggs experimentally based on a few measurements then generalize to other basic geometric shapes like pyriform to boost your benchmark.  Like if you have a curve that is 99% accurate on a scan or photograph for 99% of all the eggs produced by 99% of all bird species on the planet and it only requires measuring egg height and max diameter (and maybe a couple of more) than it must be pretty damn good and close to true egg geometry? So far, the universal egg equation is allegedly:


just FYI, the above is just a curve y=f(x) with a bunch of parameters.  the +- in front implies symmetry over the x-axis.  A circle of radius R would be y = +-SQR(R^2 - x^2).  So you'd grab an egg from the fridge, measure L,w,B,D with a tape measure or scale or whatever (I have no idea what those parameters are), plug them in and plot y with respect to x and you should have a curve that is some 99% perfect to the egg you have.  Then, presumably, the actual egg is a surface of revolution of this curve.
Title: Re: Easter Egg Decorating
Post by: bplus on March 31, 2022, 07:12:25 am
Yeah, a formula is useless if you don't know what the variables are!

@_vince So did you figure what * p(x) was to get the 2nd and 3rd line of that eq?

What is 2D sub L/4 on the 2 line of eq towards the right of center? are you kidding?


I think people have cartoon image of eggs being really pointy at one end. They aren't if you look at them.
Title: Re: Easter Egg Decorating
Post by: SMcNeill on March 31, 2022, 07:25:13 am
I think people have cartoon image of eggs being really pointy at one end. They aren't if you look at them.

Looks pretty darn pointed to me!  😁

https://3c1703fe8d.site.internapcdn.net/newman/gfx/news/hires/2017/7-researchersp.jpg
Title: Re: Easter Egg Decorating
Post by: _vince on March 31, 2022, 07:28:46 am
Yeah, a formula is useless if you don't know what the variables are!

@_vince So did you figure what * p(x) was to get the 2nd and 3rd line of that eq?

What is 2D sub L/4 on the 2 line of eq towards the right of center? are you kidding?


I think people have cartoon image of eggs being really pointy at one end. They aren't if you look at them.

Here's a more detailed description of the parameters:  https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/nyas.14771 (https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/nyas.14771)

The chicken eggs are not pointy but eggs of other bird species are, ie the "pyriform" shape https://bioone.org/journals/the-auk/volume-135/issue-4/AUK-18-38.1/The-pyriform-egg-of-the-Common-Murre-Uria-aalge-is/10.1642/AUK-18-38.1.full (https://bioone.org/journals/the-auk/volume-135/issue-4/AUK-18-38.1/The-pyriform-egg-of-the-Common-Murre-Uria-aalge-is/10.1642/AUK-18-38.1.full)

That curve equation is supposed to be universal to all eggs.  From what I gather, you can set p(x) = x for a "good enough" approximation but there are several more complicated variants of p(x) that take into account more species of birds, ie that "pyriform" one
Title: Re: Easter Egg Decorating
Post by: bplus on March 31, 2022, 07:30:59 am
Looks pretty darn pointed to me!  😁

https://3c1703fe8d.site.internapcdn.net/newman/gfx/news/hires/2017/7-researchersp.jpg

WTH? https://www.google.com/search?q=Eggs+image&tbm=isch&chips=q:eggs+image,g_1:white:oGocWXeA-oc%3D&client=opera&hs=ZAc&hl=en&sa=X&ved=2ahUKEwjkz4H6nvD2AhWVj2oFHb00A-oQ4lYoAnoECAEQIQ&biw=1165&bih=606

White eggs do appear slightly more pointed than brown. But I am talking about chicken eggs, not whatever egg Steve found LOL!
Title: Re: Easter Egg Decorating
Post by: bplus on March 31, 2022, 07:39:27 am
Here's a more detailed description of the parameters:  https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/nyas.14771 (https://nyaspubs.onlinelibrary.wiley.com/doi/10.1111/nyas.14771)

The chicken eggs are not pointy but eggs of other bird species are, ie the "pyriform" shape https://bioone.org/journals/the-auk/volume-135/issue-4/AUK-18-38.1/The-pyriform-egg-of-the-Common-Murre-Uria-aalge-is/10.1642/AUK-18-38.1.full (https://bioone.org/journals/the-auk/volume-135/issue-4/AUK-18-38.1/The-pyriform-egg-of-the-Common-Murre-Uria-aalge-is/10.1642/AUK-18-38.1.full)

That curve equation is supposed to be universal to all eggs.  From what I gather, you can set p(x) = x for a "good enough" approximation but there are several more complicated variants of p(x) that take into account more species of birds, ie that "pyriform" one

Ah that helps,   ... a bit.
Title: Re: Easter Egg Decorating
Post by: SMcNeill on March 31, 2022, 07:41:12 am
WTH? https://www.google.com/search?q=Eggs+image&tbm=isch&chips=q:eggs+image,g_1:white:oGocWXeA-oc%3D&client=opera&hs=ZAc&hl=en&sa=X&ved=2ahUKEwjkz4H6nvD2AhWVj2oFHb00A-oQ4lYoAnoECAEQIQ&biw=1165&bih=606

White eggs do appear slightly more pointed than brown. But I am talking about chicken eggs, not whatever egg Steve found LOL!

That's a pic of a quail egg, I think.

Truth is, most "natural" chicken eggs come in all sorts of shapes and sizes from my experience.  Some are extra long (usually with double yokes inside), while some are almost golf ball round.  When we raised chickens, we raised Bantam chickens, and we got everything from red to white to blue to green eggs -- and all from the same crazy ass chicken!

I'd say, "If it's close, it's close enough -- pointed or not!"  All the eggs you buy in the store are "Grade A" eggs, which is why they all look so uniform.  Look at the pictures of lower grade eggs some time.  I wouldn't be too surprised to find a dang pyramid or cube in some of them!  😂

I'll just stick to my simple little SIN stretching... Or elsejust use an actual picture of an egg and then colorit!  LOL!

See these: https://www.purinamills.com/2.purinamills.com/media/Images/Articles/PF_Quality-Eggs-Tile-Image.jpg?ext=.jpg
Title: Re: Easter Egg Decorating
Post by: bplus on March 31, 2022, 08:03:41 am
I am getting ideas for decorating from this:
 


Right up Pete's alley!
Title: Re: Easter Egg Decorating
Post by: bplus on March 31, 2022, 08:48:12 am
As Aurel would say, "Steve's got a right" some more on egg curves:
http://www.mathematische-basteleien.de/eggcurves.htm
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 31, 2022, 04:04:30 pm
I would say, if you know how to make a 3D ball using vectors, you might be able to figure out how to use the mouse to elongate one side of the ball to make it look just like an egg. Then you can copy the picture and save it. Or copy the variables and save them for an egg app. Wouldn't that be awesome! Don't look at me though, 3D vectors are a ways past my learning curve right now.
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 31, 2022, 05:01:25 pm
Here is my Easter Egg. Of course it's not as real looking as the ones you guys are doing. But at least it's something, maybe for our less-mathematically oriented people. :)

Code: QB64: [Select]
  1. Screen _NewImage(800, 600, 32)
  2. y = 300
  3. cl = 100
  4. cl2 = 20
  5. egg = 1.25
  6. sz = 100
  7. For x = 400 To 410 Step .002
  8.     sz = sz - .01
  9.     egg = egg + .01
  10.     cl = cl + .001
  11.     cl2 = cl2 + 1
  12.     If cl > 150 Then cl = 150
  13.     Circle (x, y), sz, _RGB32(cl2, 255, cl), , , egg
  14.  
  15.  
  16.  
Title: Re: Easter Egg Decorating
Post by: SMcNeill on March 31, 2022, 05:51:04 pm
Code: QB64: [Select]
  1. WorkScreen = _NewImage(800, 800, 32)
  2. DisplayScreen = _NewImage(800, 800, 32)
  3. egg = _LoadImage("egg.png", 32)
  4. Screen DisplayScreen
  5.  
  6. _Dest WorkScreen
  7. Stepp = 25 'change this for bigger or smaller bands of colors
  8. For i = 0 To 800 Step Stepp
  9.     Line (0, i)-Step(800, Stepp), &H88000000 + Rnd * &HFFFFFF, BF
  10. _Dest DisplayScreen
  11.  
  12.  
  13. For y = 0 To _Height(egg) - 1
  14.     For x = 0 To _Width(egg) - 1
  15.         _Source egg
  16.         p&& = _Alpha(Point(x, y))
  17.         If p&& > 200 Then
  18.             _Source WorkScreen
  19.             p&& = Point(x, y)
  20.             PSet (x, y), p&&
  21.         End If
  22.     Next
  23.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

(The base egg.png is included below for usage. )
Title: Re: Easter Egg Decorating
Post by: SMcNeill on March 31, 2022, 05:57:28 pm
One quirk of doing things the way I have above, is that it allows us to basically take two distinct images and then merge them together into the final result.  I start with the image of an egg, and an image of a rainbow screen.  I then basically take the rainbow colors from it's screen, wherever the egg would appear on its screen, and then copy those onto the display screen...

Using this method, I could also, conceivably, take egg-shaped portions of screens from a movie and then put them onto the display, only showing the "egg portion" out of the movie screen.  Or I could take egg-shaped images from moving flames or raindrops falling, and then display them to the screen, as I'm not so much coloring an egg, as just taking the egg-shape color information from a different image.

Movie Easter Eggs -- how great is that concept?!!
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 31, 2022, 07:52:04 pm
That's awesome Steve! I got all kinds of ideas flowing.
Title: Re: Easter Egg Decorating
Post by: SierraKen on March 31, 2022, 08:27:27 pm
Here is a mod from Steve's Easter Egg. It randomly makes an egg every second with different thickness of colors and it's either horizontal stripes or vertical stripes. Took me a little bit to figure that out. :) Press any key to stop it.

Code: QB64: [Select]
  1. 'Steve's Easter Egg  - mod by SierraKen 3-31-2022
  2. WorkScreen = _NewImage(800, 800, 32)
  3. DisplayScreen = _NewImage(800, 800, 32)
  4. egg = _LoadImage("egg.png", 32)
  5. Screen DisplayScreen
  6. _Title "Steve's Easter Egg mod by SierraKen"
  7.     _Limit 30
  8.     _Dest WorkScreen
  9.  
  10.     r = Int(Rnd * 2) + 1
  11.     If r = 1 Then GoTo one:
  12.     If r = 2 Then GoTo two:
  13.  
  14.     one:
  15.     Stepp = Int(Rnd * 50) + 10 'change this for bigger or smaller bands of colors
  16.     For i = 0 To 800 Step Stepp
  17.         Line (i, 0)-Step(Stepp, 800), &H88000000 + Rnd * &HFFFFFF, BF
  18.     Next
  19.     _Dest DisplayScreen
  20.     _Blend
  21.     For y = 0 To _Height(egg) - 1
  22.         For x = 0 To _Width(egg) - 1
  23.             _Source egg
  24.             p&& = _Alpha(Point(x, y))
  25.             If p&& > 200 Then
  26.                 _Source WorkScreen
  27.                 p&& = Point(x, y)
  28.                 PSet (x, y), p&&
  29.             End If
  30.         Next x
  31.     Next y
  32.     GoTo done:
  33.     two:
  34.     Stepp = Int(Rnd * 50) + 10 'change this for bigger or smaller bands of colors
  35.     For i = 0 To 800 Step Stepp
  36.         Line (0, i)-Step(800, Stepp), &H88000000 + Rnd * &HFFFFFF, BF
  37.     Next
  38.     _Dest DisplayScreen
  39.     _Blend
  40.     For x = 0 To _Width(egg) - 1
  41.         For y = 0 To _Height(egg) - 1
  42.             _Source egg
  43.             p&& = _Alpha(Point(x, y))
  44.             If p&& > 200 Then
  45.                 _Source WorkScreen
  46.                 p&& = Point(x, y)
  47.                 PSet (x, y), p&&
  48.             End If
  49.         Next y
  50.     Next x
  51.     done:
  52.     p&& = 0
  53.     _Delay 1
  54.     a$ = InKey$
  55.     Cls
  56. Loop Until a$ <> ""
  57.  
Title: Re: Easter Egg Decorating
Post by: _vince on April 01, 2022, 05:02:15 am
I typed out the egg-case for that theory of everything egguation:

Code: QB64: [Select]
  1. 'scale
  2. s = 80
  3.  
  4. L = 5.4
  5. B = 4.1
  6. w = 0.4
  7. D = 3.2
  8.  
  9.  
  10. sw = 800
  11. sh = 600
  12. screen _newimage(sw, sh, 32)
  13.  
  14.  
  15. for xx=-0.5*L*s to 0.5*L*s
  16.         x = xx/s       
  17.         a = (L*L - 4*x*x)/(L*L + 8*w*x + 4*w*w)
  18.         y = 0.5*B*sqr(a)
  19.         'you can stop here for p(x) = x
  20.  
  21.         a = sqr(5.5*L*L + 11*L*w + 4*w*w)
  22.         a = a*(sqr(3)*B*L - 2*D*sqr(L*L + 2*w*L + 4*w*w))
  23.         a = a/(sqr(3)*B*L*(sqr(5.5*L*L + 11*L*w + 4*w*w) - 2*sqr(L*L + 2*w*L + 4*w*w)))
  24.  
  25.         aa = L*(L*L + 8*w*x + 4*w*w)
  26.         aa = aa/(2*(L - 2*w)*x*x + (L*L + 8*L*w - 4*w*w)*x + 2*L*w*w + L*L*w + L*L*L)
  27.         aa = 1 - aa
  28.  
  29.         y = y*(1 - a*aa)
  30.  
  31.         line (sw/2 + xx, sh/2 - s*y)-(sw/2 + xx, sh/2 + s*y)
  32.  
  33.  
  34.  

Note: I also got the coefficients by measuring a real egg with a ruler in centimeters, had to eyeball quite a bit.  You'd want some kind of scanner or at least calipers as the formula is pretty sensitive to certain parameters like w and D_{L/4}
Title: Re: Easter Egg Decorating
Post by: SMcNeill on April 01, 2022, 09:22:06 am
Matrix Rain Easter Egg!

Code: QB64: [Select]
  1. WorkScreen = _NewImage(800, 800, 32)
  2. DisplayScreen = _NewImage(800, 800, 32)
  3. egg = _LoadImage("egg.png", 32)
  4. Screen DisplayScreen
  5. Cls , -1
  6.  
  7.  
  8. For i = 1 To UBound(m)
  9.     m(i) = -Int(Rnd * _Height)
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.     _Dest WorkScreen
  17.     Line (0, 0)-(_Width, _Height), _RGBA32(0, 0, 0, 20), BF
  18.  
  19.     For i = 1 To UBound(m)
  20.         Color _RGB32(0, 255, 0), 0
  21.         m(i) = m(i) + _FontHeight
  22.         If m(i) > 0 Then
  23.             If m(i) > _Height Then m(i) = -Int(Rnd * _Height)
  24.             _PrintString (i * _FontWidth - _FontWidth, m(i)), Chr$(_Ceil(Rnd * 254))
  25.         End If
  26.     Next
  27.  
  28.     For y = 0 To _Height(egg) - 1
  29.         For x = 0 To _Width(egg) - 1
  30.             _Source egg
  31.  
  32.             p&& = _Alpha(Point(x, y))
  33.  
  34.             _Source WorkScreen
  35.             If p&& > 200 Then
  36.                 p&& = Point(x, y)
  37.                 _Dest DisplayScreen
  38.                 PSet (x, y), p&&
  39.             End If
  40.         Next
  41.     Next
  42.     _Display
  43.  

Make certain to grab and use the egg.png from the previous post, if you need it in your QB64 folder.

This is basically just an example of what I was talking of above, about being able to place a flame, movie, or rain upon my egg.  I thought Ken might like it, and it might give him a few ideas for more neat little mods he can do with it.  ;)
Title: Re: Easter Egg Decorating
Post by: dbox on April 01, 2022, 09:30:10 am
When in Rome...

Here is a QBJS mod based on @vince's creation - Egg Designer 2000.

View on QBJS (https://v6p9d9t4.ssl.hwcd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Yra0sjI2Ms3w17YsE2tLcg9fDx08EJtYXhB7mn+EjSaBuboyuCD38JmuyitLPhS0Vf4B8L6Ly9UUfQGjqqrzWHXw47wG8dJbWFyZ2luTGVmdEmUOFJz+HJJH96y/vW/18PHEuqNpV2+HriM4k+TVG8l7/D33hdyio69xYNn0fCDySVHv4S+R2ukww+FnnIuxe3wjC6z/wtXW/Hf6fZ6ZO9D8u94DHzX889Xd/8fV38Ml2rx751g7N/hp73a6HdQ+Gnu373PcLodvT4a+9c+2YU9SXa6h8NZ9Owl+G0+mYUX3wHM+hh5WQHfMuYAAgOWWdxPH4zztU2lldoDmn7THWlf9+BWA5ZdPFcXqpO0B3S9MrXm0B3SRS0YNlfBXgO6za2dlij/d0cEB3WrMqID61VZS3QH1uZpKgObafRAftuvPHI40aNirUbGch/apaitsRXa+JD9t8aY4vooZyELcRtjh4kIWr34XBbZ4GZCF7V9a2zTFX8NEBK+cbUwEr5ttVZZASvxtqLJAcI2nAAAAEBxI6I3tqK7Mrc6ILC17vZcwTm6sVz8HIf5oLC1//thb9f1SGFP3oaqv5+vJ5KQ/R+1DWRGdz2+1IW53NLWfRWz8/iMvu5icg==)

Code: QB64: [Select]
  1. _Title "Egg Designer 2000"
  2. Dim Shared s, L, B, w, D, sw, sh, xx, x, a, y, aa
  3. Dim Shared ctlS, ctlL, ctlB, ctlW, ctlD
  4.  
  5. sw = 800
  6. sh = 600
  7. Screen _NewImage(sw, sh, 32)
  8.  
  9. InitControls
  10. DrawEgg
  11.  
  12. Sub DrawEgg
  13.     Cls
  14.     s = ctlS.value
  15.     L = ctlL.value / 10
  16.     B = ctlB.value / 10
  17.     w = ctlW.value / 10
  18.     D = ctlD.value / 10
  19.    
  20.     For xx = -0.5 * L * s To 0.5 * L * s
  21.         x = xx / s
  22.         a = (L * L - 4 * x * x) / (L * L + 8 * w * x + 4 * w * w)
  23.         y = 0.5 * B * Sqr(a)
  24.         'you can stop here for p(x) = x
  25.  
  26.         a = Sqr(5.5 * L * L + 11 * L * w + 4 * w * w)
  27.         a = a * (Sqr(3) * B * L - 2 * D * Sqr(L * L + 2 * w * L + 4 * w * w))
  28.         a = a / (Sqr(3) * B * L * (Sqr(5.5 * L * L + 11 * L * w + 4 * w * w) - 2 * Sqr(L * L + 2 * w * L + 4 * w * w)))
  29.  
  30.         aa = L * (L * L + 8 * w * x + 4 * w * w)
  31.         aa = aa / (2 * (L - 2 * w) * x * x + (L * L + 8 * L * w - 4 * w * w) * x + 2 * L * w * w + L * L * w + L * L * L)
  32.         aa = 1 - aa
  33.  
  34.         y = y * (1 - a * aa)
  35.  
  36.         Line (sw / 2 + xx, sh / 2 - s * y)-(sw / 2 + xx, sh / 2 + s * y)
  37.     Next
  38.  
  39. Sub InitControls
  40.     Dim c: c = DomCreate("div")
  41.     c.style.padding = "20px"
  42.    
  43.     DomCreate "span", c, "s: "
  44.     Dim e: e = DomCreate("input", c)
  45.     e.type = "range"
  46.     e.style.width = "125px"
  47.     e.style.verticalAlign = "middle"
  48.     e.min = 1
  49.     e.max = 100
  50.     e.step = 1
  51.     e.value = 80
  52.     ctlS = e
  53.        
  54.     e = DomCreate("span", c, "L: ")
  55.     e.style.marginLeft = "20px"
  56.     e = DomCreate("input", c)
  57.     e.type = "range"
  58.     e.style.verticalAlign = "middle"
  59.     e.style.width = "125px"  
  60.     e.min = 1
  61.     e.max = 100
  62.     e.value = 54
  63.     ctlL = e
  64.  
  65.     e = DomCreate("span", c, "B: ")
  66.     e.style.marginLeft = "20px"
  67.     e = DomCreate("input", c)
  68.     e.type = "range"
  69.     e.style.verticalAlign = "middle"
  70.     e.style.width = "125px"  
  71.     e.min = 1
  72.     e.max = 100
  73.     e.value = 41
  74.     ctlB = e
  75.            
  76.     e = DomCreate("span", c, "w: ")
  77.     e.style.marginLeft = "20px"
  78.     e = DomCreate("input", c)
  79.     e.type = "range"
  80.     e.style.verticalAlign = "middle"
  81.     e.style.width = "125px"  
  82.     e.min = 1
  83.     e.max = 20
  84.     e.value = 4
  85.     ctlW = e
  86.  
  87.     e = DomCreate("span", c, "D: ")
  88.     e.style.marginLeft = "20px"
  89.     e = DomCreate("input", c)
  90.     e.type = "range"
  91.     e.style.verticalAlign = "middle"
  92.     e.style.width = "125px"  
  93.     e.min = 1
  94.     e.max = 100
  95.     e.value = 32
  96.     ctlD = e
  97.                        
  98.     DomEvent ctlS, "input", sub_DrawEgg
  99.     DomEvent ctlL, "input", sub_DrawEgg
  100.     DomEvent ctlB, "input", sub_DrawEgg
  101.     DomEvent ctlW, "input", sub_DrawEgg
  102.     DomEvent ctlD, "input", sub_DrawEgg
  103.  
Title: Re: Easter Egg Decorating
Post by: STxAxTIC on April 01, 2022, 09:54:52 am
Holy crap, vince and dbox win. Bro, lemme make that link bigger:

THIS THIS THIS (https://v6p9d9t4.ssl.hwcdn.net/html/5512918/index.html?qbcode=BfIqNLo2MoBBAIgSKzs7jojK5tLO3MrlIBkAGFcOAFQJEaW08VTaGFyZWRADnoBZcAmPtAQslAdzMAiLEFzd7kC5tFtgvDx4AHj2QGFtAPLHBYWGIHZwDY3RsUzYGxujYmGkNjdGxCNQbG6Niud4bG6NiI+1egA97ADitb+IOCAbPj5CqbG5MrK3QWo6cyu6S2sLOytgFBfA88AZ9sQClkxENvbG9ylgDFEA1ZnCUluaXRDb250cm8cFscykMiOTC7orOzkihKbqxMktagSG2OZ/2nPvEgC66I7MLY6sp/63fuBoznAF+5uP9Vm1hJHbe1cf99yxNNHX5jX/fcmRVSiUf7zgthIze5KBJGALf+1aIAVNaEtKECqN7/sNBeHR20AiEkVM76Ad9hG/35ahUAA0WPlkn/ZY99nbd1gFaBeP5R6dK6ai8s5dVgH3Ub4wsv1l0hKbi5U/jBYBuAE9SE8t7qxgmNhbkWG5uje4MQNoZXJlToTM3uTSAcNsWxNRVAFVNr4N/H5h2y7c79Ey+cfEZnPP7yz7QBoTdnkuNLoIHkd582GM823npf4+gxO19g+m3vVDZLmaz4B7Se3lxc47+ql1SanG7rrp3WmxZzeYWLscPCkxwx1s4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ating
Post by: bplus on April 01, 2022, 11:37:54 am
Holy crap, vince and dbox win. Bro, lemme make that link bigger:

...

They haven't gotten to decorating yet and STx is already voting!

Who cares about colors it's all about the math! LOL
Title: Re: Easter Egg Decorating
Post by: SierraKen on April 01, 2022, 12:34:00 pm
That's neat Steve but there's no egg anywhere on the screen. The Matrix letters just fall everywhere.

Vince that's really cool! I started to attempt something like that yesterday but I think I had a problem with the square root of a negative number and I just wasn't figuring out the math good enough.
DBox, I get an Illegal String Conversion error on Line 42.
Code: QB64: [Select]
  1.  Dim c: c = DomCreate("div")
  2.  

Title: Re: Easter Egg Decorating
Post by: dbox on April 01, 2022, 12:38:01 pm
They haven't gotten to decorating yet and STx is already voting!

Who cares about colors it's all about the math! LOL

Updated with maths AND colors: View in QBJS (https://v6p9d9t4.ssl.hwcdn.net/html/5512918/index.html?qbcode=BfIqNLo2MoBBAIgSKzs7jojK5tLO3MrlIBkAGFcOAFQJEaW08VTaGFyZWRADnoBZcAmPtAQslAdzMAiLEFzd7kC5tFtgvDx4AHj2QGFtAPLHBYWGIHZwDY3RsUzYGxujYmGkNjdGxCNQbG6Niud4bG6NiI+1egA97ADitb+IOCAbPj5CqbG5MrK3QWo6cyu6S2sLOytgFBfA88AZ9sQClkxENvbG9ylgDFEA1ZnCUluaXRDb250cm8cFscykMiOTC7orOzkihKbqxMktagSG2OZ/2nPvEgC66I7MLY6sp/63fuBoznAF+5uP9Vm1hJHbe1cf99yxNNHX5jX/fcmRVSiUf7zggWwGnUYFjd8sA6SKLPgkBIze5KBFCALfbUCAAVI7+VN/Aqje93/v1zZXHQH4CksyTeoSa3siGw6yw1RoZW5oAEo5glJuZHxx4AGjFAK3GAAbF3bqVjqEUm91bmSV6611d9TADmCRW5kefMAPOsgonvADmrOX6tTP641rTapPElVKXytzuYi5UmxHUEkZRPlWAcxRieam5VnCEpuLlp2slAFgATwoTy3uqWCY2FuesNzdG9wSgbQyuTKgQmZvck0A4ffXtJ+qgCGkn/+zb4XattWdr027cdWl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Hm1+E5urFr+mSFXX8Rs/j3Vc3L2pC4X0xtUP2uDP2eQ+hCo2bKG6319OQp7raGeiKtP390289OZuY=)
Title: Re: Easter Egg Decorating
Post by: dbox on April 01, 2022, 12:40:14 pm
That's neat Steve but there's no egg anywhere on the screen. The Matrix letters just fall everywhere.

Vince that's really cool! I started to attempt something like that yesterday but I think I had a problem with the square root of a negative number and I just wasn't figuring out the math good enough.
DBox, I get an Illegal String Conversion error on Line 42.
Code: QB64: [Select]
  1.  Dim c: c = DomCreate("div")
  2.  


Hey @SierraKen, is there more to that program?  I don't see any errors when I run just that line in a new QBJS window.
Title: Re: Easter Egg Decorating
Post by: SierraKen on April 01, 2022, 12:45:56 pm
DBox, I ran it  on QB64, I don't have QBJS.
Title: Re: Easter Egg Decorating
Post by: dbox on April 01, 2022, 01:05:51 pm
DBox, I ran it  on QB64, I don't have QBJS.

Oh, I see.  Yes, I'm afraid that example won't run in QB64 since it uses web controls.  QBJS is just a web page, you don't actually have to have anything installed you can view and run the code by just Clicking this link (https://v6p9d9t4.ssl.hwcdn.net/html/5512918/index.html?qbcode=BfIqNLo2MoBBAIgSKzs7jojK5tLO3MrlIBkAGFcOAFQJEaW08VTaGFyZWRADnoBZcAmPtAQslAdzMAiLEFzd7kC5tFtgvDx4AHj2QGFtAPLHBYWGIHZwDY3RsUzYGxujYmGkNjdGxCNQbG6Niud4bG6NiI+1egA97ADitb+IOCAbPj5CqbG5MrK3QWo6cyu6S2sLOytgFBfA88AZ9sQClkxENvbG9ylgDFEA1ZnCUluaXRDb250cm8cFscykMiOTC7orOzkihKbqxMktagSG2OZ/2nPvEgC66I7MLY6sp/63fuBoznAF+5uP9Vm1hJHbe1cf99yxNNHX5jX/fcmRVSiUf7zggWwGnUYFjd8sA6SKLPgkBIze5KBFCALfbUCAAVI7+VN/Aqje93/v1zZXHQH4CksyTeoSa3siGw6yw1RoZW5oAEo5glJuZHxx4AGjFAK3GAAbF3bqVjqEUm91bmSV6611d9TADmCRW5kefMAPO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B827Mra/WQY1o9drZSH1YlYo2t/v0rSHzb1zvruVBykPq6ttfVYkPq0a6nUNsafEh/W1XTNsV/aPDgkP7aNtdIf20Ta+uuQhbkbRL/Iew2hIAAAEhqQ6I3tqK7Mrc6P/jY9Hm1+E5urFr+mSFXX8Rs/j3Vc3L2pC4X0xtUP2uDP2eQ+hCo2bKG6319OQp7raGeiKtP390289OZuY=)
Title: Re: Easter Egg Decorating
Post by: bplus on April 01, 2022, 01:07:37 pm
OK!

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Easter Egg Decorating
Post by: SMcNeill on April 01, 2022, 01:13:36 pm
That's neat Steve but there's no egg anywhere on the screen. The Matrix letters just fall everywhere.

They're not falling inside the egg for you?   Shouldn't you be seeing something like this:

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Here, I've painted the egg itself BLACK, so that the green matrix letters show up better on it and are easier to see as they move and rain down across the surface of the egg.   Are you not getting this effect somehow?
Title: Re: Easter Egg Decorating
Post by: SierraKen on April 01, 2022, 01:25:26 pm
Oh that is awesome DBox! I had no idea that existed. Pretty cool egg maker too!
B+, I had a feeling you were going to go wild on us.. LOLOL, awesome.
Steve, no it doesn't show the egg, I have the .png in the same folder too. But that looks awesome!
Title: Re: Easter Egg Decorating
Post by: SMcNeill on April 01, 2022, 01:26:01 pm
Maybe it'll look a little more egglike for you, if I use a different color scheme?

Code: QB64: [Select]
  1. WorkScreen = _NewImage(800, 800, 32)
  2. DisplayScreen = _NewImage(800, 800, 32)
  3. egg = _LoadImage("egg.png", 32)
  4. font = _LoadFont("courbd.ttf", 36, "monospace")
  5. Screen DisplayScreen
  6.  
  7.  
  8.  
  9. For i = 1 To UBound(m)
  10.     m(i) = -Int(Rnd * _Height)
  11.  
  12. _Dest WorkScreen
  13. _Font font
  14.  
  15.  
  16.     _Dest WorkScreen
  17.  
  18.     Line (0, 0)-(_Width, _Height), &H20D2B48C, BF '_RGBA32(0, 0, 0, 20), BF
  19.  
  20.     For i = 1 To UBound(m)
  21.         Color _RGB32(0, 255, 0), 0
  22.         m(i) = m(i) + _FontHeight
  23.         If m(i) > 0 Then
  24.             If m(i) > _Height Then m(i) = -Int(Rnd * _Height)
  25.             _PrintString (i * _FontWidth - _FontWidth, m(i)), Chr$(_Ceil(Rnd * 254))
  26.         End If
  27.     Next
  28.  
  29.     For y = 0 To _Height(egg) - 1
  30.         For x = 0 To _Width(egg) - 1
  31.             _Source egg
  32.  
  33.             p&& = _Alpha(Point(x, y))
  34.  
  35.             _Source WorkScreen
  36.             If p&& > 200 Then
  37.                 p&& = Point(x, y)
  38.                 _Dest DisplayScreen
  39.                 PSet (x, y), p&&
  40.             End If
  41.         Next
  42.     Next
  43.     _Display
  44.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Does this make it a little more obvious that the letters are raining down across the eggshell?  Or should I just toss the matrix rain idea and see if something like flickering flames might look better for an animated egg paint?
Title: Re: Easter Egg Decorating
Post by: SMcNeill on April 01, 2022, 01:29:10 pm
Steve, no it doesn't show the egg, I have the .png in the same folder too. But that looks awesome!

Windows machine?  Let's rule out something simple like a upper/lowercase situation with Linux filenames and such to begin with.  I'm curious why the heck you're not seeing the same effect that I am with the code.  Latest version of QB64 too, I take it? 

Umm...

(Starts digging into the code to see where the heck the overlays might be messing up on different systems...)
Title: Re: Easter Egg Decorating
Post by: SierraKen on April 01, 2022, 01:29:24 pm
Steve I found the problem, I accidentally didn't copy/paste the first line WorkScreen = _NewImage(800, 800, 32)   
LOL DOH.
I'll try your other one now.
Title: Re: Easter Egg Decorating
Post by: SMcNeill on April 01, 2022, 01:34:15 pm
Steve I found the problem, I accidentally didn't copy/paste the first line WorkScreen = _NewImage(800, 800, 32)   
LOL DOH.
I'll try your other one now.

LOL!  Had me all worried that there was something majorly off in the code.  Unfortunately, I'm now going to have to add your name to my EVIL CODER list, right below Pete's entry!  I was trying to sip on my coffee when I read your response, and you made me chuckle so badly that I snorted hot coffee out my nose!

If *that* doesn't qualify someone to be listed as an EVIL CODER, then I don't know what does!  :P
Title: Re: Easter Egg Decorating
Post by: SierraKen on April 01, 2022, 01:40:24 pm
ROFL.... you might chuckle even more to find out that I'm a preacher at my Christian church. :)

Your other one is awesome! I might have to use your Matrix code on stuff sometimes.
Title: Re: Easter Egg Decorating
Post by: CharlieJV on April 01, 2022, 06:26:36 pm
(SNIP!)

Hey, thanks for sharing that code!  BASIC Anywhere Machine (https://basicanywheremachine.neocities.org/) version:

Title: Re: Easter Egg Decorating
Post by: bplus 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.
Title: Re: Easter Egg Decorating
Post by: CharlieJV 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 (https://basicanywheremachine.neocities.org/sample_programs/Easter%20Egg%20Decorating.bas.html), run program (https://basicanywheremachine.neocities.org/sample_programs/Easter%20Egg%20Decorating.run.html)

The alternative one with line: view source code (https://basicanywheremachine.neocities.org/sample_programs/Easter%20Egg%20Decorating2.bas.html), run program (https://basicanywheremachine.neocities.org/sample_programs/Easter%20Egg%20Decorating2.run.html)



Title: Re: Easter Egg Decorating
Post by: bplus 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.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Easter Egg Decorating
Post by: SierraKen 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.
Title: Re: Easter Egg Decorating
Post by: bplus 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.
Title: Re: Easter Egg Decorating
Post by: dbox on April 01, 2022, 11:37:24 pm
Yeah here are some cherry picked Textured Eggs:

B+ Textured Egg Slideshow (https://v6p9d9t4.ssl.hwcdn.net/html/5512918/index.html?mode=auto&qbcode=BfIqNLo2MoBBAIhLI5MLuisLm6MrlhIrOzsOqMrw6OrkysnQAnwDEwCtgBkQDAfABb3gDPOOmBNreyEc9tQDTagBjhCYWRk4AOUwCyQDPnp8kODC5MLayujK5OACqkoje2o7K6JLaws9AGVYBQ1AFLQC6Ajm6PLYy/zisTe5MjK5dIB79rtLBENvbnN05AVBp5PYGlGEiNLb8RHNjYWxl1s8Xk2AN6wDXWAKI3yq0gpLMhuFUmVzaXplYQ1RoZW6VVqx7MAeFcEd2lkdGiNIJJUmVzaXplV2lkdDgGhP//baZtgw4rQytLO0OmvUUSpMrm0vTKkMrSz3QWh0T/ICRW5k3cR/jhIbY51/onnMURXaWR0aMIAv7sc5IqQytLO0OmB7x4ASk3MnYAKtDJcFvX9d7py19z3bUuiAlXERGVsYXluOMNMb29wiI/glN1YkSHtMQXhjnugXljv1DkyXJhZGlhbkFuZ2xhOaXQL02eI3/cBOTOxdeC5t+mCY2FuzIbI5MLvpAnRoZe7Dc2FtZa/1bVAPCagB5TtwGNM8AwzkQGSv84EjN7ln/fpw82CqN/kRYam6Mrg5X2SAa9vWauhrVrWVNs5AA2W01gDxZUN2yQ7aXYxjcM0NFbHNlUmS8tXY72+kACsvVVZaUX3S7XqsBefFlxvMgGza1LKsvlT3Wr/DznrMZiHlYpEdWBt7k0s/gAAtqSWAPnH34AAA+IiG3tje5MJoJSR0K/7gl31wDhMjkqa+ywlCcUyOTF0iXpwJTaW67UyRkV1oftwxszf62daFW4b3bP9z5+nfm+TWlmIQR88y2U6NbM/U+eZdquknj98puPrvIAAf3oAAAhaWE50vdS/HRqcNJix8pNjubdq7o3fko54RLMf+bd759bxnLI0Il3h99oAAOwSdAAB6KJF2g0F0YW7EJ6LP2gAA7NMiLuAEpuLlDKuzvqphb/oAAM0GoKbK6I98+s2wzISG3ucuCjd7zwk51ci2FacSuab0hDIAHCWMgGnDTmV4dNhoHv8aZ3vd)
Title: Re: Easter Egg Decorating
Post by: SierraKen 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.