| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
3172
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
22
|
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
40
|
|
|
3
|
|
|
|
|
|
|
package Graphics::Raylib::Text; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Output text to window |
|
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
176
|
use Graphics::Raylib::XS qw(:all); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=pod |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Graphics::Raylib::Text - Output text to window |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use strict; |
|
22
|
|
|
|
|
|
|
use warnings; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Graphics::Raylib; |
|
25
|
|
|
|
|
|
|
use Graphics::Raylib::Color; |
|
26
|
|
|
|
|
|
|
use Graphics::Raylib::Text; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $i = 0; |
|
30
|
|
|
|
|
|
|
my $text = Graphics::Raylib::Text->new( |
|
31
|
|
|
|
|
|
|
color => Graphics::Raylib::Color::DARKGRAY, |
|
32
|
|
|
|
|
|
|
size => 20, |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
while (!$g->exiting) |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
|
|
|
|
|
|
Graphics::Raylib::draw { |
|
38
|
|
|
|
|
|
|
$g->clear(Graphics::Raylib::Color::BLACK); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$text->{text} = "Generation " . ($i++); |
|
41
|
|
|
|
|
|
|
$text->draw; |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS AND ARGUMENTS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item new( text => $text, color => $color, pos => [$x, $y], size => [$width, $height] ) |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Constructs a new Graphics::Raylib::Text instance. Position defaults to C<[0,0]> and size to C<10>. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
|
56
|
|
|
|
|
|
|
my $class = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $self = { |
|
59
|
|
|
|
|
|
|
pos => [0,0], |
|
60
|
|
|
|
|
|
|
size => 10, |
|
61
|
|
|
|
|
|
|
@_ |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
bless $self, $class; |
|
65
|
|
|
|
|
|
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item new( text => $text, color => $color, pos => [$x, $y], size => [$width, $height], font => $font, spacing => $spacing ) |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Constructs a new Graphics::Raylib::Text instance. Position defaults to C<[0,0]> and size to C<10>. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub draw { |
|
75
|
|
|
|
|
|
|
my $self = shift; |
|
76
|
|
|
|
|
|
|
return $self->{func}() if defined $self->{func}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
if (defined $self->{font}) { |
|
79
|
|
|
|
|
|
|
DrawTextEx( |
|
80
|
|
|
|
|
|
|
$self->{font}, $self->{text}, |
|
81
|
|
|
|
|
|
|
$self->{pos}, $self->{size}, |
|
82
|
|
|
|
|
|
|
$self->{spacing}, $self->{color} |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
} else { |
|
85
|
|
|
|
|
|
|
DrawText($self->{text}, @{$self->{pos}}, $self->{size}, $self->{color}); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 PREDEFINED OBJECTS |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 4 |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item FPS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
An already constructed C, that draws FPS to the top left corner. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
use constant FPS => Graphics::Raylib::Text->new(func => sub { DrawFPS(0, 0) }); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 GIT REPOSITORY |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L L |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Ahmad Fatoum C<< >>, L |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Copyright (C) 2017 Ahmad Fatoum |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
125
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |