Wiki

Clone wiki

C-Development / ScriptFiles

File Formats

Fréchet View expects two polygonal curves as input data. These can be read from SVG or IPE files. There are numerous apps for editing vector graphics files, like InkScape or Ipe.

💡 While viewing a file in Fréchet View, you can edit the same file in any graphical or text editor. Saved changes are updated immediately in the Fréchet View window.

Use JavaScript to "program" complex curves. Have a look at some sample files zigzag.js or mcsp.js.

Our JavaScript interfaces defines two Path variables P and Q. All other common JavaScript constructs (functions, loops, variables, etc.) are avaible.

Path API

|| |------------------|--------------------------------| | new Path() | creates an empty Path object | | new Path(copy) | copies a Path object | || | M(x,y) | draws a polygon edge to (x,y) | | H(x) | horizontal edge to x | | V(y) | vertical edge to y | | m(x,y) | edge relative to the current location | | h(x,y) | horizontal edge, relative to current location| | v(x,y) | vertical edge, relative to current location| | Z() | close polygon | || | appendPath(path) | appends one path to another | | appendString(string) | appends a string encoded path. Strings contain a series of M-H-V-Z instructions, like "M 10 10 H 90 V 90 H 10 Z". Roughly follows the SVG Specification. | || | "Turtle Graphics" | | polar(angle,distance) | draws an edge defined by angle (360° degrees) and distance | | forward(distance) | move forward or backward | | left(angle) | turn left (without drawing an edge) | | right(angle) | turn right | | reset(angle) | update angle | || | Transformations| | scale(factor) | scales the whole Path object | | scale(x,y) | scales the whole Path object | | rotate(angle) | rotates the whole Path object | | translate(x,y) | translates the whole Path object | | mirrorx() | mirrors Path object horizontally | | mirrory() | mirrors Path object vertically |

Updated