Not sure if this post will ever see the light day. Mostly because all I currently have on my to do list is to add links to the animations to the various menues. With some warnings of course. But, I am also thinking about giving the user the choice to wait longer in order to get a higher resolution animation/video.

With the current values, the circles do jump a fair distance between frames. That jump is really visually discomforting at low frame per second rates. But, I have been trying to balance the app’s response time for animations against resolution and file size. All three present their own needs and issues.

As things stand, I don’t have any ideas for any new image variations. Though I would really like to find a better way to generate, save and display animations/videos. Unfortunately my knowledge and skills are not up to that challenge. And, I have recently (early 2023) started working on learning a little something about programming in Rust. Gnarly language that. I am also trying to work through a book on geometrical concepts for programmers. All in all time consuming endeavours.

But I like to document what I am doing, so I will continue with describing the menu changes and related code (Python, jinja, HTML, etc.). Whether the post gets published is pretty much irrelevant.

User Selectable Animation Step Size

When I add the animations to the menues, I plan on giving the user the option to generate wheeled animation video files with low (128 frames) or medium (256 frames) resolution. I may eventually allow higher resolutions, but at the moment do not plan on doing so. So, a new global variable and some changes to fini_curve_form() and proc_curve_form(). As well as minor change to the route code.

The globals for animations now look like this:

# animation related vars
max_life = 5    # maximum session duration in minutes, since latest request
max_ani = 5     # max animation file ids
poss_ids = list("spirograph")  # all possible file ids
file_ids = {}   # key = string, letter or two?; value = timestamp of last animation request
ani_xtra = 0    # number of animation requests after max file ids alloted
ani_step = 8    # frame step rate for generating animations, number points / ani_step -> nbr frames in video file

To fini_curve_form() I added the some suitable values to the dflts and fld_2_glbl dictionaries. And, that was that.

  dflts = {
    ... ...
    'ani_step': '8',
  }
  fld_2_glbl = {
    ... ...
    'ani_step': g.ani_step,
  }

In proc_curve_form() there was a little extra code in various places. Some of it from the previous post that I apparently failed to mention. Adding some extra lines for context.

... ...
    u_whl = f_data['wheels']
    u_lw = f_data['ln_sz']
    if i_typ == 'ani_wheel':
      g.t_pts = 1024
      if f_data['ani_step'] in [4, 8]:
        g.ani_step = int(f_data['ani_step'])
      else:
        g.ani_step = 8
    else:  
      g.t_pts = int(f_data['npts'])
... ...
    if i_typ == 'ani_wheel':
      u_shp = 'c'
    else:
      if 'shape' in f_data:
... ...
      if u_whl.isnumeric():
        g.n_whl = int(u_whl)
      elif u_whl.lower() == 'r':
        g.n_whl = rng.integers(3, 13)
      if i_typ == 'ani_wheel':
        g.n_whl = min(g.n_whl, 7)
        g.u_whl = str(g.n_whl)

And in the route function, a small change: v_frm_ratio = g.ani_step.

I have not yet modified the curve details form. But in the templates\image_links.html I am using the following to generate links to 3 animation variations.

{% set sp_ani = {
  "Basic<br>&nbsp;": ("ani_basic", "ani_basic.png", 8),
  "With Wheels<br>(low res)": ("ani_wheel", "ani_wheel_1.png", 8),
  "With Wheels<br>(med res)": ("ani_wheel", "ani_wheel_2.png", 4)}
%}

<div class="flex-container" style="margin:0;padding:0;">
  {% for i_typ in sp_ani %}
  <div>
    {% if i_typ == "Blank" %}
      &nbsp;
    {% else %}
      {% set sp_ttl = i_typ.split('<br>') %}
      <p><a href="{{ url_for(sp_ani[i_typ][0]) }}">{{ sp_ttl[0] }}</a><br>{{ sp_ttl[1]|safe }}</p>
      <form  method="post" action="{{ url_for(sp_ani[i_typ][0]) }}" class="img_btn">
        <input type="hidden" name="shp_mlt" value="">
        <input type="hidden" name="ani_step" value="{{ sp_ani[i_typ][2] }}">
        <input type="image" id="basic" src="{{url_for('static', filename=sp_ani[i_typ][1])}}"
         alt="basic spirograph image"
         style="margin:0; padding:0; width:100px; height:100px;">
      </form>
    {% endif %}  
    </div>
    {% endfor %}
</div>

I won’t bother showing the changes to the text_links.html template. I am sure you can sort that out yourself.

Done

Decided to publish. Mainly because I have been fighting a Covid infection this week and didn’t really feel I have anything else ready to go.