wxPen(3erl)

πŸŽ€ wxPen β€” the Erlang module definition, bestie πŸŽ€

okay so this is the wxPen page from the Erlang module definition set β€” it's all about the pen object, aka the lil drawing tool that gives your lines their whole look. ngl it's a good one. let's get into it πŸ’…


✨ NAME ✨

wxPen β€” literally just "Functions for wxPen class." that's it, that's the name, short and iconic 🫢


🌸 DESCRIPTION 🌸

okay so picture this: a pen is a drawing tool for drawing outlines. that's its whole job. it draws lines, and it paints the outline of rectangles, ellipses, etc. it's got three personality traits: a colour, a width, and a style. main character energy fr ✨

πŸ’€ Note: on a monochrome display, wxWidgets shows all non-white pens as black. so like... your gorgeous pink pen? black. your mint green pen? also black. monochrome said "no." 😭

Do not initialize objects on the stack before the program commences β€” highkey important, because 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 whenever they're actually needed.

so an application may wish to dynamically create pens with different characteristics β€” and there's the consequent danger that a large number of duplicate pens will be created πŸ’€ yeah. pen hoarding. it's real. therefore an application may wish to get a pointer to a pen by using the global list of pens ?wxThePenList, and calling the member function wxPenList::FindOrCreatePen() (not implemented in wx). see wxPenList (not implemented in wx) for more info πŸ¦‹

okay and this part is so slay: 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 πŸ”₯ 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. it's giving "i'm not like other pens." iykyk πŸ‘‘

Predefined objects (include wx.hrl):

See: wxPenList (not implemented in wx), wxDC, wxDC:setPen/2

wxWidgets docs: wxPen


πŸ¦‹ DATA TYPES πŸ¦‹

  • wxPen() = wx:wx_object()

that's the whole type section, she's compact and she knows it πŸ’œ


πŸ’… EXPORTS πŸ’…

new() -> wxPen()

  • new() β€” default constructor. the pen will be uninitialised, and isOk/1 will return false. so like, she exists but she's not ready yet, y'know? 🌸

new(Colour) -> wxPen()

new(Pen) -> wxPen()

  • new(Pen) β€” copy constructor, uses overview_refcount.
    • Types:
      • Pen = wxPen()

new(Colour, Options :: [Option]) -> wxPen()

  • new(Colour, Options :: [Option]) β€” constructs a pen from a colour object, pen width and style ✨
    • Types:
      • Colour = wx:wx_colour()
      • Option = {width, integer()} | {style, wx:wx_enum()}
⚠️ Remark: different versions of Windows and different versions of other platforms support very different subsets of the styles above, so handle with care, bestie 😭 like genuinely, don't assume, ok?

See: setStyle/2, setColour/4, setWidth/2

destroy(This :: wxPen()) -> ok

  • destroy(This :: wxPen()) β€” destructor 🫢

See: reference-counted object destruction

⚠️ Remark: although all remaining pens are deleted when the application exits, the application should try to clean up all pens itself. this is because wxWidgets cannot know if a pointer to the pen object is stored in an application data structure, and there is a risk of double deletion πŸ’€ so like... clean up after yourself, pls and thank u.

getCap(This) -> wx:wx_enum()

  • getCap(This) β€” returns the pen cap style, which may be one of wxCAP_ROUND, wxCAP_PROJECTING and wxCAP_BUTT. the default is wxCAP_ROUND πŸ‘‘
    • Types:
      • This = wxPen()

See: setCap/2

getColour(This) -> wx:wx_colour4()

  • getColour(This) β€” returns a reference to the pen colour 🎨
    • Types:
      • This = wxPen()

See: setColour/4

getJoin(This) -> wx:wx_enum()

  • getJoin(This) β€” returns the pen join style, which may be one of wxJOIN_BEVEL, wxJOIN_ROUND and wxJOIN_MITER. the default is wxJOIN_ROUND ⭐
    • Types:
      • This = wxPen()

See: setJoin/2

getStyle(This) -> wx:wx_enum()

  • getStyle(This) β€” returns the pen style πŸ’«
    • Types:
      • This = wxPen()

See: new/2, setStyle/2

getWidth(This) -> integer()

  • getWidth(This) β€” returns the pen width πŸ“
    • Types:
      • This = wxPen()

See: setWidth/2

isOk(This) -> boolean()

  • isOk(This) β€” returns true if the pen is initialised πŸŽ€
    • Types:
      • This = wxPen()
πŸ’€ Notice: an uninitialized pen object can't be queried for any pen properties and all calls to the accessor methods on it will result in an assert failure. so do the vibe check first, bestie. ask isOk/1 before you go poking at her internals πŸ™ˆ

setCap(This, CapStyle) -> ok

  • setCap(This, CapStyle) β€” sets the pen cap style, which may be one of wxCAP_ROUND, wxCAP_PROJECTING and wxCAP_BUTT. the default is wxCAP_ROUND πŸ’…
    • Types:
      • This = wxPen()
      • CapStyle = wx:wx_enum()

See: getCap/1

setColour(This, Colour) -> ok

  • setColour(This, Colour) β€” the pen's colour is changed to the given colour 🌈
    • Types:
      • This = wxPen()
      • Colour = wx:wx_colour()

See: getColour/1

setColour(This, Red, Green, Blue) -> ok

  • setColour(This, Red, Green, Blue) β€” the RGB flavour, same pen, three numbers instead of a colour object πŸ“
    • Types:
      • This = wxPen()
      • Red = Green = Blue = integer()

setJoin(This, Join_style) -> ok

  • setJoin(This, Join_style) β€” sets the pen join style, which may be one of wxJOIN_BEVEL, wxJOIN_ROUND and wxJOIN_MITER. the default is wxJOIN_ROUND ✨
    • Types:
      • This = wxPen()
      • Join_style = wx:wx_enum()

See: getJoin/1

setStyle(This, Style) -> ok

  • setStyle(This, Style) β€” set the pen style, go off πŸ‘‘
    • Types:
      • This = wxPen()
      • Style = wx:wx_enum()

See: new/2

setWidth(This, Width) -> ok

  • setWidth(This, Width) β€” sets the pen width 🧚
    • Types:
      • This = wxPen()
      • Width = integer()

See: getWidth/1


🫢 the sign-off 🫢

and that's the whole page, bestie! brought to you by the wxWidgets team, from wx 2.2.2.1, and yeah this was wxPen(3erl) the entire time πŸ’– go draw something gorgeous with it. slay. periodt. πŸ¦‹

πŸ“¦ where this page comes from