Stroke drawing tool

Log-in or register.

Shape drawing tool

rsrc/stroke-tool.png image STROKE is a drawing tool capable of drawing lines and curves. The path is defined by a series of vertices with tangents.

How to use the Stroke tool

A new stroke is created by defining at least 2 vertices. A vertex is added by clicking an optionally moving the mouse while keeping the button pressed. A simple click adds a sharp vertex (with zero tangents) while a click+drag creates a smooth vertex with the forward tangent defined by the dragging part (backward tangent has the same size, but opposite direction).

The Stroke tool, unlike other tools, can react to mouse clicks differently depending on its current state. Initially, it responds to all mouse clicks by adding new vertices. After right-clicking and selecting "End sub-path" from context menu, the interpretation of mouse actions changes. Instead of adding new points, the shape can now be moved by dragging it or, if clicked out of the shape, a different object may be selected (in a vector layer) or the shape is applied (in a raster layer).

A shape can be modified via the control handles. There are 3 kinds of handles (+ optional handles depending on current fill style). The azure handles represent and control positions of vertices. The brown handles control the tangents at each vertex. Green handles represent the segments between two vertices and can be used to split the segment by inserting a new vertex.

There are several commands accessible from the context menu. Right-click on the canvas or on individual vertices to display the commands. These commands allow deleting a vertex, smoothing a vertex, replacing a segment with line or arc or mirroring the shape along one of its line segments.

Stroke supports all shape-fill modes: it is capable of drawing filled shape, shape outline or combination thereof. The outline if drawn with primary color, while the interior uses the active fill style.

When used in a raster layer, Shape can be combined with many meta-tools (select, stylize, eraser) to achieve various effects.

Scripting parameters

STROKE tool can be used from scripts. The command in script specifies may specify width, dashing, join and cap styles and is followed by 2 or more vertices. Each vertex consists of 7 parameters:

  • type - "C" for normal vertex, "E" for last vertex in a sub-path.
  • positionX, positionY - coordinates of the vertex.
  • previousX, previousY - backward tangent direction.
  • nextX, nextY - forward tangent direction.

Example

DrawTool.STROKE(Document, "CWIDTH", 1, "CROUND", "JROUND", "C", 50, 100, 0, -25, 0, 25, "E", 100, 100, 0, 25, 0, -25);

See also: DrawTool object, Document object

Recent comments

user icon Anonymous
I wish there were...
What about ICL files?