wxGraphicsPath(3erl)

πŸ’– wxGraphicsPath β€” Erlang Module Definition πŸ’–

okay bestie, sit down, this one is a whole module definition page for wxGraphicsPath, and honestly? it's giving "drawing things with math" and I'm obsessed 🎨✨


🌸 NAME 🌸

wxGraphicsPath β€” literally just the functions for the wxGraphicsPath class 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so. a wxGraphicsPath is a native representation of a geometric path. and when they say native they mean it β€” the contents are specific and private to the respective renderer. like, it's renderer's business, not yours, iykyk πŸ’…

instances are reference counted, so you can assign them like a normal, well-adjusted term. slay.

the only way to get a valid instance is by using wxGraphicsContext:createPath/1 or wxGraphicsRenderer:createPath/1. that's it. that's the door. no shortcuts, no cap πŸ”₯

this class is derived (and can use functions) from: wxGraphicsObject

wxWidgets docs: wxGraphicsPath β€” go off, official docs πŸ‘‘


πŸŽ€ DATA TYPES πŸŽ€

  • wxGraphicsPath() = wx:wx_object()

⭐ EXPORTS ⭐

πŸ“ moveToPoint(This, P) -> ok

This = wxGraphicsPath()
P = {X :: float(), Y :: float()}

begins a new subpath at p ✨

πŸ“ moveToPoint(This, X, Y) -> ok

This = wxGraphicsPath()
X = Y = number()

begins a new subpath at (<em>x</em>,<em>y</em>). same energy, different arg shape πŸ’–


🧚 addArc(This, C, R, StartAngle, EndAngle, Clockwise) -> ok

This = wxGraphicsPath()
C = {X :: float(), Y :: float()}
R = StartAngle = EndAngle = number()
Clockwise = boolean()

🧚 addArc(This, X, Y, R, StartAngle, EndAngle, Clockwise) -> ok

This = wxGraphicsPath()
X = Y = R = StartAngle = EndAngle = number()
Clockwise = boolean()

adds an arc of a circle πŸ”΅

the circle is defined by the coordinates of its centre (<em>x</em>, <em>y</em>) or c and its radius r. the arc goes from the starting angle startAngle to endAngle either clockwise or counter-clockwise depending on the value of the clockwise argument.

the angles are measured in radians but, contrary to the usual mathematical convention, are always clockwise from the horizontal axis. yeah, it's built different, don't fight it 😌

  • if for clockwise arc endAngle is less than startAngle it will be progressively increased by 2*pi until it is greater than startAngle.
  • if for counter-clockwise arc endAngle is greater than startAngle it will be progressively decreased by 2*pi until it is less than startAngle.

if there is a current point set, an initial line segment will be added to the path to connect the current point to the beginning of the arc. cute. thoughtful. iconic 🫢


🌈 addArcToPoint(This, X1, Y1, X2, Y2, R) -> ok

This = wxGraphicsPath()
X1 = Y1 = X2 = Y2 = R = number()

adds an arc (of a circle with radius r) that is tangent to the line connecting current point and (<em>x1</em>, <em>y1</em>) and to the line connecting (<em>x1</em>, <em>y1</em>) and (<em>x2</em>, <em>y2</em>) πŸŒ€

if the current point and the starting point of the arc are different, a straight line connecting these points is also appended. if there is no current point before the call to addArcToPoint/6 this function will behave as if preceded by a call to MoveToPoint(0, 0). after this call the current point will be at the ending point of the arc ✨


πŸ’œ addCircle(This, X, Y, R) -> ok

This = wxGraphicsPath()
X = Y = R = number()

appends a circle around (<em>x</em>,<em>y</em>) with radius r as a new closed subpath.

after this call the current point will be at (<em>x</em>+r, <em>y*). noted. remembered. main character coordinates πŸ‘‘


πŸ’€ addCurveToPoint(This, C1, C2, E) -> ok

This = wxGraphicsPath()
C1 = C2 = E = {X :: float(), Y :: float()}

adds a cubic bezier curve from the current point, using two control points and an end point 🎒

if there is no current point before the call to addCurveToPoint/7 this function will behave as if preceded by a call to MoveToPoint(c1).

πŸ’€ addCurveToPoint(This, Cx1, Cy1, Cx2, Cy2, X, Y) -> ok

This = wxGraphicsPath()
Cx1 = Cy1 = Cx2 = Cy2 = X = Y = number()

adds a cubic bezier curve from the current point, using two control points and an end point. same deal, flatter args:

if there is no current point before the call to addCurveToPoint/7 this function will behave as if preceded by a call to MoveToPoint(cx1, cy1). periodt 🫑


🌸 addEllipse(This, X, Y, W, H) -> ok

This = wxGraphicsPath()
X = Y = W = H = number()

appends an ellipse fitting into the passed in rectangle as a new closed subpath πŸ₯š

after this call the current point will be at (<em>x</em>+w, <em>y*+h/2).


πŸ¦‹ addLineToPoint(This, P) -> ok

This = wxGraphicsPath()
P = {X :: float(), Y :: float()}

adds a straight line from the current point to p πŸ“

if current point is not yet set before the call to addLineToPoint/3 this function will behave as moveToPoint/3.

πŸ¦‹ addLineToPoint(This, X, Y) -> ok

This = wxGraphicsPath()
X = Y = number()

adds a straight line from the current point to (<em>x</em>,<em>y</em>).

if current point is not yet set before the call to addLineToPoint/3 this function will behave as moveToPoint/3. literally the same rule, no cap πŸ’…


πŸŽ€ addPath(This, Path) -> ok

This = Path = wxGraphicsPath()

adds another path onto the current path 🫢

after this call the current point will be at the added path's current point.

⚠️ for Direct2D the path being appended shouldn't contain a started non-empty subpath when this function is called. like, just don't. fr fr 😭

πŸ“ addQuadCurveToPoint(This, Cx, Cy, X, Y) -> ok

This = wxGraphicsPath()
Cx = Cy = X = Y = number()

adds a quadratic bezier curve from the current point, using a control point and an end point 🎒✨

if there is no current point before the call to addQuadCurveToPoint/5 this function will behave as if preceded by a call to MoveToPoint(cx, cy).


🌈 addRectangle(This, X, Y, W, H) -> ok

This = wxGraphicsPath()
X = Y = W = H = number()

appends a rectangle as a new closed subpath 🟦

after this call the current point will be at (<em>x</em>, <em>y</em>).


🧚 addRoundedRectangle(This, X, Y, W, H, Radius) -> ok

This = wxGraphicsPath()
X = Y = W = H = Radius = number()

appends a rounded rectangle as a new closed subpath 🟨✨

if radius equals 0 this function will behave as addRectangle/5, otherwise after this call the current point will be at (<em>x</em>+w, <em>y*+h/2). yes, the corner-case is literally a corner case, I'm hilarious πŸ’€


πŸ’œ closeSubpath(This) -> ok

This = wxGraphicsPath()

closes the current sub-path πŸ”’

after this call the current point will be at the joined endpoint of the sub-path.


πŸ‘‘ contains(This, C) -> boolean()

This = wxGraphicsPath()
C = {X :: float(), Y :: float()}

πŸ‘‘ contains(This, X, Y) -> boolean()

πŸ‘‘ contains(This, C, Y :: [Option]) -> boolean()

This = wxGraphicsPath()
C = {X :: float(), Y :: float()}
Option = {fillStyle, wx:wx_enum()}

return: true if the point is within the path ✨

πŸ‘‘ contains(This, X, Y, Options :: [Option]) -> boolean()

This = wxGraphicsPath()
X = Y = number()
Option = {fillStyle, wx:wx_enum()}

return: true if the point is within the path. vibe check: the point passes the vibe check when it's inside 🫢


⭐ getBox(This) -> {X :: float(), Y :: float(), W :: float(), H :: float()}

This = wxGraphicsPath()

gets the bounding box enclosing all points (possibly including control points) πŸ“¦


πŸ¦‹ getCurrentPoint(This) -> {X :: float(), Y :: float()}

This = wxGraphicsPath()

gets the last point of the current path, (0,0) if not yet set. default behavior, we love a sensible default πŸ’–


πŸ”₯ transform(This, Matrix) -> ok

This = wxGraphicsPath()
Matrix = wxGraphicsMatrix:wxGraphicsMatrix()

transforms each point of this path by the matrix πŸ’«

⚠️ for Direct2D the current path shouldn't contain a started non-empty subpath when this function is called. same warning, different function, still serious 😭

πŸŽ€ that's the whole page bestie πŸŽ€

and now the sign-off: this lil beauty came from the wxWidgets team πŸ’œπŸŒΊ β€” the docs are tagged wx 2.2.2.1 (both as the version and as the date on this page), so when you're citing it you can be like "per wx 2.2.2.1, obviously" πŸ’…βœ¨ mwah, go draw some paths πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from