### Author Topic: New Web-based BASIC-like language: https://easylang.online/  (Read 2030 times)

#### Ed Davis

• Guest ##### New Web-based BASIC-like language: https://easylang.online/
« on: June 05, 2019, 11:02:13 am »
New Web-based BASIC-like language: https://easylang.online/

It is pretty cool.  Lots of examples at their website (above).  For instance, here is our old friend the mandelbrot:

Code: [Select]
`floatvarsfor y% range 300  cy = (y% - 150) / 120  for x% range 300    cx = (x% - 220) / 120    n% = 0    x = 0    y = 0    while x * x + y * y < 4 and n% < 128      h = x * x - y * y + cx      y = 2 * x * y + cy      x = h      n% += 1    .    if n% = 128      color_red 0    else      color_red n% / 16    .    move x% / 3 y% / 3    rect 0.4 0.4  ..`
It is pretty fun to play with!

#### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #1 on: June 05, 2019, 12:44:10 pm »
Interesting, Python like and min. punctuation, reminds me of BestOf's stuff (who started calling himself "easylang").

#### Ed Davis

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #2 on: June 05, 2019, 01:28:39 pm »
Interesting, Python like and min. punctuation, reminds me of BestOf's stuff (who started calling himself "easylang").

Not to be argumentative - well, but I guess I am :-) - I don't really see much Python in it.
Python uses indentation for syntax, this uses ".".   Python has lists and hashes, this does not.

This reminds me more of BASIC, what with the integer% and float# stuff.

And functions and subs look at least a little like BASIC:

Code: [Select]
`# compute the greatest common divisor# func gcd a b . res .  while b <> 0    h = b    b = a mod b    a = h  .  res = a.call gcd 120 35 rprint r`
I really don't like the "." syntax - much prefer the "end" style stuff, or even C's {}.

And it also has the infamous Fern, so it must be BASIC :-)

Code: [Select]
`floatvarscolor 060for i% range 200000  r = randomf  if r < 0.01    nx = 0    ny = 0.16 * y  elif r < 0.08    nx = 0.2 * x - 0.26 * y    ny = 0.23 * x + 0.22 * y + 1.6  elif r < 0.15    nx = -0.15 * x + 0.28 * y    ny = 0.26 * x + 0.24 * y + 0.44  else    nx = 0.85 * x + 0.04 * y    ny = -0.04 * x + 0.85 * y + 1.6  .  x = nx  y = ny  move 50 + x * 15 100 - y * 10  rect 0.3 0.3.`

#### Aurel

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #3 on: June 05, 2019, 02:33:52 pm »
he he
it is freaking BASIC...
...sooooo is not dead #### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #4 on: June 05, 2019, 08:27:12 pm »
Interesting, Python like and min. punctuation, reminds me of BestOf's stuff (who started calling himself "easylang").

Not to be argumentative - well, but I guess I am :-) - I don't really see much Python in it.
Python uses indentation for syntax, this uses ".".   Python has lists and hashes, this does not.

This reminds me more of BASIC, what with the integer% and float# stuff.

And functions and subs look at least a little like BASIC:

Code: [Select]
`# compute the greatest common divisor# func gcd a b . res .  while b <> 0    h = b    b = a mod b    a = h  .  res = a.call gcd 120 35 rprint r`
I really don't like the "." syntax - much prefer the "end" style stuff, or even C's {}.

And it also has the infamous Fern, so it must be BASIC :-)

Code: [Select]
`floatvarscolor 060for i% range 200000  r = randomf  if r < 0.01    nx = 0    ny = 0.16 * y  elif r < 0.08    nx = 0.2 * x - 0.26 * y    ny = 0.23 * x + 0.22 * y + 1.6  elif r < 0.15    nx = -0.15 * x + 0.28 * y    ny = 0.26 * x + 0.24 * y + 0.44  else    nx = 0.85 * x + 0.04 * y    ny = -0.04 * x + 0.85 * y + 1.6  .  x = nx  y = ny  move 50 + x * 15 100 - y * 10  rect 0.3 0.3.`

