• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • FMSLogo
  • Support Requests
FMSLogo

Reporting a trick for animation - how clever is it?

A Logo programming environment for Microsoft Windows

Brought to you by: david_costanzo
  • Summary
  • Files
  • Reviews
  • Support
  • Tickets ▾
    • Feature Requests
    • Bugs
    • Support Requests
  • Discussion
  • Code
Menu ▾ ▴
  • Create Ticket
  • View Stats

Group

  • GUI

Searches

  • Changes
  • Closed Tickets
  • Open Tickets

Help

  • Formatting Help

#68 Reporting a trick for animation - how clever is it?

GUI
open
nobody
None
5
2026-03-12
2026-03-09
Manfred Zindel
No

I want to report a trick to reduce flickering in a graphics animation. For me it's new and it seems to work fine. I worked on it together with Opera AI, a chatbot which says it is not so well trained with FMSLogo, but it knows how to use the Internet very fast and can read the whole help section of FMSLogo in no time. Regretably all it learns gets lost when the session is closed. So I have to tell the chatbot in the next session for instance again that is should set FMSLogo keywords completely in uppercase. But working together with this chatbot and exchanging proposals is very effective - like with a creative kind of college. I wrote te two programs in German, and the chatbot did all the translation in English - comments and variable names.

Now here is the trick - simple but effective: Instead of clearing the whole Graphics area for each single image I do this only for a circular region and the animation is only in it. The remainder of the screen can be used for other (static) contents. But how: For a circular region with a given radius I take the double size of this radius plus 5 as a PENSIZE, very big, of course. I chose a background color as PENCOLOR. Then I put the turtle into the middle and just write FORWARD 0. That's all.

Now I show you the two procedures - one is the subroutie of the other. But even the main procedure has a parameter - the radius of the area. You need not take a hexagon like it's done here, you can take an image or a graphics text or so. And the whole area outside the circle is untouched and can havwe own permanent contents, if you want. And you do not need to use a pure rotation - you also can let it swing. I hope that when you try out the following programs (made with the help of AI) run nearly flicker-free as they do on my computer. Here is the code - the final result of our work (in English). Why not let the chatbot translate it into Spanish - or French. Or Chinese?

TO circular_hexagon_animation :radius

  ; Setup
  SETSCREENCOLOR "orange
  HIDETURTLE

  ; Set pen color red and pen size 5
  SETPENCOLOR "red
  SETPENSIZE [5 5]

  ; Draw circle centered at [0 0]
  PENUP
  HOME
  PENDOWN
  CIRCLE SUM :radius 8

  ; Clear inside of the circle
  SETPENSIZE PRODUCT 2 SUM :radius 5
  SETPENCOLOR [255 215 178]
  PENUP
  HOME
  PENDOWN
  FORWARD 0
  SETPENSIZE 5
  SETPENCOLOR "red

  FOR [start_angle 90 450 2] [
    circular_hexagon_animation.sub :radius :start_angle
    WAIT 8
  ]

END

TO circular_hexagon_animation.sub :radius :start_angle

  ; Draw a regular hexagon inside the circle with two vertices
  ; on the y-axis (top and bottom) and no vertix on the x-axis.
  ; The hexagon vertices lie on the circle with the given radius.
  ; Starting from the start_angle, move 60° counterclockwise for
  ; each vertex. The start_angle can point anywhere on the circle
  ; perimeter, it is a mathematical angle instead of a Logo angle.

  ; Reserve local variables
  LOCAL [x y angle]

  ; Clear inside of the circle
  SETPENSIZE PRODUCT 2 SUM :radius 5
  SETPENCOLOR [255 215 178]
  PENUP  HOME  PENDOWN  FORWARD 0
  SETPENSIZE 5  SETPENCOLOR "red

  ; Move the turtle to the first vertex (top)
  MAKE "angle :start_angle
  MAKE "x :radius * COS :angle  MAKE "y :radius * SIN :angle
  PENUP  SETPOS LIST :x :y  PENDOWN

  ; Draw lines to the other vertices. The start point repeats.
  REPEAT 6 [
    MAKE "angle SUM :angle 60
    MAKE "x :radius * COS :angle   MAKE "y :radius * SIN :angle
    SETPOS LIST :x :y
  ]

END

