A newer version of Max is available. Click here to access the latest version of this document.

lcd

Draw graphics in a patcher window

Description

In Max 4.0 and later, all lcd object drawing commands are now lower case. For backwards compatibility, old style capitalized message names are still understood; you can use either lineto or LineTo.

Arguments

None.

Messages

anything arguments [list]
anything refers to the backwards-compatible capitalized messages.
ascii text (0 through 255) [list]
The word ascii, followed by a number between 0 and 255, writes the character corresponding to that ASCII value at the current pen position, then moves the pen position to the right of that character. Numbers that exceed the 0-255 range are restricted to that range with a modulus operation.
clear arguments [list]
Erases the contents of lcd.
brgb RGB-list (0 through 255) [list]
The word brgb, followed by three numbers between 0 and 255, specify an RGB value sets the current background color of the lcd object.
clearpicts Deletes all of an lcd object's named pictures.
color ColorID(0 through 255) [int]
The word color, followed by a number from 0 to 255, specifies a color (from Max's color palette) for subsequent graphics drawn in lcd. Numbers that exceed the 0-255 range are restricted to that range with a modulus operation.
backsprite any symbol [list]
The word backsprite, followed by a symbol, sets the named sprite's drawing order so that it is drawn first (and displayed last). This command can be used to alter the order in which sprites are drawn. (Normally, sprites are drawn in the order they are recorded.)
deletepict any symbol [list]
The word deletepict, followed by a symbol, deletes the named picture.
deletesprite any symbol [list]
The word deletesprite, followed by a symbol, deletes the named sprite.
drawpict arguments [list]
The word drawpict, followed by a symbol, draws the named picture. Optionally there may follow four numbers specifying a destination rectangle in which the picture is scaled and drawn, and source rectangle that specifies the area of the picture to use in the operation. These rectangles are specified as left, top, width, and height values in pixels. The destination rectangle is relative to the top left corner of the lcd display area. The source rectangle is relative to the top, left corner of the picture. If not present, these rectangles are both set to be the same size as the picture.
clearsprites Deletes all of an lcd object's named sprites.
closesprite any symbol [list]
The word closesprite, followed by a symbol argument that names the sprite, turns off sprite command collection and associates the defined region with the symbol. After the closesprite message, drawing commands function normally again.
drawsprite any symbol [list]
The word drawsprite, followed by a symbol, draws the named sprite. Optionally this may be followed by a pair of numbers that specify a horizontal and vertical offset for drawing the sprite.
font font-ID and font-size [list]
The word font, followed by two numbers, specifies a font ID and a font size to be used when drawing text in response to a write or ascii message. This is the same font number mapping that Max 5 uses generally.
framearc left top right bottom start-angle (degrees) degrees-arc and color [list]
Same as paintarc except that only the unfilled outline of the arc is drawn.
frameoval left top right bottom and color [list]
Same as paintoval except that only the unfilled outline of the oval is drawn.
framepoly x/y-pairs and color [list]
Same as paintpoly except that only the unfilled outline of the polygon is drawn.
framerect left top right bottom and color [list]
Same as paintrect except that only the unfilled outline of the rectangle is drawn.
frameroundrect left top right bottom horizontal/vertical-roundness and color [list]
Same as paintroundrect except that only the unfilled outline of the rounded rectangle is drawn.
frgb RGB-list (0 through 255) [list]
The word frgb, followed by three numbers between 0 and 255, specify an RGB value sets the current foreground color of the lcd object.
frontsprite any symbol [list]
The word frontsprite, followed by a symbol, sets the named sprite's drawing order so that it is drawn last (and displayed first). This command can be used to alter the order in which sprites are drawn. (Normally, sprites are drawn in the order they are recorded.)
hidesprite any symbol [list]
Turns off the drawing of a named sprite in lcd.
getpenloc local-coordinates [list]
The word getpenloc outputs a message consisting of the word penloc followed by two numbers, out the lcd object's right outlet. The numbers represent local coordinates relative to the top-left corner of the lcd display area. The first number is the number of pixels to the right of that corner, and the second number is the number of pixels down from that corner.
getsize Ouputs a message from the right outlet consisting of the word size and two numbers which report the width and height in pixels of the lcd.
move horizontal and vertical-offset (pixels) [list]
Moves the pen position a certain number of pixels down from, and to the right of, its current position. The word move must be followed by two int arguments for horizontal and vertical offset, in pixels, relative to the current pen position. Negative arguments may be used to move the pen position up or to the left.
line horizontal and vertical-offset (pixels) [list]
The word line, followed by two int arguments for horizontal and vertical offset, in pixels, relative to the current pen position, draws a line from the current pen position to a point determined by the specified offset, and that point becomes the new pen position. Positive arguments draw the line to the right or down; negative arguments draw up or to the left.
moveto horizontal and vertical-offset (pixels) [list]
Sets the pen position at which the next graphic instruction will be drawn. The moveto message must include two int arguments for horizontal and vertical offset, in pixels, relative to the upper left corner of the lcd display area.
lineto horizontal and vertical-offset (pixels) [list]
The word lineto, followed by two int arguments for horizontal and vertical ending point, draws a line from the current pen position to the position specified by the arguments.
linesegment beginning and ending horizontal/vertical-offset pairs (pixels) [list]
The word linesegment, followed by four int arguments that specify the endpoints of a line segment, draw a line. The numbers represent the horizontal and vertical offset of the beginning endpoint, and the horizontal and vertical offset of the finishing endpoint, in pixels, relative to the top left corner of the lcd display area. Optionally, a color may follow. If there is one additional int argument, the color specifies a color from Max's color palette in the same way as the color message. If there are three additional int arguments, the color specifies a color as an RGB value in the same way as the frgb message.
(mouse) You can draw freehand in lcd with the mouse (provided this feature has not been turned off with a local 0 message). The mouse will draw with the current pen and color characteristics, and the mouse location will be sent out the outlet.
oprgb RGB-list (0 through 255) [list]
The word oprgb, followed by three numbers between 0 and 255, specify an RGB value used as the opcolor for penmodes that support it.
If the penmode is set to 32, the alpha channel value is derived by averaging the three RGB values and mapping the average to the range 0. - 1.0 (e.g., an oprgb value of 128 128 128 would have an alpha value of .5 when the penmode is set to 32).
paintarc left top right bottom start-angle (degrees) degrees-arc and color [list]
The word paintarc, followed by six int arguments that specify the left, top, right, and bottom extremities of an oval across which the arc will be drawn, the start angle (0 is the top) and degrees of arc, paints an arc.
paintoval left top right bottom and color [list]
The word paintoval, followed by four int arguments specifying the left, top, right, and bottom extremities of an oval, paints an oval. These extremities are specified in pixels, relative to the top left corner of the lcd display area. Optionally, a color may follow. If there is one additional int argument, the color specifies a color from Max's color palette in the same way as the color message. If there are three additional int arguments, the color specifies a color as an RGB value in the same way as the frgb message.
paintpoly x/y-pairs and color [list]
The word paintpoly may be followed by as many as 254 int arguments that would specify a series of x/y pairs that define a polygon to be painted in lcd. These x/y pairs are specified in pixels, relative to the top left corner of the lcd display area. Optionally, a color may follow the last x/y pair that is the same as the first one. If there is one additional int argument, the color specifies a color from Max's color palette in the same way as the color message. If there are three additional int arguments, the color specifies a color as an RGB value in the same way as the frgb message.
paintrect left top right bottom and color [list]
The word paintrect, followed by four int arguments specifying the left, top, right, and bottom positions of a rectangle, paints a rectangle. The edge positions are specified in pixels, relative to the top left corner of the lcd display area. Optionally, a color may follow. If there is one additional int argument, the color specifies a color from Max's color palette in the same way as the color message. If there are three additional int arguments, the color specifies a color as an RGB value in the same way as the frgb message.
paintroundrect left top right bottom horizontal/vertical-roundness and color [list]
The word paintroundrect, followed by six int arguments specifying the left, top, right, and bottom positions of a rectangle and the amount of horizontal and vertical roundness in pixels, paints a rounded rectangle. The edge positions are specified in pixels, relative to the top left corner of the lcd display area. Optionally, a color may follow. If there is one additional int argument, the color specifies a color from Max's color palette in the same way as the color message. If there are three additional int arguments, the color specifies a color as an RGB value in the same way as the frgb message.
penmode transfer-mode (0 through 7) [list]
The word penmode, followed by a number in the range 0-7, sets the transfer mode for subsequent drawing operations. The following are transfer mode constants;

Copy 0
Or 1
Xor 2
Bic 3
NotCopy 4
NotOr 5
NotXor 6
NotBic 7
pensize horizontal and vertical-thickness (pixels) [list]
The word pensize, followed by two equal int arguments specifying horizontal and vertical thickness in pixels (e.g., 4 4), sets the current pensize. The horizontal and vertical thicknesses must be equal.
scrollrect left top right bottom x-scroll y-scroll (pixels) [list]
The word scrollrect, followed by six int arguments that specify the left, top, right, and bottom positions of a rectangle to be scrolled and the number of pixels to scroll in the x and y direction, scrolls a rectangle within the lcd object's display area.
setpixel x and y coordinate pair [list]
The word setpixel, followed by two numbers which specify a location in local coordinates relative to the top-left corner of the lcd display area and a list of three integers in the range 0-255 which specify a color in RGB format, will set the pixel at the designated location to the selected color.
size horizontal (pixels) [int]
vertical (pixels) [int]
Changes the size of the lcd object. The word size must be followed by two int arguments which specify the dimensions (horizontal and vertical) in pixels of the new size.
readpict filename [list]
The word readpict followed by a symbol which specifies a filename, looks for a QuickTime graphic file (a .pct file openable on Windows using the QuickTime Picture Viewer for Windows) with that name in Max's file search path, and reads the picture file from disk into RAM. This named picture can then be drawn in lcd with the drawpict and tilepict messages. In response to the readpict message, the object sends a message out the right outlet of the lcd object consisting of the word pict followed by a symbol which specifies the name of the picture file and two numbers which specify the file's width and height. If the read is unsuccessful, the error message pict <pictname> error will be sent out the right outlet.
recordsprite Initiates the recording of drawing commands which will be stored in a named sprite. While recording, drawing commands will have no effect on the contents of the lcd object's window.
reset arguments [list]
Erases the contents of lcd and resets pen state to default values. The reset message is equivalent to the sequence

clear

pensize 1

penmode 0

frgb 0 0 0(black)

brgb 255 255 255(white)

moveto 0 0
textface text-styles [list]
The word textface, followed by one or more names specifying text style(s), sets the font style(s) to be used when rendering text. Text style names are normal, bold, and italic.
tilepict arguments [list]
The word tilepict, followed by a picture name argument, fills a rectangle by tiling a picture. Optionally there may follow, four numbers that specify a destination rectangle in which the picture is tiled and four numbers that specify a source rectangle that specifies the area of the picture to use in the operation. These rectangles are specified as left, top, width, and height values in pixels. The destination rectangle is relative to the top left corner of the lcd display area. The source rectangle is relative to the top, left corner of the picture. If not present, the destination rectangle is set to the same size of lcd, and the source rectangle is set to be the same size as the picture.
write any symbol [list]
The word write, followed by any symbol, writes that symbol beginning at the current pen position, and moves the pen position to the end of the text.
writepict filename [symbol]
The word writepict, followed by an optional filename argument, writes the current contents of the lcd display area to a PNG file.

Attributes

Name Type g/s Description
bgtransparent int
def.:0
Toggles background transparency. The message bgtransparent 1 sets the background of the lcd object to transparent. When set to 1, the background of the object remains transparent until you clear it using the clear message. When the attribute value is set to 0 (the default) the background is initially white, consistent with earlier versions of Max.
border int
def.:1
The word border, followed by a zero or one, toggles the drawing of a border around the lcd object's window, which is on by default. A message of border 0 turns this feature off.
enablesprites int
def.:0
Toggles the drawing of sprites. The message enablesprites 0 turns this feature off (the default). When sprites are enabled, lcd consumes more memory.
idle int
def.:0
Toggles the reporting of idle mouse position over an lcd object. The coordinates of the mouse position are sent out the middle outlet as a two-item list as the mouse moves. The numbers represent local coordinates relative to the top-left corner of the lcd display area. The first number is the number of pixels to the right of that corner, and the second number is the number of pixels down from that corner. idle 0 turns off this feature, which is off by default.
local int
def.:1
Toggles drawing in the lcd with the mouse. The message local 1 turns the feature on (the default). In either case, lcd will still report the location of the mouse as it is dragged within the object's rectangle.

Information for box attributes common to all objects

Output

int: Out 3rd outlet: A 1 is sent out the third outlet if the mouse button is currently being held down. A 0 is sent, otherwise.
list: Out 1st outlet: When you draw in the lcd with the mouse button held down, the coordinates of the mouse position are sent out the outlet as a two-item list as the mouse moves. The numbers represent local coordinates relative to the top-left corner of lcd. The first number is the number of pixels to the right of that corner, and the second number is the number of pixels down from that corner.
list: Out 2nd outlet: If the idle attribute is set to one, the coordinates of the mouse position are sent out the second outlet as a two-item list as the mouse moves. The numbers represent local coordinates relative to the top-left corner of the lcd display area. The first number is the number of pixels to the right of that corner, and the second number is the number of pixels down from that corner.
penloc: Out 4th outlet: In response to the getpenloc message, lcd outputs a message consisting of the word penloc followed by two numbers representing the pen location in local coordinates relative to the top-left corner of the lcd display area. The first number is the number of pixels to the right of that corner, and the second number is the number of pixels down from that corner.
update: Out 4th outlet: The word update is output whenever lcd receives an update message from Max telling it to redraw itself. This is only done when lcd is in onscreen mode

Examples

Draw an angular snake diagram using lcd

See Also

Name Description
mousestate Report the status and location of the mouse
panel Colored background area
Max Basic Tutorial 9: Mouse Drawing Max Basic Tutorial 9: Mouse Drawing