September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,4 +1,13 @@
|
|||
import Data.ByteString
|
||||
import Data.Bits
|
||||
import qualified Data.ByteString as BY (writeFile, pack)
|
||||
|
||||
main = Data.ByteString.writeFile "out.pgm" (pack (fmap (fromIntegral . fromEnum) "P5\n256 256\n256\n" ++ [x `xor` y | x <- [0..255], y <- [0..255]]))
|
||||
import Data.Bits (xor)
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
BY.writeFile
|
||||
"out.pgm"
|
||||
(BY.pack
|
||||
(fmap (fromIntegral . fromEnum) "P5\n256 256\n256\n" ++
|
||||
[ x `xor` y
|
||||
| x <- [0 .. 255]
|
||||
, y <- [0 .. 255] ]))
|
||||
|
|
|
|||
27
Task/Munching-squares/Lua/munching-squares.lua
Normal file
27
Task/Munching-squares/Lua/munching-squares.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local clr = {}
|
||||
function drawMSquares()
|
||||
local pts = {}
|
||||
for j = 0, hei - 1 do
|
||||
for i = 0, wid - 1 do
|
||||
idx = bit.bxor( i, j ) % 256
|
||||
pts[1] = { i, j, clr[idx][1], clr[idx][2], clr[idx][3], 255 }
|
||||
love.graphics.points( pts )
|
||||
end
|
||||
end
|
||||
end
|
||||
function createPalette()
|
||||
for i = 0, 255 do
|
||||
clr[i] = { bit.band( i * 2.8, 255 ), bit.band( i * 3.2, 255 ), bit.band( i * 1.5, 255 ) }
|
||||
end
|
||||
end
|
||||
function love.load()
|
||||
wid, hei = love.graphics.getWidth(), love.graphics.getHeight()
|
||||
canvas = love.graphics.newCanvas( wid, hei )
|
||||
love.graphics.setCanvas( canvas ); love.graphics.clear()
|
||||
love.graphics.setColor( 255, 255, 255 )
|
||||
createPalette(); drawMSquares();
|
||||
love.graphics.setCanvas()
|
||||
end
|
||||
function love.draw()
|
||||
love.graphics.draw( canvas )
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
my $ppm = open("munching.ppm", :w, :bin) or
|
||||
my $ppm = open("munching.ppm", :w) or
|
||||
die "Can't create munching.ppm: $!";
|
||||
|
||||
$ppm.print(q :to 'EOT');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ my @colors = map -> $r, $g, $b { Buf.new: $r, $g, $b },
|
|||
flat (0,2...254),(254,252...0));
|
||||
|
||||
|
||||
my $PPM = open "munching.ppm", :w, :bin or die "Can't create munching.ppm: $!";
|
||||
my $PPM = open "munching.ppm", :w or die "Can't create munching.ppm: $!";
|
||||
|
||||
$PPM.print: qq:to/EOH/;
|
||||
P6
|
||||
|
|
|
|||
16
Task/Munching-squares/Rust/munching-squares.rust
Normal file
16
Task/Munching-squares/Rust/munching-squares.rust
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
extern crate image;
|
||||
|
||||
use image::{ImageBuffer, Pixel, Rgb};
|
||||
|
||||
fn main() {
|
||||
let mut img = ImageBuffer::new(256, 256);
|
||||
|
||||
for x in 0..256 {
|
||||
for y in 0..256 {
|
||||
let pixel = Rgb::from_channels(0, x as u8 ^ y as u8, 0, 0);
|
||||
img.put_pixel(x, y, pixel);
|
||||
}
|
||||
}
|
||||
|
||||
let _ = img.save("output.png");
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
require('GD')
|
||||
require('Imager')
|
||||
|
||||
var img = %s<GD::Image>.new(256, 256, 1)
|
||||
var img = %O<Imager>.new(xsize => 256, ysize => 256)
|
||||
|
||||
for y,x in (^256 ~X ^256) {
|
||||
var color = img.colorAllocate((255 - x - y).abs, (255-x)^y, x^(255-y))
|
||||
img.setPixel(x, y, color)
|
||||
for x,y in (^256 ~X ^256) {
|
||||
var rgb = [(255 - x - y).abs, (255-x)^y, x^(255-y)]
|
||||
img.setpixel(x => x, y => y, color => rgb)
|
||||
}
|
||||
|
||||
File('xor.png').write(img.png, :raw)
|
||||
img.write(file => 'xor.png')
|
||||
|
|
|
|||
12
Task/Munching-squares/Zkl/munching-squares-1.zkl
Normal file
12
Task/Munching-squares/Zkl/munching-squares-1.zkl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fcn muncher{
|
||||
bitmap:=PPM(256,256);
|
||||
coolness:=(1).random(0x10000); // 55379, 18180, 40, 51950, 57619, 43514, 65465
|
||||
foreach y,x in ([0 .. 255],[0 .. 255]){
|
||||
b:=x.bitXor(y); // shades of blue
|
||||
// rgb:=b*coolness; // kaleidoscopic image
|
||||
// rgb:=(b*coolness + b)*coolness + b; // more coolness
|
||||
rgb:=(b*0x10000 + b)*0x10000 + b; // copy ADA image
|
||||
bitmap[x,y]=rgb;
|
||||
}
|
||||
bitmap.write(File("foo.ppm","wb"));
|
||||
}();
|
||||
1
Task/Munching-squares/Zkl/munching-squares-2.zkl
Normal file
1
Task/Munching-squares/Zkl/munching-squares-2.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
while(1){ muncher(); Atomic.sleep(3); }
|
||||
Loading…
Add table
Add a link
Reference in a new issue