суббота, 28 мая 2011 г.

GFig GIMP 2.6 files parsing/rendering

See modules "gfig" from "HMI pybase" project on Projects page.

Parsing
GFig files are very simple vector format in Gimp 2.x used by GFig plugin for shapes creation. It looks like this:

GFIG Version 0.1
Name: Simly\040face
Version: 0.000000
ObjCount: 1
GridSpacing: 30
GridType: RECT_GRID
DrawGrid: FALSE
Snap2Grid: FALSE
LockOnGrid: FALSE
ShowControl: TRUE
66 150
66 200

Parses only KNOWN SHAPES, all other are ignored. Also parses styles and extra parameters. Suppose fixed structure of file: lines are not joined! Known shapes are:
  • line
  • rectangle
  • circle
  • ellipse
  • poly
  • star
  • spiral
  • bezier
  • arc

Rendering
GFig GIMP 2.6 files renders with Tkinter (on canvas). Supports:
  • lines
  • circles
  • ellipses
  • rectangles
  • polygons
  • arcs
  • old style spirals (via lines)
and it's outline-, fill- colors, line width; also polygon has style ruby (recreate canvas object when changed - interesting effect with smooth=1, ruby=True). Not supported: Bezier, spiral, stars. All unknown objects are ignored.

Transforming of objects is supported: move, scale, rotate. It's possible to transform only one object or any selected objects (set) of gfig-file. First, shape class methods are used, for second, GFigRender methods are used. GFigRender transformation methods has arg shapes - shapes to be transformed. Also, you can select GFigRender shapes by find_shapes() method and process it (transform, configure, for ex.). Finding use classname of shape ("CanvasArc", "CanvasEllipse", etc) or any option (Tk cget, gfig option) in **kw form, or name of shape. Usually shapes don't have names (gfig-extension feature), but user can name each shape in order from left-to-right and top-to-bottom (canvas location) with method name_shapes(). find_shapes() returns list, ifind_shapes() - iterator.

Each shape can have label - text short string. Technically, label is created on first labelconfigure(), each other only changes label options. Label is placed by options: side (N|NW|CENTER...) and standard Tk anchor option; so side specified corner (about shape bbox) or center of bbox

Contribs
Thanks for creators of Gimp GFig:
  • Andy Thomas
  • Spencer Kimball
  • Peter Mattis

Комментариев нет:

Отправить комментарий

Thanks for your posting!