Recent

Author Topic: turtle graph  (Read 8437 times)

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
turtle graph
« on: September 08, 2013, 08:32:27 pm »
hello everyone

is there anyone remember turtle graph?
i am looking for graph functions like as turtle graph in lazarus


Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: turtle graph
« Reply #1 on: September 09, 2013, 12:47:45 am »
Wasn't that part of TP 3?
I should still have a copy of that somewhere.

Bart

tr_escape

  • Sr. Member
  • ****
  • Posts: 432
  • sector name toys | respect to spectre
    • Github:
Re: turtle graph
« Reply #2 on: September 09, 2013, 07:03:58 am »
Yes it was in turbo pascal , actually i was cleaning my bookself and i saw my old books about pascal. When i saw turtle graph , i sopposed maybe in pascal already there is.

Is there any library or component about it?

Thanks a lot

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: turtle graph
« Reply #3 on: September 09, 2013, 12:16:53 pm »
I haven't seen it around.
Would be nice (nostalgia...) to have something like it, both for FreePascal (using Graph unit) and for Lazarus...

Bart

eny

  • Hero Member
  • *****
  • Posts: 1634
Re: turtle graph
« Reply #4 on: September 09, 2013, 07:07:21 pm »
The turtle graphic procedures (actually, 5 functions) where implemented as assembler routines and included in the com-file during the 1-pass compilation.
You'd either have to disassemble them or do a bit of trial and error in a DosBox with the original TP3 compiler.
And indeed would be nice from a nostalgic/retro point of view to got it working in Lazarus :)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

circular

  • Hero Member
  • *****
  • Posts: 4220
    • Personal webpage
Re: turtle graph
« Reply #5 on: September 09, 2013, 09:45:11 pm »
I suppose you can do this with Canvas2D of BGRABitmap:
Code: [Select]
    procedure rotate(angleRad: single);
    procedure translate(x,y: single);
    procedure strokeStyle(color: TColor); overload;
    procedure beginPath;
    procedure moveTo(x,y: single); overload;
    procedure lineTo(x,y: single); overload;
    procedure stroke;

To advance you can do: beginPath; moveTo(0,0); translate(1,0); lineTo(0,0); stroke;
To turn: rotate(10*Pi/180)
To change color: strokeStyle(...)
Conscience is the debugger of the mind

ToBr

  • New Member
  • *
  • Posts: 15
Re: turtle graph
« Reply #6 on: September 16, 2013, 10:13:54 pm »
Maybe David Dirkse can help you
See www.davdata.nl

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: turtle graph
« Reply #7 on: November 28, 2017, 04:05:52 am »
Hi, I know this is really old but it shows first in a google search, so I think it worth to comment here.

In no time thanks to @Circular details on how to implement it I made this turtle graphics demo:
https://github.com/lainz/turtlegraphics

Code: Pascal  [Select][+][-]
  1.   Bitmap.Fill(BGRAWhite);
  2.  
  3.   reset(Bitmap);
  4.   set_color(Bitmap, 0, 0, 255, 255);
  5.  
  6.   // 5 points star
  7.   translate(Bitmap, (Bitmap.Width div 2) - 100, (Bitmap.Height div 2) - 50);
  8.   for i := 1 to 5 do
  9.   begin
  10.     move(Bitmap, 200);
  11.     rotate(Bitmap, 144);
  12.   end;
  13.  
  14.   reset(Bitmap);
  15.   set_color(Bitmap, 0, 255, 0, 255);
  16.  
  17.   // 9 triangles
  18.   translate(Bitmap, (Bitmap.Width div 2) - 50, (Bitmap.Height div 2) - 120);
  19.   for i := 1 to 3 do
  20.   begin
  21.     move(Bitmap, 200);
  22.     for j := 1 to 2 do
  23.     begin
  24.       rotate(Bitmap, 120);
  25.       move(Bitmap, 100);
  26.     end;
  27.     for j := 1 to 2 do
  28.     begin
  29.       rotate(Bitmap, -120);
  30.       move(Bitmap, 100);
  31.     end;
  32.     rotate(Bitmap, 120);
  33.   end;

Hope I will play more with this and include a proper class, standard naming of functions and demo with pascal scripting.

I get into this thanks to python "turtle demo" in the python IDLE shell help menu.

 

TinyPortal © 2005-2018