File: SDLx_text_zoom.pl

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (34 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#TODO: shadow, shadow_color, shadow_offset

use strict;
use warnings;
use lib '../lib';
use SDL;
use SDLx::App;
use SDLx::Text;

my $app = SDLx::App->new( eoq => 1, width => 400, height => 100 );

my $text = SDLx::Text->new;

my $size = 1;
my $direction = 1;
$app->add_move_handler( sub {
    $size += $direction;
    $text->size( $size );

    if ($direction == 1) {
        $direction = -1 if $size > 60;
    }
    else {
        $direction = 1 if $size < 2;
    }
});

$app->add_show_handler( sub {
    $app->draw_rect( [0, 0, $app->w, $app->h], 0x00ffff );
    $text->write_to( $app, 'Hello, World!' );
    $app->update;
});

$app->run;