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 callgfill_areaand you don't get a filled interior like you expected, you will probably need to callgset_fill_int_styleto 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 π
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. πβ¨
π¦ where this page comes from
- debian bookworm: libncarg-dev 6.6.2.dfsg.1-1
- debian trixie: libncarg-dev 6.6.2.dfsg.1-10+b2
- ubuntu jammy: libncarg-dev 6.6.2-10build2
- ubuntu questing: libncarg-dev 6.6.2.dfsg.1-10build2
- ubuntu resolute: libncarg-dev 6.6.2.dfsg.1-12
- ubuntu stonking: libncarg-dev 6.6.2.dfsg.1-12build2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms