Painter(3I)
β¨ Painter(3I) β¨
okay so bestie, we're in the InterViews Reference Manual section 3I today and the vibe is graphics output β literally that's the whole NAME, "Painter - graphics output" π¨π
β¨ SYNOPSIS β¨
#include <InterViews/painter.h>
π DESCRIPTION π
So Painter is a class, right? And what it does is give you "immediate-mode" graphics operations for drawing on a canvas. Periodt. ποΈ
And here's the thing β a painter's state is the graphics context for all those drawing ops. Like, it's holding:
- a brush
- foreground and background colors
- a fill pattern and mode
- a text font
- a text style
- an output origin and current position
- and a transformation matrix
That's the whole squad right there. No cap. π
π STATE OPERATIONS π
Painter(Painter* = stdpaint)β Make a brand new painter and copy its whole state from the painter you hand it. Default isstdpaint, iykyk. π«Άvoid SetBrush(Brush*)/Brush* GetBrush()β Set or get the painter's brush. Default is the predefined brushsingle. Simple, iconic.void SetColors(Color* fg, Color* bg)/Color* GetFgColor()/Color* GetBgColor()β Set or get the painter's colors. Heads up bestie: if either argument toSetColorsisnil, then that corresponding color just... doesn't change. No drama. Defaults areblackfor foreground andwhitefor background. π€π€void SetFont(Font*)/Font* GetFont()β Set or get the painter's text font. Default is the predefined fontstdfont. β¨void SetStyle(int style)/int GetStyle()β Set or get the text style. A text style is a bit vector, and you assemble it from the predefined constantsPlain,Boldface,Underlined, andReversed. Default isPlain. Mix and match, she's flexible πvoid SetPattern(Pattern*)/Pattern* GetPattern()/void FillBg(boolean mode)/boolean BgFilled()β Set or get the fill pattern and mode. If the mode istrue, fill operations set pixels corresponding to ones in the current fill pattern to the foreground color, and pixels corresponding to zeros to the background color. If it'sfalse, then only the foreground pixels get set. Default pattern issolid; default mode istrue. πvoid SetOrigin(int x0, int y0)/void GetOrigin(int& x0, int& y0)β Set or get the origin that all your coordinates get offset by. Default is(0, 0). The classic.void Translate(float dx, float dy)/void Rotate(float angle)/void Scale(float x, float y)/void SetTransformer(Transformer*)/Transformer* GetTransformer()β Coordinates you pass to drawing operations get transformed according to the current origin, translation (which is cumulative, mind you), rotation, and scale factor. Internally there's a transformation matrix stored that you can directly set and access withSetTransformerandGetTransformer. The default transformer isnil, which means no transformations happen at all β just vibes. π¦void SetPlaneMask(int mask)β Sets which bit planes get affected by drawing operations. If the Kth bit ofmaskis set, then display operations will draw on plane K. Plane K said yes to being included. πvoid SetOverwrite(boolean)β Sets whether a painter is allowed to write in subcanvases. Iftrue, drawing operations will be able to write over the canvases of component interactors. Iffalse, drawing operations get clipped by any subcanvases. The default isfalse. π§void Clip(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2)/void NoClip()βCliprestricts output operations to the specified region of the canvas.NoClipremoves the restriction so operations affect the entire canvas. And listen: only one clipping region may be in effect at a time. One. Not two. Pick a lane. πvoid MoveTo(Coord x, Coord y)β Sets the current output position. This position is used and updated byTextandCurveTo. She's a main character who grows. π±
π DRAWING OPERATIONS π
void Curve(Canvas*, Coord x0, y0, x1, y1, x2, y2, x3, y3)/void CurveTo(Canvas*, Coord x1, y1, x2, y2, x3, y3)β Paints a Bezier curve on the canvas from the first point to the last point (but not going through the intermediate control points, so don't @ me). The curve will lie within the polygon formed by the four points.CurveTouses the current position for the first point. πvoid BSpline(Canvas*, Coord x[], y[], int n)/void ClosedBSpline(Canvas*, Coord x[], y[], int n)/void FillBSpline(Canvas*, Coord x[], y[], int n)β Draws the B-spline defined by thencontrol vertices. If it's closed or filled, the last point gets connected back to the first point. Full circle moment. πvoid Circle(Canvas*, Coord x, y, int r)/void FillCircle(Canvas*, Coord x, y, int radius)β Draws a circle with center(x, y)and radiusr. Yes, the parameter is calledrin one andradiusin the other, and yes, we're keeping it exactly like that. πvoid Ellipse(Canvas*, Coord x, y, int xr, int yr)/void FillEllipse(Canvas*, Coord x, y, int xr, int yr)β Draws an ellipse with center(x, y), horizontal radiusxr, and vertical radiusyr. An icon, but stretched. π₯void Line(Canvas*, Coord x1, y1, x2, y2)/void MultiLine(Canvas*, Coord x[], y[], int n)/void Polygon(Canvas*, Coord x[], y[], int n)/void FillPolygon(Canvas*, Coord x[], y[], int n)β Draw a path using the current brush and colors.Linedraws a vector between two points (inclusive);MultiLinedraws a number of connected vectors;Polygondraws a closed set of vectors;FillPolygonfills the area inside a polygon using the current fill pattern and colors. ποΈvoid Point(Canvas*, Coord x, y)/void MultiPoint(Canvas*, Coord x[], y[], int n)β Sets a point, or a whole set of points, to the current foreground color. Tiny but mighty. βvoid Rect(Canvas*, Coord x1, y1, x2, y2)/void FillRect(Canvas*, Coord x1, y1, x2, y2)/void ClearRect(Canvas*, Coord x1, y1, x2, y2)β Draws a rectangle with opposite corners specified by(x1, y1)and(x2, y2).FillRectfills it using the current pattern and colors;ClearRectfills it with the background color. π¦void Text(Canvas*, const char* str, Coord x, Coord y)/void Text(Canvas*, const char* str, int n, Coord x, Coord y)/void Text(Canvas*, const char* str)/void Text(Canvas*, const char* str, int n)β Draws a string, or a substring of text, using the currentFontand text style.
The (x, y) coordinates specify the lower-left corner of the bounding box of the text. The width of that bounding box is the width of the string as reported by the Font::Width operation, and the height of the bounding box is the Font height. Most fonts will result in output that only affects pixels within the bounding box.
The current transformation matrix gets applied to both the positions and the shapes of the characters drawn.
β οΈ If the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. She's doing her best but she's working hard for it. π
If background fill mode is on, the characters are drawn in the foreground color and the other pixels within the bounding box get set to the background color. If background fill mode is off, only the foreground pixels get set.
If you don't specify coordinates, then the current position (the one defined by MoveTo) is used β and it gets updated to reflect the lower-right corner of the bounding box. π
void Stencil(Canvas*, Coord x, Coord y, Bitmap* image, Bitmap* mask = nil)β Paints foreground and background colors through a stencil formed by positioning theimageandmaskBitmaps with their origins at the point(x, y). Foreground color gets painted where theimageBitmap has a true value, and background color whereimageis false. However, only pixels corresponding to a true value in themaskBitmap are affected. Anilmask is equivalent to a mask of the same size and shape asimageand containing all true values. The current transformation matrix gets applied to both theimageandmaskBitmaps.
β οΈ Again: if the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. π
void RasterRect(Canvas*, Coord x, Coord y, Raster*)β Renders theRasterwith its lower-left corner at the position(x, y). The current transformation matrix gets applied to theRaster.
β οΈ And once more for the people in the back: if the matrix specifies a transformation involving rotation or scaling, the resulting operation may proceed much more slowly than normal. Bestie, just know it. π
void Read(Canvas*, void*, Coord x1, y1, x2, y2)/void Write(Canvas*, const void*, Coord x1, y1, x2, y2)/void Copy(Canvas* src, Coord x1, y1, x2, y2, Canvas* dst, Coord x0, y0)βReadcopies a region of a canvas into memory.Writecopies data from memory to a region of a canvas.Copyreads a region of one canvas and writes the data into a region of another canvas (or within a canvas ifsrcanddstare the same). The point(x0, y0)is the lower-left corner of the destination region.
π¨ Note thatReadandWriteare superseded by operations that use Rasters. Not me being outdated, it's just the lore. π
π¦ SEE ALSO π¦
Bitmap(3I), Brush(3I), Canvas(3I), Color(3I), Font(3I), Pattern(3I), Raster(3I), Transformer(3I)
Go read those too, they're all part of the friend group. π«Ά
and that's the whole page, bestie!! this one's from InterViews, dated 15 June 1987 β yeah she's vintage, she's an icon, she's a legend and she is the moment. π β¨π
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms