Difference between revisions of "Exploring Livarot"

From Inkscape Wiki
Jump to navigation Jump to search
Line 3: Line 3:
# Flood Tool (Shape->MakeOffset())
# Flood Tool (Shape->MakeOffset())
# Path Offsetting
# Path Offsetting
#* Inset/Outset
#* Inset/Outset (Livarot)
#* Dynamic Offset
#* Dynamic Offset (Livarot)
#* Linked Offset
#* Linked Offset (Livarot)
#* OffsetLPE
#* SPOffset (dynamic/linked offset) (Livarot)
#* LPEOffset (Livarot to flatten, half_outline())
# Boolean Operations
# Boolean Operations
# Flowing Text (Shape->Scan(), Shape->Transform())
# Flowing Text (Shape->Scan(), Shape->Transform())
# Path Simplification (Path->Coalesce() or Path->ConvertEvenLines() + path->Simplify())
# Path Simplification (Path->Coalesce() or Path->ConvertEvenLines() + path->Simplify())
# Path Flattening (lpe-offset.pp, elsewhere?)
# Path Flattening (lpe-offset.pp, elsewhere?)
Much of the code that uses Livarot to offset is duplicate three times:
* sp_selected_path_do_offset()
* sp_selected_path_create_offset_object() (This might not actually be needed as presumably the code in SPOffset::set_shape is what is displayed.)
* SPOffset::set_shape()
The common code should be made into a single function.


===How's it typically used?===
===How's it typically used?===

Revision as of 10:19, 24 March 2020

Why is it being used?

  1. Tweak Tool (Shape->MakeTweak())
  2. Flood Tool (Shape->MakeOffset())
  3. Path Offsetting
    • Inset/Outset (Livarot)
    • Dynamic Offset (Livarot)
    • Linked Offset (Livarot)
    • SPOffset (dynamic/linked offset) (Livarot)
    • LPEOffset (Livarot to flatten, half_outline())
  4. Boolean Operations
  5. Flowing Text (Shape->Scan(), Shape->Transform())
  6. Path Simplification (Path->Coalesce() or Path->ConvertEvenLines() + path->Simplify())
  7. Path Flattening (lpe-offset.pp, elsewhere?)


Much of the code that uses Livarot to offset is duplicate three times:

  • sp_selected_path_do_offset()
  • sp_selected_path_create_offset_object() (This might not actually be needed as presumably the code in SPOffset::set_shape is what is displayed.)
  • SPOffset::set_shape()

The common code should be made into a single function.

How's it typically used?

  1. Creating a livarot Path object by using Inkscape’s functions such as Path_for_item or Path_for_pathvector. These functions just store path descriptions inside the Path object. Such as moveTo,lineTo, cubicTo, etc. These are just instructions.
  2. Calling path->Convert or path->ConvertWithBackData. Given a threshold value, these functions create a polygon that approximates the path descriptions given in step 1. The smaller the threshold value, the better the approximation. This approximation is the fundamental tool of livarot that gives it the ability to do things like path boolean operations.
  3. Calling path->Fill(shape, ...) . This creates a directed graph structure from the approximated polygon. A directed graph just has points connected by edges.
  4. Calling shape->ConvertToShape(shape_input, ...). This function converts the graph created earlier, to a polygon without any self-intersections or duplicate points. It is one of the most important functions of livarot. It also takes a fill rule as the argument.
  5. Here whatever actual function you wanna perform is called. If you’re tweaking, you would call shape->MakeTweak, if you’re performing outset/inset, you’d call shape->MakeOffset. Similar functions exist for boolean operations.
  6. Calling shape->ConvertToForme(path). This converts the shape object back to a path whose SVG description you can grab and put in the XML tree.