基本绘图

查看 drawing.js 文件里的示例.

画 - draw

Annotate an image with one or more graphic primitives (shapes, text, transformations, pixel operations). Used internally for all drawing methods.

gm("img.png").draw(args)

弧角 - drawArc

Inscribe an elliptical arc within a rectangle. Requires a start and end point as well as the degrees of rotation.

gm("img.png").drawArc(x0, y0, x1, y1, r0, r1)

贝塞尔曲线 - drawBezier
gm("img.png").drawBezier([x0, y0], ... [xn, yn])
圆 - drawCircle
gm("img.png").drawCircle(x0, y0, x1, y1)
椭圆形 - drawEllipse
gm("img.png").drawEllipse(x0, y0, r0, ry, r0, r1)
线 - drawLine
gm("img.png").drawLine(x0, y0, x1, y1)
点 - drawPoint
gm("img.png").drawPoint(x, y)
多边形 - drawPolygon
gm("img.png").drawPolygon([x0, y0] ... [xn, yn])
多段线 - drawPolyline
gm("img.png").drawPolyline([x0, y0] ... [xn, yn])
矩形 - drawRectangle

wc and hc are optional and add roundness to the corners.

gm("img.png").drawRectangle(x0, y0, x1, y1 [, wc, hc])

文本 - drawText

Draws text on an image at x/y coordinates.

gm("img.png").drawText(x, y, text [, gravity])

填充颜色 - fill

Specifies the color to use when filling a drawn shape.

gm("img.png").fill(color)

字体 - font
gm("img.png").font(name)
字体大小 - fontSize
gm("img.png").fontSize(size)
划 - stroke

Specifies the color to use when stroking a drawn shape.

gm("img.png").stroke(color [, width])

设置边的宽度 - strokeWidth

Specifies the stroke width to use when stroking a drawn shape.

gm("img.png").strokeWidth(width)

设置属性 - setDraw

Sets drawing properties. property can be either "color" or "matte".

gm("img.png").setDraw(property, x, y, method)