You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/graphics.txt
+41-34
Original file line number
Diff line number
Diff line change
@@ -28,47 +28,54 @@ end
28
28
29
29
API overview
30
30
--------------
31
-
-- Callback functions you can define
32
31
33
-
pd:Class:mouse_down(x, y) -- Mouse down callback, called when the mouse is clicked
34
-
pd:Class:mouse_up(x, y) -- Mouse up callback, called when the mouse button is released
35
-
pd:Class:mouse_move(x, y) -- Mouse move callback, called when the mouse is moved while not being down
36
-
pd:Class:mouse_drag(x, y) -- Mouse drag callback, called when the mouse is moved while also being down
32
+
-- Callback functions you can define
33
+
pd:Class:mouse_down(x, y) -- Mouse down callback, called when the mouse is clicked
34
+
pd:Class:mouse_up(x, y) -- Mouse up callback, called when the mouse button is released
35
+
pd:Class:mouse_move(x, y) -- Mouse move callback, called when the mouse is moved while not being down
36
+
pd:Class:mouse_drag(x, y) -- Mouse drag callback, called when the mouse is moved while also being down
37
37
38
38
-- Functions you can call
39
-
pd:Class:repaint() -- Request a repaint, after this the "paint" callback will occur
40
-
pd:Class:paint(g) -- Paint callback, returns a graphics_context object (commonly called g) that you can call these drawing functions on:
41
-
g:set_size(w, h) -- Sets the size of the object.
42
-
width, height = g:get_size(w, h) -- Gets the size of the object.
39
+
pd:Class:repaint() -- Request a repaint, after this the "paint" callback will occur
40
+
pd:Class:paint(g) -- Paint callback, returns a graphics_context object (commonly called g) that you can call these drawing functions on:
41
+
42
+
g:set_size(w, h) -- Sets the size of the object
43
+
width, height = g:get_size(w, h) -- Gets the size of the object
43
44
44
-
g:set_color(r, g, b, a=1.0) -- Sets the color for the next drawing operation.
45
+
g:set_color(r, g, b, a=1.0) -- Sets the color for the next drawing operation
45
46
46
-
g:fill_ellipse(x, y, w, h) -- Draws a filled ellipse at the specified position and size.
47
-
g:stroke_ellipse(x, y, w, h, line_width) -- Draws the outline of an ellipse at the specified position and size.
47
+
g:fill_ellipse(x, y, w, h) -- Draws a filled ellipse at the specified position and size
48
+
g:stroke_ellipse(x, y, w, h, line_width) -- Draws the outline of an ellipse at the specified position and size
48
49
49
-
g:fill_rect(x, y, w, h) -- Draws a filled rectangle at the specified position and size.
50
-
g:stroke_rect(x, y, w, h, line_width) -- Draws the outline of a rectangle at the specified position and size.
50
+
g:fill_rect(x, y, w, h) -- Draws a filled rectangle at the specified position and size
51
+
g:stroke_rect(x, y, w, h, line_width) -- Draws the outline of a rectangle at the specified position and size
51
52
52
-
g:fill_rounded_rect(x, y, w, h, corner_radius) -- Draws a filled rounded rectangle at the specified position and size.
53
-
g:stroke_rounded_rect(x, y, w, h, corner_radius, line_width) -- Draws the outline of a rounded rectangle at the specified position and size.
53
+
g:fill_rounded_rect(x, y, w, h, corner_radius) -- Draws a filled rounded rectangle at the specified position and size
54
+
g:stroke_rounded_rect(x, y, w, h, corner_radius, line_width) -- Draws the outline of a rounded rectangle at the specified position and size
54
55
55
-
g:draw_line(x1, y1, x2, y2) -- Draws a line between two points.
56
-
g:draw_text(text, x, y, w, fontsize) -- Draws text at the specified position and size.
56
+
g:draw_line(x1, y1, x2, y2) -- Draws a line between two points
57
+
g:draw_text(text, x, y, w, fontsize) -- Draws text at the specified position and size
57
58
58
-
g:fill_all() -- Fills the entire drawing area with the current color. Also will draw an object outline in the style of the host (ie. pure-data or plugdata)
59
+
g:fill_all() -- Fills the entire drawing area with the current color. Also will draw an object outline in the style of the host (ie. pure-data or plugdata)
59
60
60
-
g:translate(tx, ty) -- Translates the coordinate system by the specified amounts.
61
-
g:scale(sx, sy) -- Scales the coordinate system by the specified factors. This will always happen after the translation
62
-
g:reset_transform() -- Resets current scale and translation
61
+
g:translate(tx, ty) -- Translates the coordinate system by the specified amounts
62
+
g:scale(sx, sy) -- Scales the coordinate system by the specified factors. This will always happen after the translation
63
+
g:reset_transform() -- Resets current scale and translation
63
64
64
-
p = Path(x, y) -- Initiates a new path at the specified point
65
-
p:line_to(x, y) -- Adds a line segment to the path.
66
-
p:quad_to(x1, y1, x2, y2) -- Adds a quadratic Bezier curve to the path.
67
-
p:cubic_to(x1, y1, x2, y2, x3, y) -- Adds a cubic Bezier curve to the path.
68
-
p:close_path() -- Closes the path.
65
+
p = Path(x, y) -- Initiates a new path at the specified point
66
+
p:line_to(x, y) -- Adds a line segment to the path
67
+
p:quad_to(x1, y1, x2, y2) -- Adds a quadratic Bezier curve to the path
68
+
p:cubic_to(x1, y1, x2, y2, x3, y) -- Adds a cubic Bezier curve to the path
69
+
p:close_path() -- Closes the path
70
+
71
+
g:stroke_path(p, line_width) -- Draws the outline of the path with the specified line width
72
+
g:fill_path(p) -- Fills the current path
73
+
74
+
-- Additional functions
75
+
expandedsymbol = pd:Class:canvas_realizedollar(s) -- Expand dollar symbols in patch canvas context
76
+
pd:Class:set_args(args) -- Set the object arguments to be saved in the patch file
77
+
pd:Class:get_args() -- Get the object arguments to be saved in the patch file
69
78
70
-
g:stroke_path(p, line_width) -- Draws the outline of the path with the specified line width.
71
-
g:fill_path(p) -- Fills the current path.
72
79
73
80
Basic example
74
81
---------------------
@@ -94,12 +101,12 @@ function example:mouse_drag(x, y)
0 commit comments