Bio::G...dwidth(3pm)
π Bio::Graphics::Glyph::fixedwidth β the perl manual, but make it cute π
okay bestie, gather round, because this is Bio::Graphics::Glyph::fixedwidth(3pm) from the User Contributed Perl Documentation and it's literally the blueprint for every glyph that wants to be a fixed-size icon instead of a stretchy noodle. no cap. π
β¨ NAME β¨
Bio::Graphics::Glyph::fixedwidth β a base class for fixed width glyphs. it's giving "template", it's giving "your fave is a subclass of me". π
πΈ SYNOPSIS πΈ
here's the whole vibe in code, verbatim, don't touch a character:
use Bio::Graphics;
use Bio::Seq;
use Bio::SeqFeature::Generic;
my $bsg = 'Bio::SeqFeature::Generic';
my $seq = Bio::Seq->new(-length=>1000);
my $whole = $bsg->new(-display_name => 'Clone82',
-start => 1,
-end => $seq->length);
my $f1 = $bsg->new(-start => 100,
-end => 300,
-display_name => 'feature 1',
);
my $f2 = $bsg->new(-start => 500,
-end => 800,
-display_name => 'feature 2',
);
my $panel = Bio::Graphics::Panel->new(-length => $seq->length,
-width => 800,
-key_style => 'between',
-pad_left => 10,
-pad_right => 10,
);
$panel->add_track($whole,
-glyph => 'arrow',
-double => 1,
-tick => 2,
-label => 1,
);
$panel->add_track([$f1,$f2],
-glyph => 'fixedwidth',
-label => 1,
-fixed_height => 20,
-fixed_width => 20,
-key => 'fixed width');
binmode STDOUT;
print $panel->png;
slay. run that and you get a whole PNG, no thoughts head empty. π¦
π DESCRIPTION π
so this glyph is a base class for glyphs that wanna draw fixed width content β think icons, images, scatterplots β and it would be so wrong for that content to get stretched out to match the start and end points of its feature. like, imagine being stretched to fit someone else's timeline. no thank you. π
instead, the glyph draws:
- a simple box that spans the feature's
start:endregion, - two diagonal connecting lines,
- and then a fixed width rectangle sitting beneath the box.
and honestly? this glyph does nothing very interesting by itself. it's the canvas, not the painting. the whole point is that subclasses should override the draw_contents() method to draw something interesting. wanna see how? peek at "Subclassing" for a simple example. iykyk. π
β¨ OPTIONS β¨
the standard ones every Glyph gets (yes, all of them)
these are standard among all Glyphs. for the full explanation, go read Bio::Graphics::Glyph. π
-fgcolorβ the foreground color β default isblack-outlinecolorβ literally a synonym for-fgcolor-bgcolorβ the background color β default isturquoise-fillcolorβ literally a synonym for-bgcolor-linewidthβ line width β default is1-heightβ height of the glyph β default is10-fontβ the glyph font β default isgdSmallFont-connectorβ connector type β default is0(false)-connector_colorβ connector color β default isblack-labelβ whether to draw a label β default is0(false)-descriptionβ whether to draw a description β default is0(false)-hiliteβ highlight color β default isundef(no color)
the extra ones that only the fixedwidth glyph gets π
-fixed_widthβ width of the content β default is0-fixed_heightβ height of the content β default is Same as-height-fixed_gapβ the vertical gap between the box that shows the extent of the feature and the fixed-width content β default is8
β οΈ heads up bestie: if-fixed_gapis less than8, then the diagonal connecting lines are not drawn. that's just how it is. π
π§ EXAMPLE SUBCLASS π§
wanna draw something interesting inside that fixed rectangle? override the draw_contents method, periodt. it takes four arguments, which are the GD object plus the left, top, right and bottom coordinates of the fixed rectangle. like so:
package Bio::Graphics::Glyph::fixedexample;
use strict;
use base 'Bio::Graphics::Glyph::fixedwidth';
sub draw_contents {
my $self = shift;
my ($gd,$left,$top,$right,$bottom) = @_;
$self->unfilled_box($gd,$left,$top,$right,$bottom);
$gd->line($left,$top,$right,$bottom,$self->fgcolor);
$gd->line($left,$bottom,$right,$top,$self->fgcolor);
}
1;
this draws the outline of the fixed rectangle, and the rectangle contains two diagonal lines. not very interesting, but an example, nonetheless. it's giving "hello world" energy and honestly? valid. β¨
for a more interesting subclass, go look at the stackedplot glyph. that one ate. π₯
π BUGS AND LIMITATIONS π
this glyph should be used as the base for the image glyph, but isn't. this will be fixed. (we've all been there, bestie β the glow-up is pending.) π«Ά
π SEE ALSO π
go read all of these, they're the whole friend group:
Bio::Graphics::Panel, Bio::Graphics::Glyph, Bio::Graphics::Glyph::arrow, Bio::Graphics::Glyph::cds, Bio::Graphics::Glyph::crossbox, Bio::Graphics::Glyph::diamond, Bio::Graphics::Glyph::dna, Bio::Graphics::Glyph::dot, Bio::Graphics::Glyph::ellipse, Bio::Graphics::Glyph::extending_arrow, Bio::Graphics::Glyph::generic, Bio::Graphics::Glyph::graded_segments, Bio::Graphics::Glyph::heterogeneous_segments, Bio::Graphics::Glyph::line, Bio::Graphics::Glyph::pinsertion, Bio::Graphics::Glyph::primers, Bio::Graphics::Glyph::rndrect, Bio::Graphics::Glyph::segments, Bio::Graphics::Glyph::ruler_arrow, Bio::Graphics::Glyph::toomany, Bio::Graphics::Glyph::transcript, Bio::Graphics::Glyph::transcript2, Bio::Graphics::Glyph::translation, Bio::Graphics::Glyph::triangle, Bio::DB::GFF, Bio::SeqI, Bio::SeqFeatureI, Bio::Das, GD
π AUTHOR π
Lincoln Stein <lstein@cshl.org>
Copyright (c) 2007 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 whole page, bestie π this was perl v5.30.0, dated 2019-11-25, from the Bio::G...dwidth(3pm) manpage. mwah, go forth and subclass responsibly. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libbio-graphics-perl 2.40-6 Β· Perl
- debian trixie: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu jammy: libbio-graphics-perl 2.40-6 Β· Perl
- ubuntu noble: libbio-graphics-perl 2.40-6 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms