GFILL_AREA(3NCARG)

πŸŽ€ GFILL_AREA πŸŽ€

okay bestie, welcome to gfill_area from the NCAR Graphics manual, section 3NCARG πŸ’– this is the output primitive that fills polygonal areas, and honestly? it's giving main character energy for your graphics. sit down, hydrate, let's go ✨


✨ NAME ✨

gfill_area β€” the output primitive for filling polygonal areas 🫢 like, it takes a polygon and it fills it. iconic behavior.


🌸 SYNOPSIS 🌸

#include <ncarg/gks.h>

void gfill_area(const Gpoint_list *point_list);

that's it. one function, one pointer, infinite vibes πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the function takes a Gpoint_list, and that struct is doing a lot of heavy lifting. here's the tea on its fields:

  • point_list.num_points β€” (Gint, Input) the number of points in the polygon you want filled. must be greater than two. like, that's non-negotiable bestie, a polygon needs at least three points, that's just geometry 😭
  • point_list.points β€” (Gpoint *, Input) the X and Y world coordinates of the polygon. your actual shape lives here.

πŸ’… USAGE πŸ’…

okay so here's how the fill area actually gets defined. the region you're filling is delimited by a sequence of straight line segments connecting the successive points, going like:

(point_list.points[0].x, point_list.points[0].y),
...
(point_list.points[point_list.num_points-1].x,
 point_list.points[point_list.num_points-1].y)

and here's a lil detail that matters: the last point in the polygon gets connected back to the first point with a straight line segment β€” but only in the case that it isn't already the same as the first point. so it auto-closes your shape for you. queen behavior πŸ‘‘


🌈 the "what even is inside" situation 🌈

now. when you've got a polygon whose edges cross each other, it becomes ambiguous as to what actually counts as the "inside" of the polygon. messy. chaotic. and GKS has a whole algorithm for this, so here it is:

for a given point, draw a ray starting at that point and going to infinity in any direction. then count the intersections:

  • if the number of intersections between the ray and the polygon is odd β†’ the point is within the polygon πŸ’–
  • otherwise β†’ the point is outside πŸ™ˆ
  • if the straight line passes through a polygon vertex tangentially, the intersection count is not affected (so don't stress about that edge case)

and if a point is within the polygon, it gets included in the area to be filled. simple as that, no cap.


🎨 interior styles 🎨

several interior styles can be selected β€” hollow, solid, and various hatch patterns 🌸 see the man pages for gset_fill_int_style and gset_fill_style_ind for all of that.

⚠️ note well, bestie: by default in GKS, the interior fill style is hollow, aka no fill. so if you call gfill_area and you don't get a filled interior like you expected, you will probably need to call gset_fill_int_style to set the fill style to something other than "hollow". this is the #1 gotcha and it gets everybody, fr fr πŸ˜­πŸ’€

πŸ”₯ ACCESS πŸ”₯

to use the GKS C-binding routines, you need to load the ncarg_gks and ncarg_c libraries. load them. don't skip them. that's the whole thing 🫢


⭐ SEE ALSO ⭐

Online:

  • gset_fill_int_style(3NCARG)
  • gset_fill_style_ind(3NCARG)
  • gset_colr_rep(3NCARG)
  • gset_fill_colr_ind(3NCARG)
  • ginq_fill_int_style(3NCARG)
  • ginq_fill_style_ind(3NCARG)
  • gks(3NCARG)
  • ncarg_gks_cbind(3NCARG)

Hardcopy:

  • User's Guide for NCAR GKS-0A Graphics
  • NCAR Graphics Fundamentals, UNIX Version

Copyright (C) 1987-2009 University Corporation for Atmospheric Research The use of this Software is governed by a License Agreement.


and that's the whole page, bestie πŸ’œ this one dropped on UNIX back in March 1993 as part of the NCAR GRAPHICS collection β€” yes she's an elder but she still eats. go fill some polygons. slay. periodt. πŸŽ€βœ¨