Gtk2::G...Drawable(3)

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

πŸ’– NAME πŸ’–

Gtk2::Gdk::Drawable β€” bestie, it's the wrapper for GdkDrawable. That's the whole name, no notes, we move. ✨

(You've landed on the Gtk2::G...Drawable(3) page from the User Contributed Perl Documentation, in case the URL got you confused 🫢)


🌸 HIERARCHY 🌸

Glib::Object
+----Gtk2::Gdk::Drawable

So Gtk2::Gdk::Drawable is a Glib::Object that branched off and became its own thing. Family lineage, iconic, no cap. πŸ’…


✨ METHODS ✨

πŸŽ€ The little getters that just vibe

unsigned = $drawable->XID

Hands you back an unsigned. That's it. That's the tea. β˜•

unsigned = $drawable->XWINDOW

Also an unsigned β€” the all-caps, XWINDOW-flavored one. πŸ‘‘

region = $drawable->get_clip_region

Returns a region. Clip clip, bestie. βœ‚οΈ

colormap or undef = $drawable->get_colormap

Returns a colormap, or undef. She may or may not show up β€” very "left me on read" of her. 😭

$drawable->set_colormap ($colormap)

  • $colormap (Gtk2::Gdk::Colormap) β€” the colormap you're handing over.

Setting the colormap. Periodt. πŸ’…

integer = $drawable->get_depth

Returns an integer. How deep is the depth? An integer's worth. πŸŒ€

display = $drawable->get_display

Returns the display.

Since: gtk+ 2.2 β€” so if you're on anything older, this is not your era, sorry bestie. πŸ™ˆ

screen = $drawable->get_screen

Returns the screen.

Since: gtk+ 2.2

(width, height) = $drawable->get_size

Two things back at once: width and height. List-context girlies, this one is FOR you. πŸŽ€

region = $drawable->get_visible_region

Returns the region that's visible. Eyes on it πŸ‘€

visual = $drawable->get_visual

Returns the visual. Aesthetic, honestly. πŸ¦‹

unsigned = $drawable->get_xid

Another unsigned β€” but this one goes through get_xid instead of the shouty XID spelling. Same energy, different font. πŸ’…


🎨 Drawing things, the fun part

$drawable->copy_to_image ($image, $src_x, $src_y, $dest_x, $dest_y, $width, $height)

  • $image (Gtk2::Gdk::Image or undef)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)

Returns an image. Copy it over, glow it up. ✨

Since: gtk+ 2.4

$drawable->draw_arc ($gc, $filled, $x, $y, $width, $height, $angle1, $angle2)

  • $gc (Gtk2::Gdk::GC)
  • $filled (boolean)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $angle1 (integer)
  • $angle2 (integer)

An arc with two angles, because one angle could never carry the whole arc. πŸ“

$drawable->draw_drawable ($gc, $src, $xsrc, $ysrc, $xdest, $ydest, $width, $height)

  • $gc (Gtk2::Gdk::GC)
  • $src (Gtk2::Gdk::Drawable)
  • $xsrc (integer)
  • $ysrc (integer)
  • $xdest (integer)
  • $ydest (integer)
  • $width (integer)
  • $height (integer)

Drawable drawing a drawable. Drawable-ception. πŸŒ€

$drawable->draw_gray_image ($gc, $x, $y, $width, $height, $dith, $buf, $rowstride)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $buf (scalar)
  • $rowstride (integer)

Gray image, but make it dither. 🌫️

$drawable->draw_image ($gc, $image, $xsrc, $ysrc, $xdest, $ydest, $width, $height)

  • $gc (Gtk2::Gdk::GC)
  • $image (Gtk2::Gdk::Image)
  • $xsrc (integer)
  • $ysrc (integer)
  • $xdest (integer)
  • $ydest (integer)
  • $width (integer)
  • $height (integer)

Drawing an actual Gtk2::Gdk::Image this time. πŸ–ΌοΈ

$drawable->draw_indexed_image ($gc, $x, $y, $width, $height, $dith, $buf, $rowstride, $cmap)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $buf (scalar)
  • $rowstride (integer)
  • $cmap (scalar)

Indexed image β€” she brought her own $cmap to the function, love that for her. 🎨

$drawable->draw_layout ($gc, $x, $y, $layout)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $layout (Pango::Layout)

A Pango::Layout gets drawn. Text era. πŸ“

$drawable->draw_layout_line ($gc, $x, $y, $line)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $line (Pango::LayoutLine)

Same but a single Pango::LayoutLine instead of the whole layout. ✍️

$drawable->draw_layout_line_with_colors ($gc, $x, $y, $line, $foreground, $background)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $line (Pango::LayoutLine)
  • $foreground (Gtk2::Gdk::Color or undef)
  • $background (Gtk2::Gdk::Color or undef)

Now WITH COLORS. Both $foreground and $background can be undef, so you can absolutely just do one. πŸŽ¨πŸ’…

$drawable->draw_layout_with_colors ($gc, $x, $y, $layout, $foreground, $background)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $layout (Pango::Layout)
  • $foreground (Gtk2::Gdk::Color or undef)
  • $background (Gtk2::Gdk::Color or undef)

