Ooops
July 04, 2020, 11:55:26 AM

### Author Topic: Diagonal Eggs  (Read 702 times)

#### bplus ##### Diagonal Eggs
« on: February 26, 2020, 07:20:37 PM »
Code: [Select]
`'copy from round157 2020-02-26 Syntax Bomb, ' https://www.syntaxbomb.com/index.php/topic,6677.msg347040125.html#msg347040125' BASIC-256 trans to SmallBASIC b+ 2020-02-26const w = 530: const h = 870wh = window()wh.setsize (w, h)clsk1 = .25 * h : k2 = .5 * h : k3 = .75 * hj = .25 * wy2 = k1 : y3 = k2 : y4 = k3for x1 = 0 to w  x2 = j  for y1 = 0 to h    x2 = x2 + .5    x12 = (x1 - x2)^2    y12 = (y1 - y2)^2    y13 = (y1 - y3)^2    y14 = (y1 - y4)^2    xy1 = (x12 + y12)^.5    xy2 = (x12 + y13)^.5    xy3 = (x12 + y14)^.5    r = xy1 % 255    g = xy2 % 255    b = xy3 % 255    pset x1, y1, rgb(r, g, b)  next  showpagenext`

#### bplus ##### Re: Diagonal Eggs
« Reply #1 on: February 26, 2020, 07:43:33 PM »
Aurel:
Quote
Yes it is not very smart always share your code.

Yeah so code can sit and stagnate Here is Diagonal Eggs on the move horizontally:
Code: [Select]
`'copy from round157 2020-02-26 Syntax Bomb, ' https://www.syntaxbomb.com/index.php/topic,6677.msg347040125.html#msg347040125' BASIC-256 trans to SmallBASIC b+ 2020-02-26' from Diagonal Eggs, let's see if we can do something with it?' Diagonal Eggs 2.bas b+ 2020-02-26' Yes, Diagonal Eggs On The Move Horizontallyconst w = 500: const h = 500wh = window()wh.setsize (w, h)clsk1 = .25 * h : k2 = .5 * h : k3 = .75 * hj = .25 * wy2 = k1 : y3 = k2 : y4 = k3dx = 1while 1  cls  for x1 = a to w + a    x2 = j    for y1 = 0 to h      x2 = x2 + .5      x12 = (x1 - x2)^2      y12 = (y1 - y2)^2      y13 = (y1 - y3)^2      y14 = (y1 - y4)^2      xy1 = (x12 + y12)^.5      xy2 = (x12 + y13)^.5      xy3 = (x12 + y14)^.5      r = xy1 % 255      g = xy2 % 255      b = xy3 % 255      pset x1 - a, y1, rgb(r, g, b)    next  next  print a  showpage  a = a + 5 * dx  IF a >= 500 OR a <= -500 THEN dx = -dxwend   `
EDIT: Translating to QB64 showed some errors in SB code I had, moving diagonally was creating hole.

#### Aurel ##### Re: Diagonal Eggs
« Reply #2 on: February 27, 2020, 07:17:36 AM »
He he...
I don't talk about our graphic examples Mark
i have one guy on my old forum who selling some kind of lottery programs.
He don't want to share his code with me..

#### round157

• Sr. Member
•    • Posts: 352 ##### Re: Diagonal Eggs
« Reply #3 on: February 27, 2020, 10:29:14 AM »

Ha....the program was not written by me.

I only used the screenshot on this webpage:
https://imaginary.org/fr/users/joel-kahn

#### bplus ##### Re: Diagonal Eggs
« Reply #4 on: February 27, 2020, 02:49:16 PM »

Ha....the program was not written by me.

I only used the screenshot on this webpage:
https://imaginary.org/fr/users/joel-kahn

I knew that (I was just referencing the source I was translating from), I am getting impression neither you nor Aurel write code anymore, resting on our laurels are we?

I believe the secret to quality is quantity, I mean even the worst coder has got to get lucky sometime. ;-)) If they keep at it that is; and don't get cold and stiff from spending their days chatting about code.

I liked the coloring in this code and hoped to get some insight and make it be more dynamic. I was also hoping to show on QB64 how fast it runs but it's only about twice as fast, dang! it pauses between screens also. But in QB64 I can take a whole different graphics approach for more dynamic eggs, in SB too I guess.

You guys want to give it a shot? Get the ellipsis to move, resize, change color, change tilts,... actually make them egg shaped!

Well alittle bit of chat can be motivating. Looking forward to seeing your SmallBASIC code, bye!

#### Aurel ##### Re: Diagonal Eggs
« Reply #5 on: February 28, 2020, 06:42:49 AM »
Quote
I am getting impression neither you nor Aurel write code anymore, resting on our laurels are we?

Well, i don't for round157 but i am busy with one GUI program in OxygenBasic and with few new function for my new
innterpreter.
But is you insist i can make something in SB #### round157

• Sr. Member
•    • Posts: 352 ##### Re: Diagonal Eggs
« Reply #6 on: February 28, 2020, 08:53:56 AM »

Well alittle bit of chat can be motivating.

Actually, Blitz3D and BlitzMax were installed on my hard disk. In fact, I also owned AppGameKit. But really busy in real life. Nowadays you can treat me as a read-only visitor of this forum.

#### bplus ##### Re: Diagonal Eggs
« Reply #7 on: February 28, 2020, 04:05:21 PM »
Quote
But really busy in real life.

Yeah, I know life can be a handful or a dozen.

#### bplus ##### Re: Diagonal Eggs
« Reply #8 on: February 28, 2020, 04:15:12 PM »
Man what is wrong with these eggs?

Update: Besides the s-l-o-w way I am drawing them to skip the heavy math:
Code: [Select]
`'Dinosaur Eggs.bas for SmallBASIC v0.12.13def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lodef rdir = iff(rnd < .5, -1, 1)nEggs = 5DIM e(nEggs - 1)FOR i = 0 TO nEggs - 1  e(i).x1 = rand(0, xmax)  e(i).dx1 = rand(1, 5)  e(i).ddx1 = rdir  e(i).y1 = rand(0, ymax)  e(i).dy1 = rand(1, 5)  e(i).ddy1 = rdir  e(i).r1 = rand(50, 100)  e(i).red1 = 225  e(i).grn1 = 225  e(i).blu1 = 225  e(i).d = .9  * e(i).r1  e(i).a = rnd * pi * 2  e(i).da = rnd * pi / 12 - pi / 24  e(i).x2 = e(i).x1 + e(i).d * cos(e(i).a)  e(i).y2 = e(i).y1 + e(i).d * sin(e(i).a)  e(i).r2 = .3 * e(i).r1  e(i).red2 = rand(100, 180)  e(i).grn2 = rand(100, 180)  e(i).blu2 = rand(100, 180)nextwhile 1  cls  for i = 0 to nEggs - 1    drawEgg e(i).x1, e(i).y1, e(i).r1, e(i).x2, e(i).y2, e(i).r2, e(i).red1, e(i).grn1, e(i).blu1, e(i).red2, e(i).grn2, e(i).blu2    e(i).x1 = e(i).x1 + e(i).dx1 * e(i).ddx1    if e(i).x1 < 0 or e(i).x1 > xmax then      e(i).ddx1 = e(i).ddx1 * -1      if e(i).x1 < 0 then e(i).x1 = 0      if e(i).x1 > xmax then e(i).x1 = xmax    end if    e(i).y1 = e(i).y1 + e(i).dy1 * e(i).ddy1    if e(i).y1 < 0 or e(i).y1 > ymax then      e(i).ddy1 = e(i).ddy1 * -1      if e(i).y1 < 0 then e(i).y1 = 0      if e(i).y1 > ymax then e(i).y1 = ymax    end if    e(i).a = e(i).a + e(i).da    e(i).x2 = e(i).x1 + e(i).d * cos(e(i).a)    e(i).y2 = e(i).y1 + e(i).d * sin(e(i).a)      next  showpagewendsub drawEgg(x1, y1, r1, x2, y2, r2, red1, grn1, blu1, red2, grn2, blu2)  'yeah allot of redundancy but beats trying to figure out the math  local dx, dy, dist, maxr, fr1, fr2, r, cr1, cr2  dx = x2 - x1  dy = y2 - y1  dist = sqr(dx * dx + dy * dy)  if dist > 0 then    dx = dx / dist    dy = dy / dist  else    dx = 0 : dy = 0  end if  if r1 >= r2 then maxr = r1 else maxr = r2  fr1 = r1 / maxr : fr2 = r2 / maxr  for r = maxr to 0 step -1    midInk red1, grn1, blu1, red2, grn2, blu2, r / maxr    cr1 = fr1 * r : cr2 = fr2 * r    dr = (cr1 - cr2) / dist    for d = 0 to dist      circle x1 + d * dx, y1 + d * dy, cr1 + d * dr filled    next  nextendsub midInk(r1, g1, b1, r2, g2, b2, fr)  color rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)end`

#### Aurel ##### Re: Diagonal Eggs
« Reply #9 on: February 28, 2020, 04:19:58 PM »
WOW
my chicken don't have such a colorful eggs when i say that i work on something ,here is ...

#### bplus ##### Re: Diagonal Eggs
« Reply #10 on: February 28, 2020, 05:10:14 PM »

#### Aurel ##### Re: Diagonal Eggs
« Reply #11 on: February 28, 2020, 07:01:28 PM »
Heh..yes No is not ,but that is just what you see on given image ,you don't see source code
and i can bet with you that you maybe will understand about 50% of code only.
GUI programming is very different than what you doing in basic-s.

by the way ..what is my goal with this , i would try to build simple code editor without need for
external sxintilla control in a scilexer.dll.
On this i have in plan to put whole my new interpreter into one exe.

#### round157

• Sr. Member
•    • Posts: 352 ##### Re: Diagonal Eggs
« Reply #12 on: February 29, 2020, 01:40:48 AM »
On this i have in plan to put whole my new interpreter into one exe.

You are developing an interpreter of a language? I am curious. What will be the name of this programming language?

#### Aurel ##### Re: Diagonal Eggs
« Reply #13 on: February 29, 2020, 07:06:57 AM »
heh currently is micro(A)

#### round157

• Sr. Member
•    • Posts: 352 ##### Re: Diagonal Eggs
« Reply #14 on: February 29, 2020, 12:28:28 PM »
heh currently is micro(A)

Nice project!