Turtle Graphics lazarus / 39-Graphics ---------------------------------------------------------------------- lainz · 2017-12-01 23:39 Turtle Graphics with BGRABitmap and BGRAControls: https://github.com/lainz/turtlegraphics Video of the application: https://www.youtube.com/watch?v=-ZW0bihDjUY&vq=hd720 When I discovered turtle graphics I got amazed! I discovered turtle graphics in a demo that comes with Python IDLE, in the help menu. There you can find a lot of amazing examples to get inspired, or even port these to Pascal! ---------------------------------------------------------------------- lrcvsx · 2017-12-04 19:37 Hi: lainz Look at YT the Xkrouhn channel, all videos are made with Freebasic Turtle. Freebasic turle, I started it about 3 years ago, my latest version is the Turtle9. Specifically watch the video: Freebasic Turtle. Your example seems like an imitation of my program 3 years ago. I wish you like the examples. regards ---------------------------------------------------------------------- lainz · 2017-12-04 19:55 Awesome channel, I found that video, is almost the same I did =) But you did it in 2013! I just increased the angle more slowly. Here is the Canvas version: https://lainz.github.io/webapps/turtlegraphics/ And another using Fibonacci: https://lainz.github.io/webapps/turtlegraphicsfibonacci/ Impressive videos in your channel. Edit: I found another exactly with the same code! 2015 https://www.youtube.com/watch?v=44kYhWmhJyI ---------------------------------------------------------------------- lrcvsx · 2017-12-04 20:32 Hi Ja, ja, ja... One casuality! Note: 4 years Regards ---------------------------------------------------------------------- lainz · 2017-12-05 00:10 Quote from: lrcvsx on December 04, 2017, 09:32:03 pmHi Ja, ja, ja... One casuality! Note: 4 years Regards Also notice every one that did this is in a different programming language, I never hear of Freebasic until today! Neither used FMS Logo from that video of 2015 I commented. Edit: FMS Logo website features this kind of code in his main page, attached picture. I think this code is older than we think. Edit 2: A 1998 website! https://web.archive.org/web/20171205012345/https://courses.cs.washingt on.edu/courses/cse341/98sp/assignments/assignment1.html Is called a squiral Edit 3: 1983 https://web.archive.org/web/20170927224843/https://www.atarimagazines. com/compute/issue32/063_1_HIGH_RESOLUTION_TURTLE_GRAPHICS.php ---------------------------------------------------------------------- dubst3pp4 · 2017-12-05 06:39 Hi lainz, great idea and a great JavaScript version! Back in the 90s as a kid I started to learn programming in school with turtle graphics, I think it must have been the Logo programming language (https://en.wikipedia.org/wiki/Logo_(programming_language)). It is still a great concept to get kids (and adults, too) into programming, as you can see immediately the effect of your code and ideas. Best regards, Marc ---------------------------------------------------------------------- marcov · 2017-12-05 11:04 Afaik turbo pascal 3 came with a turtle graph unit, but it was later deprecated in favor of a more modern Graph, the one that FPC provides. The old one is known as "graph3" ---------------------------------------------------------------------- Thaddy · 2017-12-05 11:07 Quote from: marcov on December 05, 2017, 12:04:00 pmAfaik turbo pascal 3 came with a turtle graph unit, but it was later deprecated in favor of a more modern Graph, the one that FPC provides. The old one is known as "graph3" TP3 is available for free here: http://edn.embarcadero.com/article/20792 You will need an account for the download and login first. There is a good chance the turtle graph  works, maybe just in TP mode on i8086 (dosbox), but maybe needs trunk for that. I did not check. I have only TP 1.0 and TP 5.5 from the museum. ---------------------------------------------------------------------- lrcvsx · 2017-12-05 13:52 Hi, lainz: Many years ago, I used with TP3 and later with TP7. Then I started with GW, QB, MSWLOGO, FMSLOGO and finally with FB. Some examples are in YT, Xkrouhn I like to program simply for hobby. ---------------------------------------------------------------------- lainz · 2017-12-05 14:59 Quote from: lrcvsx on December 05, 2017, 02:52:54 pmHi, lainz: Many years ago, I used with TP3 and later with TP7. Then I started with GW, QB, MSWLOGO, FMSLOGO and finally with FB. Some examples are in YT, Xkrouhn I like to program simply for hobby. I started programming as a hobby also (now I'm working and also studiying for a career), first with Lua script, then Pascal, JavaScript (Browser & Node.js), PHP, C#, Java... Quote from: dubst3pp4 on December 05, 2017, 07:39:54 amHi lainz, great idea and a great JavaScript version! Back in the 90s as a kid I started to learn programming in school with turtle graphics, I think it must have been the Logo programming language (https://en.wikipedia.org/wiki/Logo_(programming_language)). It is still a great concept to get kids (and adults, too) into programming, as you can see immediately the effect of your code and ideas. Best regards, Marc Thanks, and yes is very intuitive. Quote from: marcov on December 05, 2017, 12:04:00 pmAfaik turbo pascal 3 came with a turtle graph unit, but it was later deprecated in favor of a more modern Graph, the one that FPC provides. The old one is known as "graph3" Quote from: Thaddy on December 05, 2017, 12:07:17 pmQuote from: marcov on December 05, 2017, 12:04:00 pmAfaik turbo pascal 3 came with a turtle graph unit, but it was later deprecated in favor of a more modern Graph, the one that FPC provides. The old one is known as "graph3" TP3 is available for free here: http://edn.embarcadero.com/article/20792 You will need an account for the download and login first. There is a good chance the turtle graph  works, maybe just in TP mode on i8086 (dosbox), but maybe needs trunk for that. I did not check. I have only TP 1.0 and TP 5.5 from the museum. There are a lot of libraries out there, I know my example lacks of many of the functions from all these libraries. ---------------------------------------------------------------------- alaa123456789 · 2021-01-18 19:29 hi all , turtle is very and interesting subject , as it was with us in younger stage , so i found very useful component in delphi , but we need help of you to convert to Lazarus package please all help http://arbeitsplattform.bildung.hessen.de/fach/informatik/delphi/rekgr af/rekgraf2.htm.html ---------------------------------------------------------------------- lainz · 2021-01-18 22:43 If you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. ---------------------------------------------------------------------- Fred vS · 2021-01-18 22:56 Quote from: lainz on January 18, 2021, 11:43:33 pmIf you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. https://github.com/lainz/turtlegraphics WOW, very impressive, fast and out-of-the-box. Congrats. ---------------------------------------------------------------------- lainz · 2021-01-18 23:13 Quote from: Fred vS on January 18, 2021, 11:56:12 pmQuote from: lainz on January 18, 2021, 11:43:33 pmIf you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. https://github.com/lainz/turtlegraphics WOW, very impressive, fast and out-of-the-box. Congrats. Thanks to @circular, he did the code, I grabbed it from somewhere in this big forum ---------------------------------------------------------------------- Fred vS · 2021-01-18 23:50 Quote from: lainz on January 19, 2021, 12:13:10 amQuote from: Fred vS on January 18, 2021, 11:56:12 pmQuote from: lainz on January 18, 2021, 11:43:33 pmIf you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. https://github.com/lainz/turtlegraphics WOW, very impressive, fast and out-of-the-box. Congrats. Thanks to @circular, he did the code, I grabbed it from somewhere in this big forum  Thanks to both. Huh, do you think I could use it for the Strumpract-Image-Dancer? I just try it making dance and it is bluffing (and with color changing 2xWow). ---------------------------------------------------------------------- lainz · 2021-01-19 00:31 Sure, keep hacking ---------------------------------------------------------------------- Fred vS · 2021-01-19 00:38 Quote from: lainz on January 19, 2021, 01:31:21 amSure, keep hacking  OK, done! The angle value is perfect to make it dance. What is your advice to avoid flickering changing color? I search for a way to changing smoothly the colors because jumping from red to blue for example gives a flickering effect. Maybe step by step from one color to the other ? ---------------------------------------------------------------------- alaa123456789 · 2021-01-19 06:51 Quote from: lainz on January 18, 2021, 11:43:33 pmIf you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. i have looked at your sample , it is very nice , but little complicated for beginners , if possible someone who is expert who make a component called turtle so we just give it the orders (move.rotate .....etc) same as in other programming languages .it would be great thanks to all ---------------------------------------------------------------------- lainz · 2021-01-19 14:42 Quote from: Fred vS on January 19, 2021, 01:38:15 amQuote from: lainz on January 19, 2021, 01:31:21 amSure, keep hacking  OK, done! The angle value is perfect to make it dance. What is your advice to avoid flickering changing color? I search for a way to changing smoothly the colors because jumping from red to blue for example gives a flickering effect. Maybe step by step from one color to the other ? Yes, store 2 colors and you can make a blend with a percentage I think, just can't remember how.  Do the blending percentage over time. Quote from: alaa123456789 on January 19, 2021, 07:51:44 amQuote from: lainz on January 18, 2021, 11:43:33 pmIf you look at my code, you can see that move and rotate are implemented, color is just another property in bgrabitmap drawing, so it already works, try using that. i have looked at your sample , it is very nice , but little complicated for beginners , if possible someone who is expert who make a component called turtle so we just give it the orders (move.rotate .....etc) same as in other programming languages .it would be great thanks to all You mean a scripting tool? Or, just a TComponent that can be used with an OnPaint event? ---------------------------------------------------------------------- Fred vS · 2021-01-19 14:54 Quote from: lainz on January 19, 2021, 03:42:27 pmQuote from: Fred vS on January 19, 2021, 01:38:15 amQuote from: lainz on January 19, 2021, 01:31:21 amSure, keep hacking  OK, done! The angle value is perfect to make it dance. What is your advice to avoid flickering changing color? I search for a way to changing smoothly the colors because jumping from red to blue for example gives a flickering effect. Maybe step by step from one color to the other ? Yes, store 2 colors and you can make a blend with a percentage I think, just can't remember how.  Do the blending percentage over time. OK, thanks. What I do for the moment is to vary the value of G, something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i set_color(Bitmap, 255, round(128*multiplier), 64, 255); Of course if only gives a palette between yellow-orange and red. There is no flickering. It would be nice to switch to the colors of the rainbow. But this is only detail, your code is "really" impressive (and totally hypnotic). Thanks a lot. Fre;D ---------------------------------------------------------------------- alaa123456789 · 2021-01-19 14:58 i attached one component but it is in delphi, it use timage , and i attached link for the German page yes it is much easier , you just give rotate,move,draw and it will be drawn on the image,please have a look on the attachment. thanks ---------------------------------------------------------------------- lainz · 2021-01-19 15:11 Quote from: alaa123456789 on January 19, 2021, 03:58:51 pmi attached one component but it is in delphi, it use timage , and i attached link for the German page yes it is much easier , you just give rotate,move,draw and it will be drawn on the image,please have a look on the attachment. thanks Here is the automatic conversion with Lazarus convert from delphi menu, can you try it? If you can make a small demo on how to use it =) ---------------------------------------------------------------------- lainz · 2021-01-19 15:17 Quote from: Fred vS on January 19, 2021, 03:54:38 pmQuote from: lainz on January 19, 2021, 03:42:27 pmQuote from: Fred vS on January 19, 2021, 01:38:15 amQuote from: lainz on January 19, 2021, 01:31:21 amSure, keep hacking  OK, done! The angle value is perfect to make it dance. What is your advice to avoid flickering changing color? I search for a way to changing smoothly the colors because jumping from red to blue for example gives a flickering effect. Maybe step by step from one color to the other ? Yes, store 2 colors and you can make a blend with a percentage I think, just can't remember how.  Do the blending percentage over time. OK, thanks. What I do for the moment is to vary the value of G, something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i set_color(Bitmap, 255, round(128*multiplier), 64, 255); Of course if only gives a palette between yellow-orange and red. There is no flickering. It would be nice to switch to the colors of the rainbow. But this is only detail, your code is "really" impressive (and totally hypnotic). Thanks a lot. Fre;D     Circular said we can use MergeBGRA I think it can be used like this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  p1, p2: TBGRAPixel;begin  p2.Alpha := 100; // 99, 98, 97... when time passes by  MergeBGRA(p1, p2);   Quote from: circularFor a percentage you can for example assign 30 and 70 for the weights (30 + 70 = 100) So using the alternative version of the function.. ---------------------------------------------------------------------- alaa123456789 · 2021-01-19 16:33 i know conversion, could you put this and make new package so we can use it in any application? ---------------------------------------------------------------------- lainz · 2021-01-19 20:41 Quote from: alaa123456789 on January 19, 2021, 05:33:55 pmi know conversion, could you put this and make new package so we can use it in any application? Please create a demo on how to use it- To create a package go to lazarus Packages > New package. Save it somewhere. Go to the package folder and copy and paste the uturtle.pas, then in the package viewer in lazarus use add files, and add uturtle.pas. Then you can share it =) ---------------------------------------------------------------------- Fred vS · 2021-01-19 21:38 Quote from: lainz on January 19, 2021, 04:17:33 pm   p1, p2: TBGRAPixel; begin   p2.Alpha := 100; // 99, 98, 97... when time passes by   MergeBGRA(p1, p2); Quote from: circularFor a percentage you can for example assign 30 and 70 for the weights (30 + 70 = 100) So using the alternative version of the function.. Hello. OK, thanks, I will study this. I did some custom test, the result is great in animation. ---------------------------------------------------------------------- lainz · 2021-01-19 23:55 Cool, I think I did the same, using 2 colors, one at the center  https://lainz.github.io/webapps/squiraltour/ ---------------------------------------------------------------------- Fred vS · 2021-01-20 00:38 Quote from: lainz on January 20, 2021, 12:55:56 amCool, I think I did the same, using 2 colors, one at the center  https://lainz.github.io/webapps/squiraltour/ DPM! WOW. ---------------------------------------------------------------------- alaa123456789 · 2021-01-20 16:02 Quote from: lainz on January 19, 2021, 09:41:30 pmQuote from: alaa123456789 on January 19, 2021, 05:33:55 pmi know conversion, could you put this and make new package so we can use it in any application? Please create a demo on how to use it- To create a package go to lazarus Packages > New package. Save it somewhere. Go to the package folder and copy and paste the uturtle.pas, then in the package viewer in lazarus use add files, and add uturtle.pas. Then you can share it =) i did already ,but when i put it on new application it doesn't work and the background is black , also not resizing please modify the attachment and re-share it so everyone can get benefit of it thanks ---------------------------------------------------------------------- lainz · 2021-01-21 16:50 Quote from: alaa123456789 on January 20, 2021, 05:02:18 pm i did already ,but when i put it on new application it doesn't work and the background is black , also not resizing please modify the attachment and re-share it so everyone can get benefit of it thanks Hi, I've refactored my code so is more easy to use. This is the unit https://github.com/lainz/turtlegraphics/blob/master/bgraturtle.pas How to use? 1) Install BGRABitmap and BGRAControls. 2) Drop a BGRAVirtualScreen. 3) Add BGRATurtle.pas in Uses. 4) Add OnRedraw event for BGRAVirtualScreen1. 5) Use the turtle methods in the OnRedraw event. Methods? Bitmap.MoveTurtle(distance: single); Bitmap.RotateTurtle(angle: single); Bitmap.TranslateTurtle(x: single; y: single); Bitmap.ResetTurtle; Bitmap.ColorTurtle(red, green, blue: byte; alpha: byte = 255); Full demo: https://github.com/lainz/turtlegraphics/blob/master/umain.pas If you want to other people use my demo feel free to share it, it already works, so they need to only replace the code in the OnRedraw event. It has animation support, but you can disable it as well removing the timer code. ---------------------------------------------------------------------- winni · 2021-01-22 22:59 Hilbert Curve with BGRAturtle! I did a deep search in my HD and found it again: The UCSD Pascal Demo from  1979 for the Apple II using Turtlegraphics to show the Hilbert Curve. I adapted the code to BGRAturtle but left as much as possible of the old code untouched. The project and a SC is attached. ---------------------------------------------------------------------- lainz · 2021-01-23 01:15 Thanks ---------------------------------------------------------------------- lucamar · 2021-01-23 03:33 Black text on yellow background ... ouch! ouch! ---------------------------------------------------------------------- circular · 2021-01-23 10:47 Nice, the code is almost the same as the original.  @lucamar Maybe this needs some magenta as well ---------------------------------------------------------------------- winni · 2021-01-23 11:59 Quote from: lucamar on January 23, 2021, 04:33:11 amBlack text on yellow background ... ouch! ouch! Hi Lucamar! Seems the germans love that: Opel Manta (RIP) BVB Dortmund Deutsche Post DHL .... Winni ---------------------------------------------------------------------- winni · 2021-01-23 16:30 @lainz (and all who are interested) Hi! If found the manual for the library (now:unit ) TurtleGraphics for UCSD Pascal aka Apple Pascal for the Apple II. 10 PDF  Pages in the attachment. Winni ---------------------------------------------------------------------- lainz · 2021-01-28 02:32 Thanks winni. In the demo I've seen the moveTo method. Maybe I add that to the list. Any other thing missing? ---------------------------------------------------------------------- winni · 2021-01-28 23:33 Hi Lainz! Boah! It is 35 years that I used last time the TurtleGraphics .... Analog to moveto (x,y) there was Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i turnto (AbsolutAngle) And asking the Turtle about the current values: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i X := TurtleX;Y := TurtleY;Angle := TurtleAng;  And in later versions (I Think ...) there came Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TurtleHide;TurteShow; And there was also Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Pencolor (Color);  Nobody used that. On the one hand they had strange definitios (Black, Black1, Black2, ....). And second in those days nobody had a color Monitor because this was really  expensive . And the color resolution was 48x40 Pixel. Just a stamp ..... Winni