My opinion based on superficial look of one code sample, ha! the dots are like nothing... It does have a number of simple examples. I wonder about doing something more complex, say with image manipulation or alpha coloring.

BTW the elif and func are just like SmallBASIC.
« Last Edit: June 05, 2019, 08:29:22 pm by B+ »

#### Ed Davis

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #5 on: June 06, 2019, 04:54:49 am »
It does have a number of simple examples. I wonder about doing something more complex, say with image manipulation or alpha coloring.

And then click on "Edit with EasyLang" to see the code.

See here for other samples:  https://easylang.online/samples/

Being the ignorant old console oriented guy I am, I have no idea what alpha coloring is #### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #6 on: June 06, 2019, 12:51:16 pm »
Alpha is adding transparency to color.

Are all variables global? Range start at 1 or 0?

Where is decent Help for complete list and description of keywords?

3 digit color is something I worked up myself some time ago: 1000 permutations from R,G,B 0 to 9.
« Last Edit: June 06, 2019, 01:06:14 pm by B+ »

#### Ed Davis

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #7 on: June 06, 2019, 01:46:33 pm »
3 digit color is something I worked up myself some time ago: 1000 permutations from R,G,B 0 to 9.

This sounds very interesting! I'd really like to see this if you don't mind sharing it.

Are all variables global?

Good question.  I'm not really sure.   I found this:

Subroutines are defined with subr and called with call. Global variables are used for parameters and return values.

Functions are defined with func and called with call. Value and reference parameters are specified after the function name. Variables that occur for the first time within a function are local to that function.

Still not 100% clear to me.

Code: [Select]
`# greatest common divisor with a function# func gcd a b . res .  while b <> 0    h = b    b = a mod b    a = h  .  res = a.call gcd 120 35 rprint r`
Range start at 1 or 0?

I found this:

The field elements can be accessed using square brackets and a position specification, also called index. The first element is at position 0. len returns the number of elements in the array.

Definitely in need of additional reference material.

Where is decent Help for complete list and description of keywords?

Missing in action, it seems!  Hopefully the author will add it soon!

Alpha is adding transparency to color.

In terms of the Windows API, is that this guy?

SetLayeredWindowAttributes function

Sets the opacity and transparency color key of a layered window.

Syntax

Code: [Select]
`BOOL SetLayeredWindowAttributes(  HWND     hwnd,  COLORREF crKey,  BYTE     bAlpha,  DWORD    dwFlags);`Parameters

hwnd - Type: HWND

A handle to the layered window. A layered window is created by specifying WS_EX_LAYERED when creating the window with the CreateWindowEx function or by setting WS_EX_LAYERED via SetWindowLong after the window has been created.

crKey - Type: COLORREF

A COLORREF structure that specifies the transparency color key to be used when composing the layered window. All pixels painted by the window in this color will be transparent. To generate a COLORREF, use the RGB macro.

bAlpha - Type: BYTE

Alpha value used to describe the opacity of the layered window. Similar to the SourceConstantAlpha member of the BLENDFUNCTION structure. When bAlpha is 0, the window is completely transparent. When bAlpha is 255, the window is opaque.

dwFlags - Type: DWORD

An action to be taken. This parameter can be one or more of the following values.
Value    Meaning

LWA_ALPHA
0x00000002

Use bAlpha to determine the opacity of the layered window.

LWA_COLORKEY
0x00000001

Use crKey as the transparency color.

#### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #8 on: June 06, 2019, 03:48:22 pm »
Quote
Quote from: B+ on Today at 14:51:16
3 digit color is something I worked up myself some time ago: 1000 permutations from R,G,B 0 to 9.

This sounds very interesting! I'd really like to see this if you don't mind sharing it.

