Error: no such theme PatternSkinTheme
You are here: Foswiki>Glimmer Web>DailyNotesInkscape>InkGuide>InkFuture (2011-07-20, KateIngersoll)EditAttach
-- KateIngersoll - 2011-07-20

Ink Script- For the Future

The annoying task of fixing things we've done

  1. Testing/Error messages: Currently, inkscript functions have minimal parameter checking. console.c includes type checking for the functions converted from dbus methods, so Media Script will print a useful error to the user if, for example, image-draw-polygon! is called with a string or a double value for "sides", but won't check to make sure that "sides" is only called with an integer larger than 2. There is no parameter checking in the wrapped procedures (found in wrapper_library.scm). It would help users if someone were to add parameter checking for all of the inkscript functions, using inkscript-documentation as a guide for valid parameter values.
  2. Improving methods: There are some methods that we're currently using that need to be wrapped with other functions in order to work correctly. It would be nice to re-write these methods, so the methods just do what we want in the first place.
    1. inkscape_draw_line (image-draw-line-orig!): same problem as inkscape_spiral. Wrapped func: image-draw-line!
    2. inkscape_load (document-load-orig): This method doesn't return a document-id number for the loaded document. A few notes: according to the documentation, this function should load a new image in the place of a given doc. In practice, this function only loads in the place of a doc if that doc is new. Otherwise, the image is loaded in a new window, leaving the given doc open. In our wrapped function, image-load! the image is loaded in a new window, but the function returns a doc-id.
    3. inkscape_move (object-move-orig!): This method only works if the object is already selected. Wrapped func: object-move!
    4. inkscape_move_to (object-move-to-orig!): same problem as inkscape_move. Wrapped_func: object-move-to!
    5. inkscape_selection_paste (selection-paste-orig!): This method doesn't paste the selection to any particular location of the document. The wrapped function isn't ideal, either: it just sends the pasted selection to the origin. Wrapped func: selection-paste!
    6. inkscape_selection_group (selection-group-orig!): This method doesn't return anything, but we want it to return the object id of the group. Wrapped func: selection-group!
    7. inkscape_spiral (image-draw-spiral-orig!): The spiral is drawn in the document's stroke color. If the document's stroke color is "none", the spiral's stroke should default to black. But instead, if the document's stroke isn't set, the spiral just isn't drawn. Wrapped func: image-draw-spiral!

Adding more functions!
  1. Current dbus methods: You may be interested in adding the rest of Soren's dbus methods. We implemented what we considered the most basic/essential inkscape methods, but if inkscript is getting expanded, it might be useful to include layer functions, update functions, the "image" function for importing a jpg image, etc. Once you have the source code for inkscape, and the dbus extension for inkscape, you should be able to find documentation for all of these dbus methods by running inkscape/src/extension/dbus/ This will build the documentation from xml. If this no longer works (if you're running a newer version of the dbus extension, and this has changed) try looking for a notes or a readme file in inkscape/src/extension/dbus for instructions.
    1. unused methods: these are the methods that we decided not to implement. We haven't tested them yet.
      1. layer_change_level
      2. layer_get_all
      3. layer_new
      4. layer_next
      5. layer_previous
      6. layer_set
      7. select_all_in_layers
      8. move_to_layer
      9. selection_move_to_layer
      10. pause_updates
      11. resume_updates
      12. update
      13. get_path
      14. image
      15. mark_as_unmodified
      16. merge_css
      17. node => creates a node.
      18. selection_to_path
    2. broken methods: these are methods that we wanted to use, but they're broken, and need to be rewritten (as of 7/13/2011)
      1. close => causes Inkscape to crash
      2. exit => causes Inkscape to crash
      3. object_to_path => causes Inkscape to crash
      4. get_node_coordinates => causes Inkscape to crash
      5. star =>can't change # sides, or change the orientation, ('arg1', 'arg2', and 'sides' parameters don't change the final shape)
      6. selection_box => just returns an error message....
      7. undo/redo seem to work in some situations and not others.
      8. selection_get_center => error "no (de)marshaller for GArray type"
  2. Ideas for wrapped functions:
    1. object-set-style! and document-set-style!: There are about 101 different wrapped functions you can write with object-set-style! You can set the pattern of the stroke (solid or a type of dash, and the spacing of the dash), the style of the corners, and so on. We only wrapped the most basic of these (setting the color, opacity, and the stroke width). To figure out what style attributes you can set, I would suggest experimenting by hand with many different objects, and then looking at each object's xml. Note that the type of style attributes in "style" depends on the type of object. For example, for text objects, the "style" attribute is used to set attributes like "font-size", "font-weight", and "line-height", as well as the more standard "fill", "fill-opacity", etc.
    2. object-set-attribute! and document-set-attribute!: Likewise, there maybe be some wrapped functions you can write using the set_attribute command. Our notes for inkscape object attributes can be found in InkInkscapeNotes. These notes include all the major attributes for rectangles, ellipses, polygons, and text, but not necessarily all attributes for these objects. Once functions are written to draw stars, calligraphic lines, paths, etc, object-set-attribute! will be a very helpful function for writing object commands for these objects.
    3. image-call-verb!: Look into useful/interesting inkscape verbs you could call with image-call-verb!
    4. transform commands Right now, we have a series of useful transformation functions (skew-x, skew-y, scale, scale-x, scale-y, hflip, vflip) that transform a shape without changing it's location. It would be nice to replace all of out "shape" commands with transform commands that work on all objects.
  3. Ideas for new inkscape methods (i.e. methods you would have to write yourself for dbus):
    1. New tools: Not a comprehensive list, but some of the major tools for inkscape that we are currently missing.
      1. measure tool (just a proc to calculate the distance between two points)
      2. draw box
      3. draw paths/curves
      4. draw with calligraphic brush
      5. spraycan
      6. erase
      7. fill area
      8. color picker
    2. Setting contexts: we're wondering if it would be valuable to write a series of functions that define the context for each tool. For example, calligraphic-brush-context commands to set the type of brush ("wiggly', 'dip pen', 'marker', etc), the width, brush affects like 'thinning', 'angle', etc. In other words, a series of commands that correspond to the toolbar for each tool. For lines and brush-strokes, for example, it seems to make more sense to set the context then set the style of the brush each time you use it, since the user is likely to draw more than one line at a time, and it would be punishing to set the type of brush, the width of the brush, etc, for each individual line. Does it make sense to follow the model of setting-the-context for all objects? Would it be confusing for users to have a set of "context" commands for creating objects, and a set of "object" commands for modifying existing objects?
    3. ellipse-types: setting an ellipse to a segment or an arc. If the ellipse is an arc, it has the attribute 'sodipodi:open' and the value 'true'. So, to get the ellipse to an arc, one can use (object-set-attribute! doc ellipse "sodipodi:open" "true"). But, to set the ellipse to a segment from an arc, one can't just set sopdipodi:open to "false"; one needs to delete the sodipodi:open attribute itself. Currently, we don't have a way to delete attributes.
    4. filters: a series of commands to apply filters, gradients, and patterns. A series of commands to list valid filters, gradients, and patterns. Note that filters, gradients, patterns, etc are assigned urls. So, if an object is filtered, the 'style' attribute of the object will include a 'filter' attribute such as "filter:url(#filter3425)". BUT, the url of a filter changes in each instance of inkscape! So, in one image, #filter3425 might reference the "cubes" filter, and in another image, it might reference the "felt" filter. urls are defined in the xml for a document under . That's about all we know; more experimentation/research needed.
Topic revision: r1 - 2011-07-20, KateIngersoll

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback