September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -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] ]))

View 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

View file

@ -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');

View file

@ -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

View 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");
}

View file

@ -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')

View 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"));
}();

View file

@ -0,0 +1 @@
while(1){ muncher(); Atomic.sleep(3); }