-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComeGetSome.pl
87 lines (69 loc) · 1.82 KB
/
ComeGetSome.pl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use Data::Dumper;
use IO::Socket::INET;
use GD;
use strict;
our $main_offsetx = 150;
our $main_offsety = 0;
$| = 1;
my $img_w = 80;
my $img_h = 80;
my $host = 'barflood.sha2017.org';
#my $host = 'localhost';
my $port = 2342;
#my $port = 7777;
my $socket = new IO::Socket::INET (
PeerHost => $host,
PeerPort => $port,
Proto => 'tcp',
Type => SOCK_STREAM,
);
GD::Image->trueColor(1);
#my $image = new GD::Image('resources/troll-face-meme.png') or die 'no pic dude !';
my $image = newFromPng GD::Image('resources/troll-face-meme.png',1) or die 'no pic dude !';
my $w = $image->width;
my $h = $image->height;
my $imageResized = new GD::Image($img_w,$img_h);
$imageResized->copyResized($image,0,0,0,0,$img_w,$img_h,$w,$h);
printImage($imageResized);
#print $imageResized->png;
#exit 0;
sub printImage {
my $w = $image->width;
my $h = $image->height;
$image = @_[0];
while (1) {
for my $x(0..$w) {
for my $y(0..$h) {
#print "$x $y $w $h\n";
my $i = $image->getPixel($x,$y);
my ($r,$g,$b) = $image->rgb($i);
pixel($x,$y,$r,$g,$b);
}
}
}
}
sub pixel {
my ($x,$y,$r,$g,$b,$a,$offsetx,$offsety) = @_;
if ( !defined $a ) { $a=255 };
if ( !defined $offsetx ) { $offsetx=$main_offsetx };
if ( !defined $offsety ) { $offsety=$main_offsety };
$x = $x+$offsetx;
$y = $y+$offsety;
my $cmd;
if ($a == 255) {
$cmd = sprintf("PX %d %d %02x%02x%02x\n",$x,$y,$r,$g,$b);
$socket->send($cmd);
} else {
$cmd = sprintf("PX %d %d %02x%02x%02x%02x\n",$x,$y,$r,$g,$b,$a);
$socket->send($cmd);
}
}
sub rect {
# implement me !
}
sub worm {
# implement me !
}
sub line {
my ($x,$y,$r,$g,$b,$a,$offsetx,$offsety) = @_;
}