Author Topic: Turtle graphic library  (Read 357 times)

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: Turtle graphic library
« Reply #15 on: 02. June 2017, 11:25:37 »
Main question here is :
What is a license of this examples...he ...he... 8)


ps..it is joke question  :D

Galileo...very nice examples ..i like it  :D
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Peter

  • Newcomer
  • *
  • Posts: 22
    • View Profile
    • BaCon - A free BAsic CONverter for Unix, BSD and MacOSX
Re: Turtle graphic library
« Reply #16 on: 11. June 2017, 16:34:32 »
The original tree program uses colors which looks awesome... below the BaCon version.

Code: [Select]
INCLUDE canvas.bac

OPTION VARTYPE double

WINDOW("Turtle Graphics Tree", 600, 600)

INK(0,0,0,255)
CLS

RESETANGLE

PENXY(300, 600)

PEN(1, TRUE)

CALL tree(400)

WAITKEY

SUB tree(size)

    IF size < 5 THEN
        DRAW(size)
        DRAW(-size)
        EXIT SUB
    ENDIF

    INK(0,255,0,255)
    DRAW(size/3)

    TURN(-30)
    tree(size*2/3)
    TURN(30)

    INK(0,255,0,255)
    DRAW(size/6)

    TURN(25)
    tree(size/2)
    TURN(-25)

    INK(0,255,0,255)
    DRAW(size/3)

    TURN(25)
    tree(size/2)
    TURN(-25)

    INK(139,69,19,255)
    DRAW(size/6)

    DRAW(-size)

END SUB

Peter

  • Newcomer
  • *
  • Posts: 22
    • View Profile
    • BaCon - A free BAsic CONverter for Unix, BSD and MacOSX
Re: Turtle graphic library
« Reply #17 on: 11. June 2017, 20:26:38 »
Can't resist animations  ;D

Code: [Select]
INCLUDE canvas-gd.bac

OPTION VARTYPE double

WINDOW("Dudeney", 500, 500)

RESETANGLE

PENXY(250, 250)

PEN(2, TRUE)

DELAY(80)

CALL Dudeney()

WAITKEY

SUB sqtri()

    DRAW(80) : TURN(120) : DRAW(160)
    TURN(120) : DRAW(119.28) : TURN(-42.12)
    DRAW(60) : TURN(90) : DRAW(104) : TURN(90)
    DRAW(106) : TURN(90) : DRAW(53)

END SUB

SUB shape0()

    DRAW(52) : TURN(90) : DRAW(45.5) : TURN(42.12)
    DRAW(41) : TURN(120) : DRAW(80)

END SUB

SUB shape1(offset)

    TURN(-offset) : DRAW(80) : TURN(120) : DRAW(80)
    CALL shape2(offset) : TURN(180 + offset)
    DRAW(60.5) : TURN(90) : DRAW(52)

END SUB

SUB shape2(offset)

    TURN(-offset) : DRAW(80) : TURN(120) : DRAW(39)
    CALL shape3(offset) : TURN(180 + offset)
    DRAW(52) : TURN(90) : DRAW(46)

END SUB

SUB shape3(offset)

    TURN(-offset) : DRAW(80) : TURN(137.88)
    DRAW(60) : TURN(90) : DRAW(52)

END SUB

SUB dudneyDraw(ang)

    LOCAL offset

    offset = 90 * (1 + COS(ang * 0.0174533))
    PENXY(250, 250)
    TURN(210)
    INK(128, 128, 128, 255)
    CLS
    sqtri()
    INK(0, 255, 0, 255)
    shape0()
    shape1(offset)
    SYNC

END SUB

SUB Dudeney()

    LOCAL ang

    FOR ang = 0 TO 180 STEP 5
        dudneyDraw(ang)
    NEXT

    FOR ang = 180 DOWNTO 0 STEP 5
        dudneyDraw(ang)
    NEXT

END SUB