wxBrush(3)
π wxBrush π
okay bestie, welcome to the wxBrush page β this is the Erlang module definition straight out of the wx docs, and it's literally the little drawing tool that fills stuff in. a brush is a drawing tool for filling in areas. periodt.
β¨ DESCRIPTION β¨
So what's a brush actually for? it paints the background of rectangles, ellipses, etc. that's the whole job. and it's got two things going on: a colour and a style. iconic combo, no notes. π¨
ngl there's a monochrome situation you need to know about: on a monochrome display, wxWidgets shows all brushes as white unless the colour is really black. so like. don't be confused when everything's ghost-white. π»
β οΈ big important warning, bestie: do not initialize objects on the stack before the program commences, since other required structures may not have been set up yet. instead, define global pointers to objects and create them in wxApp::OnInit (not implemented in wx) or when required. fr fr, do it the right way.
so an application may wish to create brushes with different characteristics dynamically β and there's the consequent danger that a large number of duplicate brushes will be created. the way that duplicates just pile up... π therefore an application may wish to get a pointer to a brush by using the global list of brushes ?wxTheBrushList, and calling the member function wxBrushList::FindOrCreateBrush() (not implemented in wx). reuse, don't hoard, we love to see it.
now for the secret sauce: this class uses reference counting and copy-on-write internally so that assignments between two instances of this class are very cheap. you can therefore use actual objects instead of pointers without efficiency problems. π and if an instance of this class is changed it will create its own data internally so that other instances, which previously shared the data using the reference counting, are not affected. copy-on-write is lowkey the main character here.
π Predefined objects (include wx.hrl):
?wxNullBrush?wxBLACK_BRUSH?wxBLUE_BRUSH?wxCYAN_BRUSH?wxGREEN_BRUSH?wxYELLOW_BRUSH?wxGREY_BRUSH?wxLIGHT_GREY_BRUSH?wxMEDIUM_GREY_BRUSH?wxRED_BRUSH?wxTRANSPARENT_BRUSH?wxWHITE_BRUSH
twelve of them, all pre-made, just sitting there waiting for you. β¨
π¦ See:
wxDCwxDC:setBrush/2
wxWidgets docs: wxBrush
π DATA TYPES π
wxBrush() :: wx:wx_object().
there it is. that's the whole type section. short king. π
π FUNCTIONS π
π destroy
destroy(This :: wxBrush()) -> ok.
Destroys the object. bye bestie, you served well. π«Ά
πΈ getColour
getColour(This) -> wx:wx_colour4() when This :: wxBrush().
Returns a reference to the brush colour. it's giving "tell me your colour." π¨
See: setColour/4
β getStipple
getStipple(This) -> wxBitmap:wxBitmap() when This :: wxBrush().
Gets a pointer to the stipple bitmap.
π heads up: if the brush does not have awxBRUSHSTYLE_STIPPLEstyle, this bitmap may be non-NULLbut uninitialised (i.e.wxBitmap:isOk/1returnsfalse). so like, it exists but it's not really there, iykyk.
See: setStipple/2
π
getStyle
getStyle(This) -> wx:wx_enum() when This :: wxBrush().
Returns the brush style, one of the ?wxBrushStyle values. v important enum moment.
See:
setStyle/2setColour/4setStipple/2
π£ isHatch
isHatch(This) -> boolean() when This :: wxBrush().
Returns true if the style of the brush is any of hatched fills. hatch = the little line-pattern fills, and this is your vibe check for them.
See: getStyle/1
β
isOk
isOk(This) -> boolean() when This :: wxBrush().
Returns true if the brush is initialised.
π¨ notice that an uninitialized brush object can't be queried for any brush properties and all calls to the accessor methods on it will result in an assert failure. like, don't poke the uninitialised brush. it WILL yell at you.
π new
new() -> wxBrush().
Default constructor. The brush will be uninitialised, and wxBrush:isOk/1 will return false. so yeah, it's a blank canvas β literally. π
new(Colour) -> wxBrush() when Colour :: wx:wx_colour();
(Brush) -> wxBrush()
when Brush :: wxBrush:wxBrush() | wxBitmap:wxBitmap().
Copy constructor, uses reference counting. cheap. effortless. iconic. β¨
new(Colour, [Option]) -> wxBrush()
when
Colour :: wx:wx_colour(),
Option :: {style, wx:wx_enum()}.
Constructs a brush from a colour object and style. two ingredients, one brush. slay.
πΊ setColour
setColour(This, Colour) -> ok
when This :: wxBrush(), Colour :: wx:wx_colour().
Sets the brush colour using red, green and blue values.
See: getColour/1
setColour(This, Red, Green, Blue) -> ok
when
This :: wxBrush(),
Red :: integer(),
Green :: integer(),
Blue :: integer().
yep, that's the four-arg version right there. π
π§ setStipple
setStipple(This, Bitmap) -> ok
when
This :: wxBrush(), Bitmap ::
wxBitmap:wxBitmap().
Sets the stipple bitmap.
π‘ remark: the style will be set towxBRUSHSTYLE_STIPPLE, unless the bitmap has a mask associated to it, in which case the style will be set towxBRUSHSTYLE_STIPPLE_MASK_OPAQUE. so the mask literally changes which style you end up with. no cap.
See: wxBitmap
π₯ setStyle
setStyle(This, Style) -> ok
when This :: wxBrush(), Style :: wx:wx_enum().
Sets the brush style.
See: getStyle/1
π«Ά and that's the whole page, bestie!! this one came to you from Ericsson AB, living in the wx 2.6 era, and its little home in the manual is wxBrush(3). go forth and fill in some rectangles. πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms