polygons(3U)

✨ polygons β€” the structured graphics glow-up for rects & polys ✨

okay so bestie, welcome to polygons(3U) from the InterViews Reference Manual πŸ’– this is the page about drawing rectangles and polygons in Unidraw, and honestly? it's giving foundational. let's get into it 🫢


🌸 NAME 🌸

Rect, S_Rect, F_Rect, SF_Rect, Polygon, S_Polygon, F_Polygon, SF_Polygon β€” structured graphics classes for rectangles and polygons πŸŽ€


✨ SYNOPSIS ✨

#include <Unidraw/Graphic/polygons.h>

like that's it, that's the include, slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so Rect and Polygon are the abstract base classes for rectangle and polygon structured graphics respectively. no cap. and the way that Rect is derived from Graphic, while Polygon is derived from Vertices? iconic lineage fr fr πŸ‘‘

the predefined subclasses are where it gets juicy:

  • S_Rect, F_Rect, and SF_Rect draw stroked, filled, and stroked-filled rectangles respectively 🌈
  • S_Polygon, F_Polygon, and SF_Polygon draw stroked, filled, and stroked-filled polygons respectively ✨

and the storage tea β˜• β€” the stroked subclasses store a PSBrush, the filled subclasses store a PSPattern, and the stroked-filled subclasses store one of each. main character energy honestly πŸ’œ


πŸ‘‘ RECT PUBLIC OPERATIONS πŸ‘‘

  • void GetOriginal(Coord& x0, Coord& y0, Coord& x1, Coord& y1) β€” returns the rectangle's geometry exactly as it was specified in the constructor. (x0, y0) defines one corner of the rectangle, and (x1, y1) defines the opposing corner. so like, the og vibes, preserved πŸŽ€

πŸ’… RECT PROTECTED OPERATIONS πŸ’…

  • Rectangle(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil) β€” okay so this constructor is protected on purpose, to disallow instantiation of the abstract base class (no making a bare Rect happen, bestie, it's not that kind of party πŸ™ˆ). a rectangle's geometry is defined by two points, corresponding to opposing corners of the rectangle. it also takes an optional graphic from which to obtain an initial set of graphics state ✨
  • void s_getExtent(float&, float&, float&, float&, float&, Graphic*)
  • void f_getExtent(float&, float&, float&, float&, float&, Graphic*)
  • boolean s_contains(PointObj&, Graphic*)
  • boolean f_contains(PointObj&, Graphic*)
  • boolean s_intersects(BoxObj&, Graphic*)
  • boolean f_intersects(BoxObj&, Graphic*)

these are the helper functions πŸ’– they return extent and hit detection information based on the bounding box that the rectangle defines. s_getExtent, s_contains, and s_intersects return info that accounts for the width of a brush, as would be necessary if the rectangle is stroked β€” while f_getExtent, f_contains, and f_intersects assumes that the rectangle is filled. subclasses can use these operations to help implement their own getExtent, contains, and intersects operations. teamwork makes the dream work fr 🫢


🌈 RECT SUBCLASS PUBLIC OPERATIONS 🌈

  • S_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)
  • F_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)
  • SF_Rect(Coord x0, Coord y0, Coord x1, Coord y1, Graphic* = nil)

constructors for the various predefined Rect subclasses πŸŽ€ pick your fighter: stroked, filled, or both πŸ’…


🧚 POLYGON PROTECTED OPERATIONS 🧚

  • Polygon(Coord* x, Coord* y, int count, Graphic* = nil) β€” Polygon's constructor is protected to prevent instantiation of the abstract base class. and listen, the parameters are passed directly to the Vertices constructor. no extra steps, no middleman, just straight through πŸ”₯

⭐ POLYGON SUBCLASS PUBLIC OPERATIONS ⭐

  • S_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)
  • F_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)
  • SF_Polygon(Coord* x, Coord* y, int count, Graphic* = nil)

constructors for the various predefined Rect subclasses. (yes bestie, the original really does say Rect here, we are reporting the lore exactly as written, no editing the canon πŸ’€)


πŸ’œ SEE ALSO πŸ’œ

Graphic(3U), Vertices(3U), geomobjs(3U), pspaint(3U) β€” go read these next, they're the supporting cast and they ate πŸ“


and that's the whole page, babe! this one came from the Unidraw era, dated 2 February 1991 β€” vintage but still serving ✨ mwah, go draw some rectangles πŸ’–πŸŽ€πŸ¦‹