Manual/Plugins/Scripting/0.9.3

From Knotter
< Manual‎ | Plugins‎ | Scripting
Revision as of 19:44, 22 May 2013 by Mattia Basaglia (talk | contribs) (Created page with "Scripts are in QtScript aka ECMAScript aka JavaScript. The details of the language are specified in the [http://qt-project.org/doc/qt-5.0/qtscript/ecmascript.html Qt ECMAScr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Scripts are in QtScript aka ECMAScript aka JavaScript.

The details of the language are specified in the Qt ECMAScript reference. This page focuses on functions and objects specific to Knotter.

Global Objects

point

A wrapper to QPointF.

Constructors
Name Type Description
point() point point(0,0)
point( point other ) line Copy point other
point( Number x, Number y ) point Create point with given coordinates
External functions
Name Type Description
opposite( point p ) point point(-p.x,-p.y)

line

A wrapper to QLineF most of the functionality of QLineF is also present in line.

Constructors
Name Type Description
line() line Empty line
line( other_line ) line Copy line other_line
line( p1, p2 ) line Line from point p1 to p2
Properties
Name Type Description
p1 point Starting point of the line
p2 point End point of the line
x1 Number p1.x
x2 Number p2.x
y1 Number p1.y
y2 Number p2.y
angle Number Angle of the line in degrees. An angle of 0° is a horizontal line pointing to the right.
length Number Length of the line (distance between p1 and p2
Methods
Name Type Description
intersect ( line other ) line Return the intersection point between the current line and other
normalVector() line Returns a line that is perpendicular to this line with the same starting point and length.
unitVector() line Returns the unit vector for this line, i.e a line starting at the same point as this line with a length of 1.0.
pointAt(Number t) point
translate(point off) Translate the line by off
translate(Number x,Number y) translate(point(x,y))

path

Object used in cusp plugins to draw the knot line, wrapper to the Knotter internal Path_Builder class. Cannot be constructed by the user.

Methods
add_line( point p1, point p2 ) Draw a straight line from p1 to p2
add_quad( point p1, point control, point p2 Draw a quadratic curve from p1 to p2 with control point control
add_cubic( point p1, point control1, point control2, point p2 ) Draw a cubic curve from p1 to p2 with control points control1 and control2