Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,16 @@
(lib 'types)
(lib 'plot)
(plot-size 512 512) ;; for example
;; use m = 16, 32, 44, .. to change the definition (number of losanges)
(define (plot-munch (m 256))
(define PIX (pixels->int32-vector)) ;; get canvas image
(define (pcolor x y) ;; color at (x,y)
(hsv->rgb
(// (bitwise-xor (modulo x m) (modulo y m)) m)
0.9
0.9))
(pixels-map pcolor PIX)
(vector->pixels PIX)) ;; draw canvas image
(plot-much) ;; ESC to see tge drawing

View file

@ -0,0 +1,21 @@
' version 03-11-2016
' compile with: fbc -s gui
Dim As ULong x, y, r, w = 256
ScreenRes w, w, 32
For x = 0 To w -1
For y = 0 To w -1
r =(x Xor y) And 255
PSet(x, y), RGB(r, r , r) ' gray scale
' PSet(x, y), RGB(r, 255 - r, 0) ' red + green
' PSet(x, y), RGB(r, 0, 0) ' red
Next
Next
' empty keyboard buffer
While Inkey <> "" : Wend
WindowTitle "Close window or hit any key to end program"
Sleep
End

View file

@ -0,0 +1,43 @@
vec3 color;
float c,p;
vec2 b;
void main(void)
{
vec2 uv = gl_FragCoord.xy / iResolution.xy;
float scale = iResolution.x / iResolution.y;
uv = uv-0.5;
uv.y/=scale;
b = uv*256.0+256.0;
c = 0.0;
for(float i=16.0;i>=1.0;i-=1.0)
{
p = pow(2.0,i);
if((p < b.x) ^^
(p < b.y))
{
c += p;
}
if(p < b.x)
{
b.x -= p;
}
if(p < b.y)
{
b.y -= p;
}
}
c=mod(c/128.0,1.0);
color = vec3(sin(c+uv.x*cos(uv.y*1.2)), tan(c+uv.y-0.3)*1.1, cos(c-uv.y+0.9));
gl_FragColor = vec4(color,1.0);
}

View file

@ -0,0 +1,10 @@
require('GD')
var img = %s<GD::Image>.new(256, 256, 1)
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)
}
File('xor.png').write(img.png, :raw)

View file

@ -0,0 +1 @@
jq -n -r -f Munching_squares.jq > Munching_squares.svg

View file

@ -0,0 +1,23 @@
# Convert the input integer to an array of bits with lsb first
def integer_to_lsb:
[recurse(if . > 0 then ./2|floor else empty end) | . % 2] ;
# input array of bits (with lsb first) is converted to an integer
def lsb_to_integer:
reduce .[] as $bit
# state: [power, ans]
([1,0]; (.[0] * 2) as $b | [$b, .[1] + (.[0] * $bit)])
| .[1];
def xor(x;y):
def lxor(a;b): # a and/or b may be null
if a == 1 then if b==1 then 0 else 1 end
elif b==1 then if a==1 then 0 else 1 end
else 0
end;
(x|integer_to_lsb) as $s
| (y|integer_to_lsb) as $t
| ([$s|length, $t|length] | max) as $length
| reduce range(0;$length) as $i
([]; . + [ lxor($s[$i]; $t[$i]) ] )
| lsb_to_integer;

View file

@ -0,0 +1,11 @@
def rgb2rgb:
def p: (. + 0.5) | floor; # to nearest integer
"rgb(\(.red|p),\(.green|p),\(.blue|p))";
def svg(width; height):
"<svg width='\(width // "100%")' height='\(height // "100%")'
xmlns='http://www.w3.org/2000/svg'>";
def pixel(x; y; color):
(color | if type == "string" then . else rgb2rgb end) as $c
| "<circle r='1' cx='\(x)' cy='\(y)' fill='\($c)' />";

View file

@ -0,0 +1,17 @@
# rgb is a JSON object: { "red": _, "green": _, "blue": _}
def xor_pattern(width; height; rgb1; rgb2):
# create colour table
256 as $size
| (reduce range(0;$size) as $i
([]; . + [
{"red": (rgb1.red + (rgb2.red - rgb1.red) * $i / $size),
"green": (rgb1.green + (rgb2.green - rgb1.green) * $i / $size),
"blue": (rgb1.blue + (rgb2.blue - rgb1.blue) * $i / $size) }])
) as $colours
# create the image
| svg(width; height),
( (range(0;width) as $x
| range(0;height) as $y
| pixel($x; $y; $colours[ xor($x; $y) % $size] ) ) ),
"</svg>" ;

View file

@ -0,0 +1,5 @@
def black: { "red": 0, "green": 0, "blue": 0};
def red: black + { "red": 255 };
def yellow: red + { "green": 255 };
xor_pattern(384; 384; red; yellow)