Ace::G...:Glyph(3pm)
β¨ Ace::Graphics::Glyph(3pm) β the perl docs, but make it make sense β¨
okay bestie, so this is a page from the User Contributed Perl Documentation collection, and it's about Ace::Graphics::Glyph, the literal base class for all the Ace::Graphics::Glyph objects out there. yes, the module and the package have the same name, that's just how it is, we don't question it π
π¦ NAME π¦
Ace::Graphics::Glyph β the base class for Ace::Graphics::Glyph objects. it's giving "mother of all glyphs", and honestly? iconic. π
πΈ SYNOPSIS πΈ
Go look at Ace::Graphics::Panel for this one, bestie. no cap, that's where the action lives.
π DESCRIPTION π
So Ace::Graphics::Glyph is the base class for every single glyph object. And what even is a glyph, you ask? Each one is a lil wrapper around an Ace::Sequence::Feature object, it knows how to render itself onto an Ace::Graphics::Panel, and it's got a whole wardrobe of configuration variables. main character energy fr fr.
Now β important reality check β if you're an end developer, you will not ordinarily work directly with Ace::Graphics::Glyph. That's not the vibe. But you might want to subclass it if you're building customized displays, and in that case, welcome, this is your page. π«Ά
π METHODS π
This whole section is the class and object methods for Ace::Graphics::Glyph. Buckle up, there's a lot, and every single one matters. β¨
π CONSTRUCTORS π
Ace::Graphics::Glyph objects get constructed automatically by an Ace::Graphics::GlyphFactory. They are not usually created by end-developer code. Let the factory do its thing, she's got it. π
$glyph = Ace::Graphics::Glyph->new(-feature=>$feature,-factory=>$factory)β give this a sequence feature and it creates anAce::Graphics::Glyphobject to display that feature. The-featureargument points at theAce::Sequence::Featureobject you want displayed. And-factoryindicates anAce::Graphics::GlyphFactoryobject, which is where the glyph fetches all of its run-time configuration info from. It's a whole support system.
A standard set of options are recognized here. Go see OPTIONS, we cover them all below, promise. π€
π OBJECT METHODS π
Once a glyph exists, it responds to a lowkey huge number of methods. This section groups them into related categories so you don't lose your mind. You're welcome. π§
π« Retrieving glyph context:
$factory = $glyph->factoryβ get theAce::Graphics::GlyphFactoryassociated with this object. This cannot be changed once it is set. Once it's locked in, it's locked in, periodt.$feature = $glyph->featureβ get the sequence feature associated with this object. Also cannot be changed once it is set. No takebacks. π
π« Retrieving glyph options:
$fgcolor = $glyph->fgcolor$bgcolor = $glyph->bgcolor$fontcolor = $glyph->fontcolor$fillcolor = $glyph->fillcolor
These four return the configured foreground, background, font and fill colors for the glyph, delivered in the form of a GD::Image color index. aesthetic.
$width = $glyph->widthβ returns the maximum width allowed for the glyph. Heads up though: most glyphs will be smaller than this. It's a ceiling, not a promise.$font = $glyph->fontβ returns the font for the glyph.$option = $glyph->option($option)β returns the value of the option you named.$index = $glyph->color($color)β hand it a symbolic color name or a#RRGGBB-form color name, and it hands back its GD index. π¨
π« Retrieving information about the sequence:
$start = $glyph->start$end = $glyph->end
These return the start and end of the glyph, measured in base pair units.
$offset = $glyph->offsetβ returns the offset of the segment, which is the base pair sitting at the far left of the image. the origin point, the moment it all begins π¦$length = $glyph->lengthβ returns the length of the sequence segment.
π« Retrieving formatting information:
$top = $glyph->top$left = $glyph->left$bottom = $glyph->bottom$right = $glyph->right
These return the top, left, bottom and right of the glyph in pixel coordinates.
$height = $glyph->heightβ returns the height of the glyph. Fair warning: this may be somewhat larger or smaller than the height suggested by theGlyphFactory, depending on the type of glyph. It does what it wants. π$scale = $glyph->scaleβ get the scale for the glyph in pixels/bp.$height = $glyph->labelheightβ return the height of the label, if there is any. (if!)$label = $glyph->labelβ return a human-readable label for the glyph. for the girlies who need to read it π
π« These methods are called by Ace::Graphics::Track during the layout process:
$glyph->move($dx,$dy)β move the glyph in pixel coordinates by the indicated delta-x and delta-y values. scoot πΌ($x1,$y1,$x2,$y2) = $glyph->boxβ return the current position of the glyph.
π« These methods are intended to be overridden in subclasses:
$glyph->calculate_heightβ calculate the height of the glyph.$glyph->calculate_leftβ calculate the left side of the glyph.$glyph->calculate_rightβ calculate the right side of the glyph.$glyph->draw($gd,$left,$top)β optionally offset the glyph by the indicated amount and draw it onto theGD::Imageobject.$glyph->draw_label($gd,$left,$top)β draw the label for the glyph onto the providedGD::Imageobject, optionally offsetting by the amounts indicated in$leftand$right.
π« These methods are useful utility routines:
$pixels = $glyph->map_pt($bases);β map the indicated base position, given in base pair units, into pixels, using the current scale and glyph position.$glyph->filled_box($gd,$x1,$y1,$x2,$y2)β draw a filled rectangle onto theGD::Imageobject given by$gd, using the provided rectangle coordinates, with the appropriate foreground and fill colors and pen width. πͺ$glyph->filled_oval($gd,$x1,$y1,$x2,$y2)β same as above, except it draws an oval inscribed on the rectangle. cute lil oval. π₯
π OPTIONS π
These options are standard among all Glyphs. (For more options, check the individual glyph pages β everybody's got their own extras.)
-fgcolorβ Foreground color. Default:black.-outlinecolorβ Synonym for-fgcolor. Default:black.-bgcolorβ Background color. Default:white.-fillcolorβ Interior color of filled images. Default:turquoise.-linewidthβ Width of lines drawn by glyph. Default:1.-heightβ Height of glyph. Default:10.-fontβ Glyph font. Default:gdSmallFont.-labelβ Whether to draw a label. Default:false.
And here's the spicy bit π₯: you may pass an anonymous subroutine to -label, in which case that subroutine will be invoked with the feature as its single argument. The subroutine must return a string to render as the label. no returning undef, bestie, it will not slay.
π§ SUBCLASSING Ace::Graphics::Glyph π§
By convention, subclasses are all lower-case. Every subclass starts with a preamble exactly like this one:
package Ace::Graphics::Glyph::crossbox;
use strict;
use vars '@ISA';
@ISA = 'Ace::Graphics::Glyph';
Then you override the methods you actually need to. Typically, just the draw() method needs overriding. But if you need additional room in the glyph, you may override calculate_height(), calculate_left() and calculate_right().
β οΈ Do NOT directly overrideheight(),left()andright(). Their whole purpose is to cache the values returned by their calculating cousins so you avoid time-consuming recalculation. Override the calculators, not the cache. trust. π
A simple draw() method looks like this:
sub draw {
my $self = shift;
$self->SUPER::draw(@_);
my $gd = shift;
# and draw a cross through the box
my ($x1,$y1,$x2,$y2) = $self->calculate_boundaries(@_);
my $fg = $self->fgcolor;
$gd->line($x1,$y1,$x2,$y2,$fg);
$gd->line($x1,$y2,$x2,$y1,$fg);
}
So what's happening here, bestie? This subclass draws a simple box with two lines criss-crossed through it. Step one: we call our inherited draw() method to generate the filled box and the label. Step two: we call calculate_boundaries() to get back the coordinates of the glyph, disregarding any extra space taken by labels. Step three: we call fgcolor() to return the desired foreground color. Step four, the finale: we call $gd->line() twice to generate the criss-cross. ate. π
Want more complex draw() methods to study? Go look at Ace::Graphics::Glyph::transcript and Ace::Graphics::Glyph::segments.
π BUGS π
Please report them. that's it. that's the whole section. she's concise. π
π SEE ALSO π
Go read these, bestie, they're the whole friend group:
Ace::SequenceAce::Sequence::FeatureAce::Graphics::PanelAce::Graphics::TrackAce::Graphics::Glyph::anchored_arrowAce::Graphics::Glyph::arrowAce::Graphics::Glyph::boxAce::Graphics::Glyph::primersAce::Graphics::Glyph::segmentsAce::Graphics::Glyph::toomanyAce::Graphics::Glyph::transcript
π AUTHOR π
Lincoln Stein <lstein@cshl.org>.
Copyright (c) 2001 Cold Spring Harbor Laboratory
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty.
and that's the page, babes π«Ά this was perl v5.42.3, dated 2026-08-19, and it's the Ace::Graphics::Glyph(3pm) page from the User Contributed Perl Documentation. mwah. πβ¨π
π¦ where this page comes from
- ubuntu stonking: libace-perl 1.92-14build1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms