Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fractal tree in micro(A)
#1
using stack

https://youtu.be/Vnt7aOxTw4g
Reply
#2
Cool!
Reply
#3
thanks
Reply
#4
super ultra fantastic space shooter written in micro(A)


https://youtu.be/iPOPHWLW98o

Big Grin Big Grin Big Grin


Confused yipieeeee Angel
Reply
#5
(06-07-2026, 08:27 AM)aurel Wrote: super ultra fantastic space shooter written in micro(A)


https://youtu.be/iPOPHWLW98o

Big Grin Big Grin Big Grin


Confused yipieeeee Angel

Nice Smile
Reply
#6
with recursive local calls
Code:
' Micro(A) Fraktalno Stablo - Test s pravim lokalnim varijablama
mode 1 : wcolor 0,0,0: swap

var PI
PI = 3.141592

' Pocetne koordinate (dno ekrana, dužina 100, kut -90 stupnjeva prema gore)
drawTree(400, 550, 100, -90)
'swap

func drawTree(var x, var y, var length, var angle)
    ' LOKALNE VARIJABLE (sada bi zbog novog preScana trebale raditi na stogu!)
    var xEnd, yEnd

    if length > 5       
        ' Izracun kraja linije pomocu kuta u radijanima
        xEnd = x + length * cos(angle * PI / 180)
        yEnd = y + length * sin(angle * PI / 180)
       
        ' Nacrtaj trenutnu granu
        fcolor 150, 200, 100
        line x, y, xEnd,yEnd
        swap
       
        ' REKURZIVNI POZIVI: Ako preScan radi dobro, nakon povratka iz lijeve grane,
        ' desna grana ce tocno znati svoje roditeljske xEnd i yEnd koordinate!
        drawTree(xEnd, yEnd, length * 0.75, angle - 30)
        drawTree(xEnd, yEnd, length * 0.75, angle + 30)
    endif
endfn


Attached Files Thumbnail(s)
   
Reply
#7
I need to install micro(a) and try these things out, don't have it on my current computer. Thanks for posting!
Reply
#8
wait i must upload it first
Reply
#9
Converted to N7... Very nice! Big Grin
Logic is the beginning of wisdom.

Live long and prosper.
Reply
#10
cool john...must work of course
Big Grin


@marcus

in attachment is quick release of micro(A) v14 F

dang i find that one example not work because is no properly written
it is Sierpinski Gasket
so here is code :
just copy from here to code editor AEdit14.exe
click on blue-ish button SaveAs...
type name and confirm save...
then click on green arrow Toolbar button -> RUN
and voila....

Code:
' Micro(A) - Sierpinski Trokut s lokalnim varijablama
mode 1 : wcolor 0,0,0: swap

' Pocetne tocke velikog trokuta (X, Y) prilagodene za ekran 800x600
' Gornji vrh (400, 50), Donji lijevi (100, 550), Donji desni (700, 550)
' Zadnji parametar 5 je dubina rekurzije (razina detalja)
drawSierpinski(400, 50, 100, 550, 700, 550, 7)
swap

func drawSierpinski(var x1, var y1, var x2, var y2, var x3, var y3, var depth)
    ' LOKALNE VARIJABLE: Polovišta stranica trokuta (zahvaljujuci novom preScanu rade na stogu!)
    var x12, y12, x23, y23, x31, y31

    if depth = 0
        ' Baza rekurzije: nacrtaj najmanji trokut spajanjem tri tocke
        fcolor 100, 150, 255 ' Prekrasna plava boja
        line x1, y1, x2, y2
        line x2, y2, x3, y3
        line x3, y3, x1, y1
        'swap
    else
        ' Izracunaj središnje tocke (polovišta) svake od tri stranice
        x12 = (x1 + x2) / 2
        y12 = (y1 + y2) / 2
       
        x23 = (x2 + x3) / 2
        y23 = (y2 + y3) / 2
       
        x31 = (x3 + x1) / 2
        y31 = (y3 + y1) / 2

        ' REKURZIVNI POZIVI: Nacrtaj 3 manja trokuta u kutovima
        ' Gornji trokut
        drawSierpinski(x1, y1, x12, y12, x31, y31, depth - 1)
        ' Donji lijevi trokut
        drawSierpinski(x12, y12, x2, y2, x23, y23, depth - 1)
        ' Donji desni trokut
        drawSierpinski(x31, y31, x23, y23, x3, y3, depth - 1)
    endif
endfn

here is screenshot :

what a heck i discovered that koch flake work too

Code:
' Micro(A) - Kochova Pahuljica pomocu SIN i COS
mode 1 : wcolor 0,0,0: swap

fcolor 100, 150, 255 ' Plava boja za pahuljicu

' Definiramo tri vrha pocetnog velikog trokuta (X, Y)
' Kut od 60 stupnjeva u radijanima iznosi oko 1.04719
' Ovdje koristimo izravne trigonometrijske pozive za izracun treceg vrha
var ax, ay, bx, by, cx, cy
ax = 200 : ay = 450
bx = 600 : by = 450

' Izracun treceg (donjeg) vrha jednakostranicnog trokuta pomocu sin/cos 60°
' (Visina trokuta stranice 400 piksela je 400 * sin(60 stupnjeva) = 400 * 0.866)
cx = 400
cy = 450 - (400 * 0.866)

' Nacrtaj 3 Kochove krivulje koje cine zatvorenu pahuljicu (dubina rekurzije 4)
drawKoch(ax, ay, bx, by, 4)
drawKoch(bx, by, cx, cy, 4)
drawKoch(cx, cy, ax, ay, 4)

swap

func drawKoch(var x1, var y1, var x5, var y5, var depth)
    ' LOKALNE VARIJABLE: Sve na samom vrhu zbog stabilnosti stoga!
    var x2, y2, x3, y3, x4, y4
    var dx, dy
   
    ' Varijable za rotaciju pod kutom od 60 stupnjeva (p / 3 radijana)
    ' NAPOMENA: Ako Micro(A) koristi stupnjeve, zamijeni 1.0472 sa 60!
    var rad, cos60, sin60
    rad = 1.0472
    cos60 = cos(rad)
    sin60 = sin(rad)

    if depth = 0
        ' Bazni slucaj: nacrtaj ravnu crtu
        line x1, y1, x5, y5
        return
    else
        ' 1. Izracunaj trecine linije (tocke 2 i 4)
        x2 = x1 + (x5 - x1) / 3
        y2 = y1 + (y5 - y1) / 3
       
        x4 = x1 + (x5 - x1) * 2 / 3
        y4 = y1 + (y5 - y1) * 2 / 3

        ' 2. Izracunaj vektor srednje trecine (od tocke 2 do tocke 4)
        dx = x4 - x2
        dy = y4 - y2

        ' 3. Rotiraj taj vektor za 60 stupnjeva pomocu sin i cos kako bi dobio vrh (tocku 3)
        ' Ovo je standardna formula rotacijske matrice za grafiku
        x3 = x2 + (dx * cos60 - dy * sin60)
        y3 = y2 + (dx * sin60 + dy * cos60)

        ' 4. REKURZIVNI POZIVI: Lomimo liniju na 4 nova manja segmenta
        drawKoch(x1, y1, x2, y2, depth - 1)
        drawKoch(x2, y2, x3, y3, depth - 1)
        drawKoch(x3, y3, x4, y4, depth - 1)
        drawKoch(x4, y4, x5, y5, depth - 1)
    endif
endfn


Attached Files Thumbnail(s)
       

.zip   microA14F.zip (Size: 3.95 MB / Downloads: 3)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)