Recent Posts

Pages: [1] 2 3 ... 10
1
Code and examples / Re: Spiral Pearl Swirl
« Last post by B+ on 16. March 2017, 00:36:00 »
Here is FB version:
Code: [Select]
'Psychedelic Star Swirl.bas for FreeBASIC [B+=MGA] 2017-03-15
'from SmallBASIC version 2017-03-01

Randomize Timer

Const As Double PI = ACos(-1)
Const As Double RAD = PI / 180
Common Shared As Double r, g, b, clr

'Set screen size here
dim as integer sw = 600, sh = 600, depth = 32
screenres sw, sh, depth, 2
WindowTitle "Psychedelic Star Swirl  -  Press esc to exit"

sub star( x As Integer, y As Integer, rInner As Double, rOuter As Double, nPoints As Integer, angleOffset As Double)
' x, y are same as for circle,
' rInner is center circle radius
' rOuter is the outer most point of star
' nPoints is the number of points,
' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
' this is to allow us to spin the polygon of n sides
Dim As Double pAngle, radAngleOffset, x1, y1, x2, y2, x3, y3
Dim As Integer i
pAngle = RAD * (360 / nPoints)  :  radAngleOffset = RAD * (angleOffset)
x1 = x + rInner * cos(radAngleOffset)
y1 = y + rInner * sin(radAngleOffset)
For i = 0 to nPoints - 1
x2 = x + rOuter * cos(i * pAngle + radAngleOffset + .5 * pAngle)
y2 = y + rOuter * sin(i * pAngle + radAngleOffset + .5 * pAngle)
x3 = x + rInner * cos((i + 1) * pAngle + radAngleOffset)
y3 = y + rInner * sin((i + 1) * pAngle + radAngleOffset)
Line (x1, y1) - (x2, y2)
Line (x2, y2) - (x3, y3)
x1 = x3 : y1 = y3
Next
end sub

sub chColor()
clr = clr + 1
Color rgb(127 + 127 * sin(r * clr), 127 + 127 * sin(g * clr), 127 + 127 * sin(b * clr))
If clr > 50000 then r = Rnd(1) : g = Rnd(1): b = Rnd(1) : clr = 0
End Sub

Dim As Integer page, notpage, rd, cx, cy
Dim As Double size, radius, angle, sangle, x, y, r2
Dim ky as String

notpage = 1 : cx = sw/2 : cy = sh/2
sangle = 0.0 : r = Rnd(1) : g = Rnd(1) : b = Rnd(1)
While ky <> Chr(27)
If page = 0 Then page = 1 ELSE page = 0   'These two lines flip the page and the
  If notpage = 1 THEN notpage = 0 ELSE notpage = 1 'backpage
  SCREENSET page, notpage 'This flips the page
 
  size = 1
  radius = .06
  angle = sangle
  cls
  While radius < 400
    x = cos(angle) * radius
    y = sin(angle) * radius
    r2 = (x ^ 2 + y ^ 2) ^ .5
    size = 4 * r2 ^ .25
    For rd = size to 1 step -10
      chColor
      star cx + x, cy + y, rd/3, rd*1.3, 7, 90
    Next
    angle -= .4
    radius += 1
  Wend

Sleep(60)
   sangle = sangle + pi/18
  ky = InKey
Wend
2
EGSL / Re: physics sandbox
« Last post by Cybermonkey on 15. March 2017, 18:34:30 »
Sorry, but I used a library called Chipmunk2D, but there are'nt any actual wrappers for Pascal, so far as I know. Be aware that the physics example was not made with Lua but with Pascal-
3
EGSL / Re: physics sandbox
« Last post by pielago on 15. March 2017, 04:02:09 »
Ohh
really well  can you help me get the code from it so I can learn it how its done..
4
EGSL / Re: physics sandbox
« Last post by Cybermonkey on 14. March 2017, 19:27:31 »
This was just a proof of concept. Actually there are no physics functions in EGSL or Pulsar2D.
5
EGSL / physics sandbox
« Last post by pielago on 14. March 2017, 07:09:40 »
trying to learn the physics sandbox for EGSL
under the showcase I see the example but cant get the source code to work under mac I see it only for linux
can someone help me please?
6
Offtopic / Re: My Workstation. What's Yours?
« Last post by wang renxin on 13. March 2017, 11:48:49 »
We don't have a tradition to walk shoeless neither at office, but we do at home. And that is my SOHO room. Generally speaking, in my country, some Apple style companies use Macbooks, all the other ones use Lenovo or Dell desktops with top-down black. I didn't pay too much attention about the color when I built it, but I'm always sensitive about the noise. I'm glad that until now it's still unnoticeable, even when I am playing some triple-A games.
7
General questions and discussions / Re: Precision Perfect!
« Last post by B+ on 12. March 2017, 21:31:09 »
The constant e to 50 decimal places:

Code: [Select]
'e with Fraction Tools.txt for JB [B+=MGA] 2017-03-08
' how many terms does it take to match eWiki$

'kth term estimate:  e^1 = 1 + 1/1 + 2/2*1 + 3/3*2*1 +...   k/k*(k-1)*...*2*1
eWiki$ = "2.71828182845904523536028747135266249775724709369995"

lastFactorial = 1 : lastSum$ = "0/1" : i = 0
while mid$(eCurrent$, 1, 52) <> mid$(eWiki$, 1, 52)
    scan
    i = i + 1
    nextFactorial = i * lastFactorial
    nextTerm$ = str$(i);"/";str$(nextFactorial)
    nextSum$ = frac$(lastSum$, "+", nextTerm$)
    call fSplit nextSum$, n, d
    print i;"th Term : ";nextTerm$
    eCurrent$ = nOverDlimitDP$(n, d, 50)
    print i;"th estimate: ";eCurrent$
    print i;"th  compare: ";eWiki$
    print
    lastFactorial = nextFactorial
    lastSum$ = nextSum$
    if i = 50 then exit while 'see where we are
wend
print "Wiki e constant (50 decimals) reached in ";i;" terms of Taylor estimate."
print "Bye!"

function frac$(f1$, op$, f2$)
    call fSplit f1$, n1, d1 : call fSplit f2$, n2, d2
    select case op$
    case "+" : da = d1 * d2 : na = n1 * d2 + n2 * d1
    case "-" : da = d1 * d2 : na = n1 * d2 - n2 * d1
    case "*" : da = d1 * d2 : na = n1 * n2
    case "/" : da = d1 * n2 : na = n1 * d2
    end select
    frac$ = reduce$(str$(na);"/";str$(da))
end function

'n/d as decimal (if not integer) with limit of dp decimal places
'handles case when n/d is improper fraction
function nOverDlimitDP$(n, d, dp)
    ' n, d, dp are presumed to be integers before calling this function.
    ' As integer test: int(n) = n, does not work on very large decimal numbers.
    ' Also presumed, dp > 0. This function won't check these specs.

    ' handle cases n = 0, d = 1, n < 0, d < 0, abs(n) > d
    if n = 0 then nOverDlimitDP$ = "0" : exit function
    if d = 1 or d = -1 then nOverDlimitDP$ = str$(n) : exit function
    if n < 0 then s$ = "-" : n = n * -1
    if d < 0 then
        if s$ = "-" then s$ = "" else s$ = "-"
        d = d * -1
    end if
    i = int(n/d) : i$ = str$(i)
    if i <> 0 then n = n - i * d

    if n <> 0 then
        r = n * 10
        while len(out$) < dp and r <> 0
            while r - d < 0
                out$ = out$;"0"
                if len(out$) >= dp then exit while
                r = r * 10
            wend
            div = int(r/d)
            out$ = out$;str$(div)
            r = (r - div * d) * 10
        wend
        out$ = left$(out$, dp)  'make sure decimal places is correct
        nOverDlimitDP$ = s$;i$;".";out$
    else
        nOverDlimitDP$ = s$;i$
    end if
end function

function reduce$(f$)  'f$ can't be a mixed fraction, fixed for improper
    't$ = mixed2Improper$(f$) 'check that it is not mixed form
    call fSplit f$, n, d
    if n < 0 then s$ = "-": n = 0 - n
    if n >= d then m = int(n/d) : n = n mod d
    gcd = gcd(n, d)
    if gcd > 1 then
        n = n / gcd : d = d / gcd
    end if
    if d = 1 then                      ' output is not mixed fraction
        reduce$ = s$;str$(n + m)
    else
        reduce$ = s$;str$(m * d + n);"/";str$(d)
    end if
end function

function gcd(a, b)
    while a <> 0 and b <> 0
        if a > b then a = a mod b else b = b mod a
    wend
    gcd = a + b
end function

sub fSplit f$, byref n, byref d
    n = val(word$(f$, 1, "/"))
    d = val(word$(f$, 2, "/"))
    if d = 0 then d = 1
end sub

8
Other Languages / Re: thonny
« Last post by John on 12. March 2017, 19:44:28 »
Quote
Python is quite popular on Github

My experience with Python has been that the interpreter has a huge memory footprint, everything is an IMPORT and the C interface is a kludge. (putting all the other quirks aside)
9
Other Languages / Re: thonny
« Last post by Aurel on 11. March 2017, 18:23:57 »
Quote
So, why the address in your profile has been changed?
ahh...i see i will change that crap  >:(
 ;D
yes of course it is popular on github
but most of sources are in python2 ..so not work with thonny( require v3)..
anyway there (on github) we can find many interesting things  :D
10
Other Languages / Re: thonny
« Last post by Tomaaz on 11. March 2017, 10:26:43 »
no forum is still there..

So, why the address in your profile has been changed? ;D

about py3 hmm it looks is not "popular" like py2
anyway who care?

Why double quotes? Python is quite popular on Github - http://githut.info/ .
Pages: [1] 2 3 ... 10