September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
27
Task/Pinstripe-Display/Go/pinstripe-display.go
Normal file
27
Task/Pinstripe-Display/Go/pinstripe-display.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import "github.com/fogleman/gg"
|
||||
|
||||
var palette = [2]string{
|
||||
"FFFFFF", // white
|
||||
"000000", // black
|
||||
}
|
||||
|
||||
func pinstripe(dc *gg.Context) {
|
||||
w := dc.Width()
|
||||
h := dc.Height() / 4
|
||||
for b := 1; b <= 4; b++ {
|
||||
for x, ci := 0, 0; x < w; x, ci = x+b, ci+1 {
|
||||
dc.SetHexColor(palette[ci%2])
|
||||
y := h * (b - 1)
|
||||
dc.DrawRectangle(float64(x), float64(y), float64(b), float64(h))
|
||||
dc.Fill()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
dc := gg.NewContext(900, 600)
|
||||
pinstripe(dc)
|
||||
dc.SavePNG("w_pinstripe.png")
|
||||
}
|
||||
|
|
@ -1,22 +1,20 @@
|
|||
my $HOR = 1280;
|
||||
my $VERT = 720;
|
||||
|
||||
my ($x,$y) = 1280,720;
|
||||
my @colors = 0, 1;
|
||||
|
||||
spurt "pinstripes.pgm", qq:to/EOH/;
|
||||
spurt "pinstripes.pgm", qq:to/EOH/ orelse .die;
|
||||
P5
|
||||
# pinstripes.pgm
|
||||
$HOR $VERT
|
||||
$x $y
|
||||
1
|
||||
EOH
|
||||
|
||||
my $PGM = open "pinstripes.pgm", :a, :bin or die "Can't append to pinstripes.pgm: $!";
|
||||
my $img = open "pinstripes.pgm", :a, :bin orelse .die;
|
||||
|
||||
my $vzones = $VERT div 4;
|
||||
my $vzones = $y div 4;
|
||||
for 1..4 -> $w {
|
||||
my $hzones = ceiling $HOR / $w / +@colors;
|
||||
my $line = Buf.new: (flat((@colors Xxx $w) xx $hzones).Array).splice(0,$HOR);
|
||||
$PGM.write: $line for ^$vzones;
|
||||
my $stripes = ceiling $x / $w / +@colors;
|
||||
my $line = Buf.new: (flat((@colors Xxx $w) xx $stripes).Array).splice(0,$x); # DH change 2015-12-20
|
||||
$img.write: $line for ^$vzones;
|
||||
}
|
||||
|
||||
$PGM.close;
|
||||
$img.close;
|
||||
|
|
|
|||
19
Task/Pinstripe-Display/Perl/pinstripe-display.pl
Normal file
19
Task/Pinstripe-Display/Perl/pinstripe-display.pl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use Imager;
|
||||
|
||||
my($xsize,$ysize) = (640,400);
|
||||
$img = Imager->new(xsize => $xsize, ysize => $ysize);
|
||||
|
||||
my $eps = 10**-14;
|
||||
my $height = int $ysize / 4;
|
||||
for my $width (1..4) {
|
||||
$stripes = int((1-$eps) + $xsize / $width / 2);
|
||||
@row = ((0) x $width, (1) x $width) x $stripes;
|
||||
for $x (0..$#row) {
|
||||
for $y (0..$height) {
|
||||
my $offset = $height*($width-1);
|
||||
$img->setpixel(x => $x, y => $y+$offset, color => $row[$x] ? 'black' : 'white')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$img->write(file => 'pinstripes-bw.png');
|
||||
Loading…
Add table
Add a link
Reference in a new issue