Discussion

  • David Costanzo

    David Costanzo - 2026-03-11

    That is clever to use a large pen size to erase. It's not documented that the pen is round or that FORWARD 0 draws anything, but given my hesitance to break compatibility with existing programs, I think it's safe to assume I wouldn't change it.

    When I run your program on my laptop, I don't see any flicker.

    If I were trying to be clever, I would have used (FILL "TRUE) to fill the shape. To do this, you can choose a color that is slightly off from your PENCOLOR. For example [254 0 0] looks red, but isn't the same as "red. FILL has several advantages over using a large pen size.

    1. It can fill any closed shape, not just a circle.
    2. You don't have to move the turtle to fill.
    3. You don't rely on undocumented behavior.

    However, if you asked me to program this, I wouldn't use FILL. I would have used a bitmapped turtle (as you wrote), or BITCOPY and BITPASTE to quickly restore a rectangular portion of the screen that includes the outer circle. I might even leave a turtle at the right location for the BITPASTE to minimize the time it takes to "clear".

    Here's a version that uses FILL. It also uses SETXY, which is faster than using SETPOS and LIST.

    TO circular_hexagon_animation :radius
    
      ; Setup
      SETSCREENCOLOR "orange
      HIDETURTLE
    
      ; Set pen color red and pen size 5
      SETPENSIZE [5 5]
    
      ; Draw circle centered at [0 0]
      PENUP
      HOME
      PENDOWN
      SETPENCOLOR [254 0 0]
      CIRCLE SUM :radius 8
    
      ; Clear inside of the circle
      SETPENCOLOR "red
      clear_circle
    
      FOR [start_angle 90 450 2] [
        circular_hexagon_animation.sub :radius :start_angle
        WAIT 8
      ]
    
    END
    
    TO circular_hexagon_animation.sub :radius :start_angle
    
      ; Draw a regular hexagon inside the circle with two vertices
      ; on the y-axis (top and bottom) and no vertex on the x-axis.
      ; The hexagon vertices lie on the circle with the given radius.
      ; Starting from the start_angle, move 60° counterclockwise for
      ; each vertex. The start_angle can point anywhere on the circle
      ; perimeter, it is a mathematical angle instead of a Logo angle.
    
      ; Reserve local variables
      LOCAL [x y angle]
    
      ; Clear inside of the circle
      clear_circle
    
      ; Move the turtle to the first vertex (top)
      MAKE "angle :start_angle
      MAKE "x :radius * COS :angle  MAKE "y :radius * SIN :angle
      PENUP  SETXY :x :y  PENDOWN
    
      ; Draw lines to the other vertices. The start point repeats.
      REPEAT 6 [
        MAKE "angle SUM :angle 60
        MAKE "x :radius * COS :angle   MAKE "y :radius * SIN :angle
        SETXY :x :y
      ]
    
    END
    
    TO clear_circle
      SETPENCOLOR   [254 0 0]
      SETFLOODCOLOR [255 215 178]
      (FILL "TRUE)
      SETPENCOLOR   "red
    END
    
     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • Manfred Zindel

    Manfred Zindel - 2026-03-11

    Well, your variation did its job at once:

    SETPOS with a list was an idea of my chatbot OPERA AI.

    You're right - I could take BITBLOCK to restrict an animation to only a part of the graphics area in order to get a rectangle instead of a circle, I bet it's really pretty fast for a small part. The wish behind it is always to have a very short interruption while going from step to step and so compensate the lack of a background buffer.

    I never noticed that FILL has a parameter that allows it to use the current PENCOLOR as an obstacle instead of having to watch the color where it started and stop when it changes. Very good! I think I have tasks for it.

    BITBLOCK and FORWARD 0 have one thing in common: They cover everyrhing within their rectangle or circle (unlike even FILL "TRUE). I had the idea to put something like graphics text or an image, both static, not moving, with the hexagon rotating around them to attract attention.

    And I don't think that FORWARD 0 with a big PENSIZE is something outside the FMSLogo rules (like an undocumented, but useful mistake), this combination does exactly and logically, what the rules say for this case. Yes, it should always, not by chance, be a circle, because this is the only way to let corners of thick polygons look good. And a circle for a single point is just a special case within the rules. Yes, there could be constraints like numbers have constraints, but only, if it gets dangerous.

    But as soon as I can I'll do some more and extended experiments to enable even in FMSLogoanimation tasks for students.

    I still have a remark: Schools in Germany like MacBooks very much and try to get them if they have enough money. But most of them have little money and so prefer Windows notebooks. This is good for FMSLogo. But now I read that Apple offers a new notebook as cheap as a good Windows notebook. I expect that many shools will switch to Apple and its new offer. But what can we do if we teach FMSLogo that is tied up to Windows?

     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
  • Manfred Zindel

    Manfred Zindel - 2026-03-12

    I've been thinking about my FORWARD-0 trick.

    When I first saw it, I wondered: Is this an undocumented extra feature I can use before someone notices the error? Then I thought about it some more and realized: It's not an error at all; it's a regular part of the language. If you remove it, THEN you're making a mistake.

    Now, to get straight to the point: I think FORWARD 0 belongs to FMSLogo, and so does the circular shape. FORWARD allows any positive and (!) negative number that can be represented on a computer, even 0.0001 and -0.0001 (because pixel approximation is irrelevant to the calculation). There's no reason to deliberately omit 0 between the minus and plus signs on the number line.

    The programmers of this part of FMSLogo put a lot of effort into creating a smooth connection between multiple FORWARD lines. They insert a circle at each end of every straight line, positioned at the midpoint of the end edges. When the midpoints of the edges of two consecutive lines are aligned, the two end circles coincide, creating a clean connection at any angle, even for an entire polygon.

    Most people make straight lines as thin as possible, but FMSLogo allows for many thicknesses, even 20, 50, or more. This becomes increasingly important when the screen has high pixel density. As mentioned, a circle is necessary for this connection to work.

    The rule isn't broken if a line has a length of 0. In that case, the two end circles merge into one, which is also within the concept. This allows you to draw a point solely through the end circle, and that—and nothing else!—is correct and consistent with FMSLogo.

    Even in later school mathematics, it's common to deal with boundary processes, and this should continue in advanced programming.

    I'm sending a small example program to illustrate this and have included a screenshot of the result.

    TO symbol
      SETSCREENCOLOR "orange  CLEARSCREEN
      SETPENCOLOR "blue
      SETPENSIZE 64
      PENUP HOME PENDOWN  
      LEFT 30  FORWARD 200  LEFT 120  FORWARD 100
      PENUP  FORWARD 100  PENDOWN  FORWARD 0
    END
    
     
    Thumbnail
    symbol.png
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Log in to post a comment.

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
MongoDB Logo MongoDB