# IupDraw

Description: | A group of functions to draw in an IupCanvas or an IupBackgroundBox. They are simple functions designed to help the drawing of custom controls based on these two controls. It is NOT a complete set of drawing functions, for that you should still use another toolkit like CD. IMPORTANT: all functions can be used only in IupCanvas or IupBackgroundBox and inside the ACTION callback. To force a redraw anytime use the functions IupUpdate or IupRedraw.
pwa/p2js: | Supported, apart from IupDrawSetClipRect, IupDrawResetClip, IupDrawGetClipRect, IupDrawParentBackground, IupDrawPolygon, IupDrawImage, IupDrawSelectRect, IupDrawFocusRect, and IupDrawGetImageInfo.
See Also: | IupCanvas, IupBackgroundBox, IupUpdate, IupRedraw
Functions: | Control: All primitives can be called only between calls to IupDrawBegin and IupDrawEnd. IupDrawBegin(Ihandle ih) - Initialize the drawing process. IupDrawEnd(Ihandle ih) - Terminates the drawing process. IupDrawSetClipRect(Ihandle ih, int x1, int y1, int x2, int y2) - Defines a rectangular clipping region?. IupDrawResetClip(Ihandle ih) - Reset the clipping area to none?. integer {x1,y1,x2,y2} = IupDrawGetClipRect(Ihandle ih) - Returns the previous rectangular clipping region set by IupDrawSetClipRect, if clipping was reset returns 0 in all values ?. Primitives: The primitives color is controlled by the attribute DRAWCOLOR+. Default: "0 0 0". Rectangle, Arc and Polygon can be filled or stroked. When stroked the line style can be continuous, dashed or dotted. These are controlled by the attribute DRAWSTYLE?. Can have values: FILL, STROKE, STROKE_DASH, STROKE_DOT, STROKE_DASH_DOT or STROKE_DASH_DOT_DOT (dash dot and dash dot dot since 3.25). Default: STROKE. The FILL value when set before IupDrawLine has the same effect as STROKE. The line width default is 1, but it can be controlled by the DRAWLINEWIDTH attribute. (since 3.24) IupDrawParentBackground(Ihandle ih) - Fills the canvas with the native parent background color?. IupDrawLine(Ihandle ih, integer x1, y1, x2, y2) - Draws a line including start and end points. IupDrawRectangle(Ihandle ih, integer x1, y1, x2, y2) - Draws a rectangle including start and end points. IupDrawArc(Ihandle ih, integer x1, y1, x2, y2, atom a1, a2) - Draws an arc inside a rectangle between the two angles in degrees. When filled will draw a pie shape with the vertex at the center of the rectangle. Angles are counter-clock wise relative to the 3 o’clock position. IupDrawPolygon(Ihandle ih, sequence points) - Draws a polygon. Coordinates are stored in the array in the sequence: x1, y1, x2, y2, ..?. IupDrawText(Ihandle ih, string str, integer x, y, w=0, h=0) - Draws a text in the given position using the font defined by DRAWFONT? (since 3.22), if not defined then use FONT. The coordinates are relative the top-left corner of the text. Strings with multiple line are accepted using '\n' as line separator. Horizontal text alignment for multiple lines can be controlled using DRAWTEXTALIGNMENT attribute: ALEFT (default), ARIGHT and ACENTER options (since 3.22). For single line texts if the text is larger than its box and DRAWTEXTWRAP=Yes, then the line will be automatically broken in multiple lines. Notice that this is done internally by the system, the element natural size will still use only a single line. For the remaining lines to be visible the element should use EXPAND=VERTICAL or set a SIZE/RASTERSIZE with enough height for the wrapped lines. (since 3.25) If the text is larger that its box and DRAWTEXTELLIPSIS=Yes, an ellipsis ("...") will be placed near the last visible part of the text and replace the invisible part. It will be ignored when WRAP=Yes (since 3.25). w and h are optional and can be -1 or 0, the text size will be used, so WRAP nor ELLIPSIS will not produce any changes. The text is not automatically clipped to the rectangle, if DRAWTEXTCLIP=Yes it will be clipped but depending on the driver may affect the clipping set by IupDrawSetClipRect (since 3.25). The text can be draw in any angle using DRAWTEXTORIENTATION?, in degrees and counterclockwise (since 3.25), its layout is not centered inside the given rectangle when text is oriented, to center the layout use DRAWTEXTLAYOUTCENTER=Yes. Text orientation, ellipsis and wrap are not supported in X11. IupDrawImage(Ihandle ih, string name, integer x, y, w=0, h=0) - Draws an image given its name?. The coordinates are relative the top-left corner of the image. The image name follows the same behavior as the IMAGE attribute used by many controls. Use IupSetHandle or IupSetAttributeHandle to associate an image to a name. See also IupImage. The DRAWMAKEINACTIVE attribute can be used to force the image to be draw with an inactive state appearance. The DRAWBGCOLOR can be used to control the inactive state background color or when transparency is flatten. w and h are optional and can be -1 or 0, then the image size will be used and no zoom will be performed (since 3.25). Image zoom is not supported in X11 and GDK. IupDrawSelectRect(Ihandle ih, integer x1, y1, x2, y2) - Draws a selection rectangle?. IupDrawFocusRect(Ihandle ih, integer x1, y1, x2, y2) - Draws a focus rectangle?. Information: integer {width,height} = IupDrawGetSize(Ihandle ih) - Returns the drawing area size. integer {width,height} = IupDrawGetTextSize(Ihandle ih, string str) - Returns the given text size using the font defined by DRAWFONT, if not defined then use FONT. integer {width,height,bpp} = IupDrawGetImageInfo(string name) - Returns the given image size and bits per pixel. bpp can be 8, 24 or 32?.