Gtk2::Gdk::GC(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::Gdk::GC πŸ’–

okay bestie, welcome to Gtk2::Gdk::GC β€” it's a lil wrapper around GdkGC, aka your Graphics Context ✨ Think of it as the ✨aesthetic✨ settings bundle for drawing: what color, what line style, what fill, all that. It's from the User Contributed Perl Documentation corner of the internet and it's lowkey iconic. πŸŽ€


🌈 HIERARCHY 🌈

the family tree, and yes it's giving nepo baby:

Glib::Object
+----Gtk2::Gdk::GC

✨ METHODS ✨

πŸ¦‹ gc = Gtk2::Gdk::GC->new ($drawable, $values=undef)

  • $drawable (Gtk2::Gdk::Drawable)
  • $values (scalar)

Create and return a new GC. slay. πŸ’…

$drawable is used for the depth and the display (Gtk2::Gdk::Display) for the GC. The GC can then be used with any drawable of the same depth on that display. no cap, that's the rule.

$values is a hashref containing some of the following keys:

foreground          Gtk2::Gdk::Color
background          Gtk2::Gdk::Color
font                Gtk2::Gdk::Font
function            Gtk2::Gdk::Function enum
fill                Gtk2::Gdk::Fill enum
tile                Gtk2::Gdk::Pixmap
stipple             Gtk2::Gdk::Pixmap
clip_mask           Gtk2::Gdk::Pixmap
subwindow_mode      Gtk2::Gdk::SubwindowMode enum
ts_x_origin         integer
ts_y_origin         integer
clip_x_origin       integer
clip_y_origin       integer
graphics_exposures  boolean integer 1 or 0
line_width          integer
line_style          Gtk2::Gdk::LineStyle enum
cap_style           Gtk2::Gdk::CapStyle enum
join_style          Gtk2::Gdk::JoinStyle enum

Keys not given get default values β€” the defaults got your back 🫢. For the foreground and background colour objects only the pixel field is used; the red, green and blue are ignored. literally ignored. For example:

my $pixel = 0x123456;
my $color = Gtk2::Gdk::Color->new (0,0,0, $pixel);
my $gc = Gtk2::Gdk::GC->new_with_values
  ($win, { foreground => $color,
           line_style => 'on_off_dash' });

πŸ¦‹ gc = Gtk2::Gdk::GC->new_with_values ($drawable, $values=undef)

  • $drawable (Gtk2::Gdk::Drawable)
  • $values (scalar)

πŸ¦‹ $gc->set_background ($color)

  • $color (Gtk2::Gdk::Color)

πŸ¦‹ $gc->set_clip_mask ($mask)

  • $mask (scalar)

πŸ¦‹ $gc->set_clip_origin ($x, $y)

  • $x (integer)
  • $y (integer)

πŸ¦‹ $gc->set_clip_rectangle ($rectangle)

  • $rectangle (Gtk2::Gdk::Rectangle or undef)

πŸ¦‹ $gc->set_clip_region ($region)

  • $region (Gtk2::Gdk::Region or undef)

πŸ¦‹ colormap = $gc->get_colormap

πŸ¦‹ $gc->set_colormap ($colormap)

  • $colormap (Gtk2::Gdk::Colormap)

πŸ¦‹ $dst_gc->copy ($src_gc)

  • $src_gc (Gtk2::Gdk::GC)

πŸ¦‹ $gc->set_dashes ($dash_offset, ...)

  • $dash_offset (integer)
  • ... (list) of integers, the length of the dash segments

Sets the way dashed-lines are drawn. Lines will be drawn with alternating on and off segments of the lengths specified in list of dashes. The manner in which the on and off segments are drawn is determined by the line_style value of the GC. dashes? in THIS economy? yes. πŸ’…

πŸ¦‹ $gc->set_exposures ($exposures)

  • $exposures (boolean)

πŸ¦‹ $gc->set_fill ($fill)

  • $fill (Gtk2::Gdk::Fill)

πŸ¦‹ $gc->set_font ($font)

  • $font (Gtk2::Gdk::Font)

πŸ¦‹ $gc->set_foreground ($color)

  • $color (Gtk2::Gdk::Color)

πŸ¦‹ $gc->set_function ($function)

  • $function (Gtk2::Gdk::Function)

πŸ¦‹ $gc->set_line_attributes ($line_width, $line_style, $cap_style, $join_style)

  • $line_width (integer)
  • $line_style (Gtk2::Gdk::LineStyle)
  • $cap_style (Gtk2::Gdk::CapStyle)
  • $join_style (Gtk2::Gdk::JoinStyle)

πŸ¦‹ $gc->offset ($x_offset, $y_offset)

  • $x_offset (integer)
  • $y_offset (integer)

πŸ¦‹ $gc->set_rgb_background ($rgb)

  • $rgb (unsigned)

πŸ¦‹ $gc->set_rgb_bg_color ($color)

  • $color (Gtk2::Gdk::Color)

πŸ¦‹ $gc->set_rgb_fg_color ($color)

  • $color (Gtk2::Gdk::Color)

πŸ¦‹ $gc->set_rgb_foreground ($rgb)

  • $rgb (unsigned)

πŸ¦‹ $gc->rgb_gc_set_background ($rgb)

  • $rgb (unsigned)

πŸ¦‹ $gc->rgb_gc_set_foreground ($rgb)

  • $rgb (unsigned)

πŸ¦‹ screen = $gc->get_screen

Since: gtk+ 2.2 ⭐

πŸ¦‹ $gc->set_stipple ($stipple)

  • $stipple (Gtk2::Gdk::Pixmap)

πŸ¦‹ $gc->set_subwindow ($mode)

  • $mode (Gtk2::Gdk::SubwindowMode)

πŸ¦‹ $gc->set_tile ($tile)

  • $tile (Gtk2::Gdk::Pixmap)

πŸ¦‹ $gc->set_ts_origin ($x, $y)

  • $x (integer)
  • $y (integer)

πŸ¦‹ scalar = $gc->get_values

Return the attributes of $gc in the form of a hashref with keys and values as described with "new" above.

⚠️ In the foreground and background colour objects returned only the pixel fields are set; the red, green and blue fields are garbage. not "close enough", not "approximately", GARBAGE. πŸ’€ don't trust them bestie.

πŸ¦‹ $gc->set_values ($values)

  • $values (scalar)

Set some of the attributes of $gc. $values is a hashref of keys and values as described for "new" and "new_with_values" above. Fields not present in $values are left unchanged. so chill, it won't touch what you didn't mention. 🫢


🌸 ENUMS AND FLAGS 🌸

πŸŽ€ enum Gtk2::Gdk::CapStyle

  • 'not-last' / 'GDK_CAP_NOT_LAST'
  • 'butt' / 'GDK_CAP_BUTT'
  • 'round' / 'GDK_CAP_ROUND'
  • 'projecting' / 'GDK_CAP_PROJECTING'

πŸŽ€ enum Gtk2::Gdk::Fill

  • 'solid' / 'GDK_SOLID'
  • 'tiled' / 'GDK_TILED'
  • 'stippled' / 'GDK_STIPPLED'
  • 'opaque-stippled' / 'GDK_OPAQUE_STIPPLED'

πŸŽ€ enum Gtk2::Gdk::Function

  • 'copy' / 'GDK_COPY'
  • 'invert' / 'GDK_INVERT'
  • 'xor' / 'GDK_XOR'
  • 'clear' / 'GDK_CLEAR'
  • 'and' / 'GDK_AND'
  • 'and-reverse' / 'GDK_AND_REVERSE'
  • 'and-invert' / 'GDK_AND_INVERT'
  • 'noop' / 'GDK_NOOP'
  • 'or' / 'GDK_OR'
  • 'equiv' / 'GDK_EQUIV'
  • 'or-reverse' / 'GDK_OR_REVERSE'
  • 'copy-invert' / 'GDK_COPY_INVERT'
  • 'or-invert' / 'GDK_OR_INVERT'
  • 'nand' / 'GDK_NAND'
  • 'nor' / 'GDK_NOR'
  • 'set' / 'GDK_SET'

πŸŽ€ enum Gtk2::Gdk::JoinStyle

  • 'miter' / 'GDK_JOIN_MITER'
  • 'round' / 'GDK_JOIN_ROUND'
  • 'bevel' / 'GDK_JOIN_BEVEL'

πŸŽ€ enum Gtk2::Gdk::LineStyle

  • 'solid' / 'GDK_LINE_SOLID'
  • 'on-off-dash' / 'GDK_LINE_ON_OFF_DASH'
  • 'double-dash' / 'GDK_LINE_DOUBLE_DASH'

πŸŽ€ enum Gtk2::Gdk::SubwindowMode

  • 'clip-by-children' / 'GDK_CLIP_BY_CHILDREN'
  • 'include-inferiors' / 'GDK_INCLUDE_INFERIORS'

πŸ‘€ SEE ALSO πŸ‘€

Gtk2, Glib::Object β€” go read those too, they're the supporting cast and honestly they ate. πŸ”₯


Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


and that's the whole page bestie, no notes, we ate and left no crumbs πŸ“

sign-off: this was perl v5.42.0, dated 2025-07-25, and the manual page is Gtk2::Gdk::GC(3) β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from