If you don't mind QB64 code Code: [Select]
`_TITLE "3 digit Colour System demo" 'B+ 2019-06-06'everything without Type Suffix will be Single'setup a graphics screenCONST xmaxScreen = 800 '<<< constants don't have to be typedCONST ymaxScreen = 600SCREEN _NEWIMAGE(xmaxScreen, ymaxScreen, 32) '<<< 32 means to use highest graphics RGBA color system_SCREENMOVE 300, 100 'put screen approx in middle of display for 1280X760 laptopcolour 950S\$ = "Here is Orange: colour 950"FOR i = 1 TO 10    LINE (RND * xmaxScreen * .4, RND * ymaxScreen)-STEP(80, 60), _DEFAULTCOLOR, BFNEXTLOCATE 20, 20: PRINT S\$colour 707S\$ = "And here is Purple: colour 707"FOR i = 1 TO 10    LINE (RND * xmaxScreen * .5 + .5 * xmaxScreen, RND * ymaxScreen)-STEP(80, 60), _DEFAULTCOLOR, BFNEXTLOCATE 20, 60: PRINT S\$SLEEP'set COLOR foreground for drawing or printing text FROM up to 3 digit integer parameterSUB colour (n AS INTEGER) 'can't use COLOR as is keyword    s3\$ = RIGHT\$("000" + LTRIM\$(STR\$(n)), 3)    r = VAL(MID\$(s3\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s3\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s3\$, 3, 1)): IF b THEN b = 28 * b + 3    COLOR _RGB32(r, g, b)END SUB' 2019-06-06 I will build an rgb sub off a mod of this because I can't find the SmallBASIC code or maybe SdlBasic codeFUNCTION rgba~& (n) ' New (even less typing!) New Color System 1000 colors with up to 3 digits    s4\$ = RIGHT\$("0000" + LTRIM\$(STR\$(n)), 4)    r = VAL(MID\$(s4\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s4\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s4\$, 3, 1)): IF b THEN b = 28 * b + 3    a = VAL(MID\$(s4\$, 4, 1)): IF a THEN a = 28 * a + 3    rgba~& = _RGBA32(r, g, b, a)END SUB`
With QB64 I have since moved on to using &HFFFF8C00 for Orange 950 and &HFF840084 for Purple 707:
Code: [Select]
`_TITLE "3 digit Colour System demo" 'B+ 2019-06-06'everything without Type Suffix will be Single'setup a graphics screenCONST xmaxScreen = 800 '<<< constants don't have to be typedCONST ymaxScreen = 600SCREEN _NEWIMAGE(xmaxScreen, ymaxScreen, 32) '<<< 32 means to use highest graphics RGBA color system_SCREENMOVE 300, 100 'put screen approx in middle of display for 1280X760 laptop'colour 950COLOR &HFFFF8C00S\$ = "Here is Orange: COLOR &HFFFF8C00"FOR i = 1 TO 10    LINE (RND * xmaxScreen * .4, RND * ymaxScreen)-STEP(80, 60), _DEFAULTCOLOR, BFNEXTLOCATE 20, 20: PRINT S\$'colour 707COLOR &HFFD400D4S\$ = "And here is Purple: COLOR &HFFD400D4"FOR i = 1 TO 10    LINE (RND * xmaxScreen * .5 + .5 * xmaxScreen, RND * ymaxScreen)-STEP(80, 60), _DEFAULTCOLOR, BFNEXTLOCATE 20, 60: PRINT S\$SLEEP'set COLOR foreground for drawing or printing text FROM up to 3 digit integer parameterSUB colour (n AS INTEGER) 'can't use COLOR as is keyword    s3\$ = RIGHT\$("000" + LTRIM\$(STR\$(n)), 3)    r = VAL(MID\$(s3\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s3\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s3\$, 3, 1)): IF b THEN b = 28 * b + 3    COLOR _RGB32(r, g, b)END SUB' 2019-06-06 I will build an rgb sub off a mod of this because I can't find the SmallBASIC code or maybe SdlBasic codeFUNCTION rgba~& (n) ' New (even less typing!) New Color System 1000 colors with up to 3 digits    s4\$ = RIGHT\$("0000" + LTRIM\$(STR\$(n)), 4)    r = VAL(MID\$(s4\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s4\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s4\$, 3, 1)): IF b THEN b = 28 * b + 3    a = VAL(MID\$(s4\$, 4, 1)): IF a THEN a = 28 * a + 3    rgba~& = _RGBA32(r, g, b, a)END SUB`

