Gnome2:...s::main(3)

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

πŸ’– NAME πŸ’–

Gnome2::Canvas::main β€” a structured graphics canvas, bestie. It's section 3 of the User Contributed Perl Documentation, and it's so much.

Okay so real talk: this is the canvas you draw stuff onto. Items, coordinates, zooming, scrolling, the whole vibe. Let's get into it πŸ’…


✨ METHODS ✨

πŸŽ€ widget = Gnome2::Canvas->new

Makes you a brand new empty canvas, and it's in non-antialiased mode. Crunchy pixels, no smoothing, we love her.

πŸ¦‹ widget = Gnome2::Canvas->new_aa

Same deal, brand new empty canvas, but this one is in antialiased mode. Smooth edges, soft life. ✨

πŸ’œ boolean = $canvas->aa

Returns true if $canvas was created in anti-aliased mode. Just a little vibe check on your canvas.

🌸 ($bx1, $by1, $bx2, $by2) = Gnome2::Canvas->get_butt_points ($x1, $y1, $x2, $y2, $width, $project)

  • $x1 (double)
  • $y1 (double)
  • $x2 (double)
  • $y2 (double)
  • $width (double)
  • $project (integer)

πŸ’… (wx, wy) = $canvas->c2w ($cx, $cy)

  • $cx (integer)
  • $cy (integer)

🫢 boolean = $canvas->get_center_scroll_region

🫢 $canvas->set_center_scroll_region ($center_scroll_region)

  • $center_scroll_region (boolean)

πŸ“ list = $canvas->get_color ($spec)

  • $spec (string)

Returns an integer indicating the success of the color allocation and a GdkColor. Two things, one call, icon behaviour fr.

πŸ”₯ unsigned = $canvas->get_color_pixel ($rgba)

  • $rgba (integer)

🌈 rgbdither = $canvas->get_dither

🌈 $canvas->set_dither ($dither)

  • $dither (Gtk2::Gdk::RgbDither)

πŸ‘‘ item = $canvas->get_item_at ($x, $y)

  • $x (double)
  • $y (double)

πŸ’€ ($mx1, $my1, $mx2, $my2) = Gnome2::Canvas->get_miter_points ($x1, $y1, $x2, $y2, $x3, $y3, $width)

  • $x1 (double)
  • $y1 (double)
  • $x2 (double)
  • $y2 (double)
  • $x3 (double)
  • $y3 (double)
  • $width (double)

🧚 double = $canvas->get_pixels_per_unit

Fetches $canvas' scale factor. That's it, that's the whole method.

🧚 $canvas->set_pixels_per_unit ($n)

  • $n (double)

Sets the zooming factor of $canvas by telling it how many screen pixels correspond to one canvas unit. Zoom zoom, main character energy.

⭐ double = Gnome2::Canvas->polygon_to_point ($poly_ref, $x, $y)

  • $poly_ref (arrayref) β€” coordinate pairs that make up the polygon
  • $x (double)
  • $y (double)

Returns the distance from the point $x,$y to the polygon described by the vertices in $poly_ref, or zero if the point is inside the polygon.

πŸ’– $canvas->request_redraw ($x1, $y1, $x2, $y2)

  • $x1 (integer)
  • $y1 (integer)
  • $x2 (integer)
  • $y2 (integer)

πŸŽ€ group = $canvas->root

πŸŽ€ (cx, cy) = $canvas->get_scroll_offsets

πŸŽ€ (x1, y1, x2, y2) = $canvas->get_scroll_region

πŸŽ€ $canvas->set_scroll_region ($x1, $y1, $x2, $y2)

  • $x1 (double)
  • $y1 (double)
  • $x2 (double)
  • $y2 (double)

πŸ¦‹ $canvas->scroll_to ($cx, $cy)

  • $cx (integer)
  • $cy (integer)

πŸ¦‹ $canvas->set_stipple_origin ($gc)

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

πŸ¦‹ $canvas->update_now

πŸ’œ (cx, cy) = $canvas->w2c ($wx, $wy)

  • $wx (double)
  • $wy (double)

🌟 $affine = $canvas->w2c_affine

Fetches the affine transform that converts from world coordinates to canvas pixel coordinates. So useful, no cap.

😭 Note: this method was completely broken for all $Gnome2::Canvas::VERSION < 1.002. Not "a little weird", not "slightly off" β€” completely broken. If you're on an old version, that's the tea. πŸ’€

🌟 (cx, cy) = $canvas->w2c_d ($wx, $wy)

  • $wx (double)
  • $wy (double)

🌈 (worldx, worldy) = $canvas->window_to_world ($winx, $winy)

  • $winx (double)
  • $winy (double)

🌈 (winx, winy) = $canvas->world_to_window ($worldx, $worldy)

  • $worldx (double)
  • $worldy (double)

🌸 ENUMS AND FLAGS 🌸

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

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

🫢 SEE ALSO 🫢

  • Gnome2::Canvas

Copyright (C) 2003-2004 by the Gtk2-Perl Team.

This software is licensed under the LGPL; see Gnome2::Canvas for a full notice.


And that's the whole page, bestie πŸ’– This was perl v5.42.0, dated 2025-07-25, page Gnome2:...s::main(3). Go forth and draw something iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from