Adding inital support to printing pokemon icons.

This commit is contained in:
Sergiotarxz 2024-03-06 13:22:16 +01:00
parent 3ace9d4438
commit 129e20ffd6
1 changed files with 32 additions and 11 deletions

View File

@ -322,7 +322,9 @@ sub activate_about {
$about->present;
}
my $root = path(__FILE__)->parent->parent->parent->parent;
sub activate_view_pc {
my $self = shift;
my $gtk_window = Gtk4::Window->new;
my $canvas = Gtk4::DrawingArea->new;
$gtk_window->set_default_size(312,340);
@ -332,20 +334,39 @@ sub activate_view_pc {
my $cairo = shift;
my $width = shift;
my $height = shift;
my $root = path(__FILE__)->parent->parent->parent->parent;
$cairo->rectangle(0, 0, $width, $height);
my $surface = Cairo::ImageSurface->create_from_png($root->child('resources/forest.png'));
$cairo->set_source_rgb(0, 0, 0);
$cairo->paint;
$cairo->scale(2, 2);
$cairo->set_source_surface($surface, 0, 0);
$cairo->get_source()->set_filter('nearest');
$cairo->paint;
$self->draw_box($cairo);
$self->draw_pokemon($cairo);
});
$gtk_window->set_child($canvas);
$gtk_window->present;
}
sub draw_pokemon {
my $self = shift;
my $cairo = shift;
my $pokemon = $root->child('pokeemerald/graphics/pokemon/bulbasaur/icon.png');
my $surface = Cairo::ImageSurface->create_from_png($pokemon);
my $output_image = Cairo::ImageSurface->create('argb32', 32, 32);
my $image_context = Cairo::Context->create($output_image);
$image_context->set_source_surface($surface, 0, 0);
$image_context->get_source()->set_filter('nearest');
$image_context->paint;
$cairo->set_source_surface($output_image, 0, 20);
$cairo->get_source()->set_filter('nearest');
$cairo->paint;
}
sub draw_box {
my $self = shift;
my $cairo = shift;
my $surface = Cairo::ImageSurface->create_from_png($root->child('resources/forest.png'));
$cairo->scale(2, 2);
$cairo->set_source_surface($surface, 0, 0);
$cairo->get_source()->set_filter('nearest');
$cairo->paint;
}
1;