« Last Edit: June 06, 2019, 04:59:03 pm by B+ »

#### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #9 on: June 06, 2019, 04:12:33 pm »
Range starts at 1, it must!

Angles are in degrees.

Here is Easylang Clock Sim at least the drawing part, I simplified the call to SYStem since QB64 has TIME\$ function:
Code: [Select]
`_TITLE "Easylang Sim Output: Clock " 'started 2019-06-06 by B+DEFSNG A-Z 'everything without Type Suffix will be Single'setup a graphics screenCONST xmaxScreen = 400 '<<< constants don't have to be typedCONST ymaxScreen = 400SCREEN _NEWIMAGE(xmaxScreen, ymaxScreen, 32) '<<< 32 means to use highest graphics RGBA color system_SCREENMOVE 300, 100 'put screen approx in middle of display for 1280X760 laptop'setup globals to do things like easylang doesDIM SHARED sz, cx, cyDIM SHARED colr AS _UNSIGNED LONG'on timer'  if t\$ <> sys "time"'    t\$ = sys "time"'    h\$ = sys "time:" & t\$'    sec = number substr h\$ 17 2'    min = number substr h\$ 14 2'    hour = number substr h\$ 11 2'    if hour > 12'      hour -= 12'    .'    call draw hour min sec'    timer 0.98'  else'    timer 0.01'  .'.'timer 0'using a timer is too complicated, just get the time, 30 per secCLS , &HFFFFFFFFDO    t\$ = TIME\$    hour = VAL(MID\$(t\$, 1, 2))    IF hour > 12 THEN hour = hour - 12    min = VAL(MID\$(t\$, 4, 2))    sec = VAL(MID\$(t\$, 7, 2))    drawClock hour, min, sec    _DISPLAY    _LIMIT 30 '<<< loops per secLOOP'func draw hour min sec . .   <<< really a sub because no return valueSUB drawClock (hour, min, sec)    '  # dial    '  color 333    colour 333    '  move 50 50    move 50, 50    '  circle 45    circul 45    '  color 797    colour 797    '  circle 44    circul 44    '  color 333    colour 333    '  for i range 60    FOR i = 1 TO 60        '    a# = i * 6        a = i * 6        '    move 50 + sin a# * 40 50 - cos a# * 40        move 50 + SIN(_D2R(a)) * 40, 50 - COS(_D2R(a)) * 40        '    circle 0.25        circul .25        '  .    NEXT    '  for i range 12    FOR i = 1 TO 12        '    a# = i * 30        a = i * 30        '    move 50 + sin a# * 40 50 - cos a# * 40        move 50 + SIN(_D2R(a)) * 40, 50 - COS(_D2R(a)) * 40        '    circle 1        circul 1        '  .    NEXT    '  # hour    '  linewidth 2    lineWidth 2    '  color 000    colour 0    '  a# = (hour * 60 + min) / 2    a = (hour * 60 + min) / 2    '  move 50 50    move 50, 50    '  line 50 + sin a# * 32 50 - cos a# * 32    lyne 50 + SIN(_D2R(a)) * 32, 50 - COS(_D2R(a)) * 32    '  # min    '  linewidth 1.5    lineWidth 1.5    '  a# = (sec + min * 60) / 10    a = (sec + min * 60) / 10    '  move 50 50    move 50, 50    '  line 50 + sin a# * 40 50 - cos a# * 40    lyne 50 + SIN(_D2R(a)) * 40, 50 - COS(_D2R(a)) * 40    '  # sec    '  linewidth 1    lineWidth 1    '  color 700    colour 700    '  a# = sec * 6    a = sec * 6    '  move 50 50    move 50, 50    '  line 50 + sin a# * 40 50 - cos a# * 40    lyne 50 + SIN(_D2R(a)) * 40, 50 - COS(_D2R(a)) * 40    '.END SUB'set COLOR foreground for drawing or printing text FROM up to 3 digit integer parameterSUB colour (n AS INTEGER) 'can't use COLOR as is keyword    s3\$ = RIGHT\$("000" + LTRIM\$(STR\$(n)), 3)    r = VAL(MID\$(s3\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s3\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s3\$, 3, 1)): IF b THEN b = 28 * b + 3    colr = _RGB32(r, g, b)END SUBSUB move (setX, setY)    cx = setX * 4: cy = setY * 4END SUBSUB circul (radius)    fcirc cx, cy, 4 * radius, colrEND SUBSUB lyne (endx, endy)    thic2 cx, cy, 4 * endx, 4 * endy, sz, colrEND SUBSUB lineWidth (width)    sz = 4 * widthEND SUB' 2019-06-06 I will build an rgb sub off a mod of this because I can't find the SmallBASIC code or maybe SdlBasic codeFUNCTION rgba~& (n) ' New (even less typing!) New Color System 1000 colors with up to 3 digits    s4\$ = RIGHT\$("0000" + LTRIM\$(STR\$(n)), 4)    r = VAL(MID\$(s4\$, 1, 1)): IF r THEN r = 28 * r + 3    g = VAL(MID\$(s4\$, 2, 1)): IF g THEN g = 28 * g + 3    b = VAL(MID\$(s4\$, 3, 1)): IF b THEN b = 28 * b + 3    a = VAL(MID\$(s4\$, 4, 1)): IF a THEN a = 28 * a + 3    rgba~& = _RGBA32(r, g, b, a) '>>> a is for alpha 0 to 255 0 is completely transparent 255 is completely opaqueEND SUB'from Steve Gold standardSUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)    DIM Radius AS INTEGER, RadiusError AS INTEGER    DIM X AS INTEGER, Y AS INTEGER    Radius = ABS(R)    RadiusError = -Radius    X = Radius    Y = 0    IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB    ' Draw the middle span here so we don't draw it twice in the main loop,    ' which would be a problem with blending turned on.    LINE (CX - X, CY)-(CX + X, CY), C, BF    WHILE X > Y        RadiusError = RadiusError + Y * 2 + 1        IF RadiusError >= 0 THEN            IF X <> Y + 1 THEN                LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF                LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF            END IF            X = X - 1            RadiusError = RadiusError - X * 2        END IF        Y = Y + 1        LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF        LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF    WENDEND SUB'this version needs fcirc and is pretty inefficient but once and a while it comes in handySUB thic2 (x1, y1, x2, y2, rThick, K AS _UNSIGNED LONG)    'x1, y1 is one endpoint of line    'x2, y2 is the other endpoint of the line    'rThick is the radius of the tiny circles that will be drawn    '   from one end point to the other to create the thick line    'Yes, the line will then extend beyond the endpoints with circular ends.    rThick = INT(rThick / 2): stepx = x2 - x1: stepy = y2 - y1    length = INT((stepx ^ 2 + stepy ^ 2) ^ .5)    IF length THEN        dx = stepx / length: dy = stepy / length        FOR i = 0 TO length            fcirc x1 + dx * i, y1 + dy * i, rThick, K        NEXT    ELSE        fcirc x1, y1, rThick, K    END IFEND SUB`
Easylangs Clock window size did adjust to changing window size of browser! I had to scale everything in Easylang to 4 x's pixels for comparison drawings.
« Last Edit: June 07, 2019, 11:46:19 am by B+ »

#### Aurel

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #10 on: June 06, 2019, 05:33:53 pm »
wait a moment
qb64 don't have RGB(r,g,b) function built in #### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #11 on: June 06, 2019, 06:07:27 pm »
wait a moment
qb64 don't have RGB(r,g,b) function built in wait... then what are QB64's: _RGB(r, g, b), _RGB32(r, g, b [, a optional]), _RGBA(r, g, b, a), _RGBA32(r, g, b, a) functions for? BTW all keywords that start with underline eg_KEYWORD, are new to QB64 that are not found in QB 4.5 or other older QB versions. This is to help track what is and is not compatible to old code.

#### B+

• Guest ##### Re: New Web-based BASIC-like language: https://easylang.online/
« Reply #12 on: June 06, 2019, 06:31:23 pm »
OK a list of built in functions can be found at the end of Code Snippets section.