Module: Gluttonberg::Library::QuickMagick::Draw

Extended by:
ActiveSupport::Concern
Included in:
Image
Defined in:
lib/gluttonberg/library/quick_magick/image/draw.rb

Instance Method Summary collapse

Instance Method Details

#draw_arc(x0, y0, x1, y1, a0, a1, options = {}) ⇒ Object

The arc primitive is used to inscribe an elliptical segment in to a given rectangle. An arc requires the two corners used for rectangle (see above) followed by the start and end angles of the arc of the segment segment (e.g. 130,30 200,100 45,90). The start and end points produced are then joined with a line segment and the resulting segment of an ellipse is filled.



44
45
46
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 44

def draw_arc(x0, y0, x1, y1, a0, a1, options={})
  _draw_6_points("arc",  x0, y0, x1, y1, a0, a1, options)
end

#draw_bezier(points, options = {}) ⇒ Object

The Bezier primitive creates a spline curve and requires three or points to define its shape. The first and last points are the knots and these points are attained by the curve, while any intermediate coordinates are control points. If two control points are specified, the line between each end knot and its sequentially respective control point determines the tangent direction of the curve at that end. If one control point is specified, the lines from the end knots to the one control point determines the tangent directions of the curve at each end. If more than two control points are specified, then the additional control points act in combination to determine the intermediate shape of the curve. In order to draw complex curves, it is highly recommended either to use the path primitive or to draw multiple four-point bezier segments with the start and end knots of each successive segment repeated.



89
90
91
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 89

def draw_bezier(points, options={})
  _draw(options, "bezier #{points_to_str(points)}")
end

#draw_circle(x0, y0, x1, y1, options = {}) ⇒ Object

The circle primitive makes a disk (filled) or circle (unfilled). Give the center and any point on the perimeter (boundary).



56
57
58
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 56

def draw_circle(x0, y0, x1, y1, options={})
  _draw_4_points("circle", x0, y0, x1, y1, options)
end

#draw_ellipse(x0, y0, rx, ry, a0, a1, options = {}) ⇒ Object

Use ellipse to draw a partial (or whole) ellipse. Give the center point, the horizontal and vertical “radii” (the semi-axes of the ellipse) and start and end angles in degrees (e.g. 100,100 100,150 0,360).



51
52
53
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 51

def draw_ellipse(x0, y0, rx, ry, a0, a1, options={})
  _draw_6_points("ellipse",  x0, y0, rx, ry, a0, a1, options)
end

#draw_image(operator, x0, y0, w, h, image_filename, options = {}) ⇒ Object

Use image to composite an image with another image. Follow the image keyword with the composite operator, image location, image size, and filename You can use 0,0 for the image size, which means to use the actual dimensions found in the image header. Otherwise, it is scaled to the given dimensions. See -compose for a description of the composite operators.



108
109
110
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 108

def draw_image(operator, x0, y0, w, h, image_filename, options={})
  _draw(options, "image #{operator} #{x0},#{y0} #{w},#{h} \"#{image_filename}\"")
end

#draw_line(x0, y0, x1, y1, options = {}) ⇒ Object

draws a line between the given two points A line primitive requires a start point and end point.



22
23
24
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 22

def draw_line(x0, y0, x1, y1, options={})
  _draw_4_points("line", x0, y0, x1, y1, options)
end

#draw_path(path_spec, options = {}) ⇒ Object

A path represents an outline of an object, defined in terms of moveto (set a new current point), lineto (draw a straight line), curveto (draw a Bezier curve), arc (elliptical or circular arc) and closepath (close the current shape by drawing a line to the last moveto) elements. Compound paths (i.e., a path with subpaths, each consisting of a single moveto followed by one or more line or curve operations) are possible to allow effects such as donut holes in objects. (See www.w3.org/TR/SVG/paths.html)



100
101
102
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 100

def draw_path(path_spec, options={})
  _draw(options, "path #{path_spec}")
end

#draw_point(x, y, options = {}) ⇒ Object

draws a point at the given location in pixels A point primitive is specified by a single point in the pixel plane, that is, by an ordered pair of integer coordinates, x,y. (As it involves only a single pixel, a point primitive is not affected by -stroke or -strokewidth.)



16
17
18
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 16

def draw_point(x, y, options={})
  _draw(options, "point #{x},#{y}")
end

#draw_polygon(points, options = {}) ⇒ Object

The polygon primitive requires three or more points to define their perimeters. A polyline is simply a polygon in which the final point is not stroked to the start point. When unfilled, this is a polygonal line. If the -stroke setting is none (the default), then a polyline is identical to a polygon.

points - A single array with each pair forming a coordinate in the form (x, y).

e.g. [0,0,100,100,100,0] will draw a polygon between points (0,0)-(100,100)-(100,0)



74
75
76
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 74

def draw_polygon(points, options={})
  _draw(options, "polygon #{points_to_str(points)}")
end

#draw_polyline(points, options = {}) ⇒ Object

The polyline primitive requires three or more points to define their perimeters. A polyline is simply a polygon in which the final point is not stroked to the start point. When unfilled, this is a polygonal line. If the -stroke setting is none (the default), then a polyline is identical to a polygon.

points - A single array with each pair forming a coordinate in the form (x, y).

e.g. [0,0,100,100,100,0] will draw a polyline between points (0,0)-(100,100)-(100,0)



65
66
67
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 65

def draw_polyline(points, options={})
  _draw(options, "polyline #{points_to_str(points)}")
end

#draw_rectangle(x0, y0, x1, y1, options = {}) ⇒ Object

draw a rectangle with the given two corners A rectangle primitive is specified by the pair of points at the upper left and lower right corners.



28
29
30
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 28

def draw_rectangle(x0, y0, x1, y1, options={})
  _draw_4_points("rectangle", x0, y0, x1, y1, options)
end

#draw_round_rectangle(x0, y0, x1, y1, wc, hc, options = {}) ⇒ Object

draw a rounded rectangle with the given two corners wc and hc are the width and height of the arc A roundRectangle primitive takes the same corner points as a rectangle followed by the width and height of the rounded corners to be removed.



36
37
38
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 36

def draw_round_rectangle(x0, y0, x1, y1, wc, hc, options={})
  _draw_6_points("roundRectangle",  x0, y0, x1, y1, wc, hc, options)
end

#draw_text(x0, y0, text, options = {}) ⇒ Object

Use text to annotate an image with text. Follow the text coordinates with a string.



113
114
115
# File 'lib/gluttonberg/library/quick_magick/image/draw.rb', line 113

def draw_text(x0, y0, text, options={})
  _draw(options, "text #{x0},#{y0} '#{text}'")
end