Embroidermodder icon indicating copy to clipboard operation
Embroidermodder copied to clipboard

Complete translation to C/SDL

Open robin-swift opened this issue 3 years ago • 2 comments

This used to have an issue but it was closed because it was mostly not about the specifics of the current effort (due to experiments with Python/Tk etc.) the key things to note are some changes in my coding approach.

  1. We're not scared of global variables. This is a utility, not a library, so no-one should be using this code within their separate project unless they intend to replace Embroidermodder 2. So namespace pollution is not an issue.
  2. All code files are included directly into embroidermodder.c so the build is really simple.
  3. We're not using CMake for building this project since if someone has all the libraries as shared objects the compilation could be a single line of shell. There is a build.sh utility to help with this, but it's far simpler than a CMake build and optional.
  4. This project, unlike libembroidery, is focussed mainly on the data structures and configuration. em2_data.c and em2_structs.c should be a really good way of understanding the code rather than starting with what the functions are. These hold the role that XML or another markup would hold in many other GUIs.
  5. There are three core features which all other features are subordinate to, they all use integer constants to refer to their specific behaviours:
    1. The actuator: a function that calls the action to be taken, connecting the user interface element to a function
    2. The widget builders: functions that constructs a widget given the data describing the toolbars, menubars, context menus etc.
    3. The settings system: a few arrays of all the settings to allow for bulk copying when the user wants to preview a feature without applying it or loading a setting from file.

The actual design of Embroidermodder 2 remains very similar and the specifics of the C++/Qt version have been hand translated into this version. The continuity from Embroidermodder 2 (before 2022) to Embroidermodder 2 (2022) should be easy to follow once the translation is complete.

robin-swift avatar Jul 06 '22 12:07 robin-swift

For specifics on the actuator, we have issue #282 , this is the parent issue for that one.

robin-swift avatar Jul 06 '22 12:07 robin-swift

Also for the history of this change start with #143

robin-swift avatar Jul 06 '22 12:07 robin-swift

Conclusions on the Lisp/scripting front.

Postscript is a language that we may have to support in libembroidery anyway since it is used to describe a lot of the existing vector graphics files out there, also we may use it to produce the pattern printouts. Postscript is also a stack oriented Turing complete computer language so we could establish a subset of it as out "shape description" mechanism for Embroidermodder.

See this tutorial for details: https://staff.science.uva.nl/a.j.p.heck/Courses/Mastercourse2005/tutorial.pdf

In exercise 9 it shows we have the ability to describe non trivial functions in this syntax:

1 2 div 1 2 div 3 sqrt mul add dup mul

Represents the expression $(\frac{1}{2}+\frac{1}{2}\sqrt{3})^2$. Since postscript is concatenative, we may represent the function $(x+\frac{1}{2}\sqrt{3})^2$ by just chopping this expression down:

1 2 div 3 sqrt mul add dup mul

Since add takes two arguments we have an incomplete lambda expression, it's just the input format is anonymous (unlike lisp). This seems like a really good reason to replace our "shape description" language with postscript (compiled into libembroidery) and remove TinyScheme.

robin-swift avatar Nov 05 '22 18:11 robin-swift