The Pango::Layout version of the above, also with $foreground / $background that may be undef. 🌈

$drawable->draw_line ($gc, $x1_, $y1_, $x2_, $y2_)

  • $gc (Gtk2::Gdk::GC)
  • $x1_ (integer)
  • $y1_ (integer)
  • $x2_ (integer)
  • $y2_ (integer)

One line. And yes, the trailing underscores in $x1_, $y1_, $x2_, $y2_ are real and intentional β€” do not "fix" them, bestie, that's the API. 🚫

$drawable->draw_lines ($gc, ...)

  • $gc (Gtk2::Gdk::GC)
  • ... (list) integer x,y coordinates (possibly none)

For example:

$win->draw_lines ($gc, 0,0, 20,30, 40,20);

"Possibly none" coordinates is sending me β€” you can literally call it with zero points. πŸ’€

$drawable->draw_pixbuf ($gc, $pixbuf, $src_x, $src_y, $dest_x, $dest_y, $width, $height, $dither, $x_dither, $y_dither)

  • $gc (Gtk2::Gdk::GC or undef)
  • $pixbuf (Gtk2::Gdk::Pixbuf)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)
  • $dither (Gtk2::Gdk::RgbDither)
  • $x_dither (integer)
  • $y_dither (integer)

$gc here can be undef, which is very "come as you are" of it. 🫢

Since: gtk+ 2.2

$drawable->draw_point ($gc, $x, $y)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)

One singular point. Tiny. Precious. A little pixel baby. ⭐

$drawable->draw_points ($gc, ...)

  • $gc (Gtk2::Gdk::GC)
  • ... (list) integer x,y coordinates (possibly none)

For example three points:

$win->draw_points ($gc, 0,0, 10,10, 20,20);

$drawable->draw_polygon ($gc, $filled, $x1, $y1, ...)

  • $gc (Gtk2::Gdk::GC)
  • $filled (boolean)
  • $x1 (integer) the x coordinate of the first point
  • $y1 (integer) the y coordinate of the first point
  • ... (list) pairs of x and y coordinates

You give it the first point properly ($x1, $y1), then the rest of the points roll in as pairs. πŸ”·

$drawable->draw_rectangle ($gc, $filled, $x, $y, $width, $height)

  • $gc (Gtk2::Gdk::GC)
  • $filled (boolean)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)

A rectangle, and you decide whether it's $filled or just an outline. Serving both looks. ⬛

$drawable->draw_rgb_32_image ($gc, $x, $y, $width, $height, $dith, $buf, $rowstride)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $buf (scalar)
  • $rowstride (integer)

32-bit RGB image, dither and all. πŸ–₯️

$drawable->draw_rgb_32_image_dithalign ($gc, $x, $y, $width, $height, $dith, $rgb_buf, $rowstride, $xdith, $ydith)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $rgb_buf (scalar)
  • $rowstride (integer)
  • $xdith (integer)
  • $ydith (integer)

Same 32-bit RGB energy, except now the dither is aligned β€” that's what $xdith and $ydith are there for. Note the buffer is called $rgb_buf here, not $buf. Names matter, bestie. πŸ“Œ

$drawable->draw_rgb_image ($gc, $x, $y, $width, $height, $dith, $buf, $rowstride)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $buf (scalar)
  • $rowstride (integer)

RGB image, no 32 in the name this time. 🎯

$drawable->draw_rgb_image_dithalign ($gc, $x, $y, $width, $height, $dith, $rgb_buf, $rowstride, $xdith, $ydith)

  • $gc (Gtk2::Gdk::GC)
  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)
  • $dith (Gtk2::Gdk::RgbDither)
  • $rgb_buf (scalar)
  • $rowstride (integer)
  • $xdith (integer)
  • $ydith (integer)

And the RGB (not-32) version with dither alignment. $rgb_buf again, $xdith and $ydith again. πŸ’«

$drawable->draw_segments ($gc, ...)

  • $gc (Gtk2::Gdk::GC)
  • ... (list) quads of x1,y1,x2,y2 coordinates

For example, to draw two diagonal line segments:

$drawable->draw_segments($gc, 0,0,100,100, 200,200,300,300);

Quads. Four numbers per segment. Math ate. πŸ“

image = $drawable->get_image ($x, $y, $width, $height)

  • $x (integer)
  • $y (integer)
  • $width (integer)
  • $height (integer)

Returns an image. πŸ“Έ


πŸŽ‰ ENUMS AND FLAGS πŸŽ‰

enum Gtk2::Gdk::RgbDither

  • 'none' / GDK_RGB_DITHER_NONE
  • 'normal' / GDK_RGB_DITHER_NORMAL
  • 'max' / GDK_RGB_DITHER_MAX

Three dither moods: none, normal, and max. Pick your fighter. ✨


πŸ”— SEE ALSO πŸ”—

  • Gtk2
  • Glib::Object

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

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


Okay that's the whole page, bestie β€” you made it to the bottom, crown behavior. πŸ‘‘ This was perl v5.42.0, dated 2025-07-25, and you were reading Gtk2::G...Drawable(3) the whole time. Drink some water, go draw a rectangle, mwah πŸ’‹πŸ«Ά

πŸ“¦ where this page comes from