Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Bitmap/Raku/bitmap.raku
Normal file
29
Task/Bitmap/Raku/bitmap.raku
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class Pixel { has UInt ($.R, $.G, $.B) }
|
||||
class Bitmap {
|
||||
has UInt ($.width, $.height);
|
||||
has Pixel @!data;
|
||||
|
||||
method fill(Pixel $p) {
|
||||
@!data = $p.clone xx ($!width*$!height)
|
||||
}
|
||||
method pixel(
|
||||
$i where ^$!width,
|
||||
$j where ^$!height
|
||||
--> Pixel
|
||||
) is rw { @!data[$i + $j * $!width] }
|
||||
|
||||
method set-pixel ($i, $j, Pixel $p) {
|
||||
self.pixel($i, $j) = $p.clone;
|
||||
}
|
||||
method get-pixel ($i, $j) returns Pixel {
|
||||
self.pixel($i, $j);
|
||||
}
|
||||
}
|
||||
|
||||
my Bitmap $b = Bitmap.new( width => 10, height => 10);
|
||||
|
||||
$b.fill( Pixel.new( R => 0, G => 0, B => 200) );
|
||||
|
||||
$b.set-pixel( 7, 5, Pixel.new( R => 100, G => 200, B => 0) );
|
||||
|
||||
say $b.perl;
|
||||
Loading…
Add table
Add a link
Reference in a new issue