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,9 @@
10 COLOR 0,1:COLOR 1,2:COLOR 4,1:GRAPHIC 1,1
20 X=160:Y=100:R=80
30 CIRCLE 1,X,Y,R
40 CIRCLE 1,X,Y-R/2,R/2,R/2,0,180
50 CIRCLE 1,X,Y+R/2,R/2,R/2,180,360
60 CIRCLE 1,X,Y-R/2,R/8
70 CIRCLE 1,X,Y+R/2,R/8
80 PAINT 1,X,Y+R/2
90 PAINT 1,X-R/2,Y

View file

@ -0,0 +1,66 @@
module circles;
extern printf;
@Boolean in_circle(@Integer centre_x, @Integer centre_y, @Integer radius, @Integer x, @Integer y) [
return (x-centre_x)*(x-centre_x)+(y-centre_y)*(y-centre_y) <= radius*radius;
]
@Boolean in_big_circle (@Integer radius, @Integer x, @Integer y) [
return in_circle(0, 0, radius, x, y);
]
@Boolean in_while_semi_circle (@Integer radius, @Integer x, @Integer y) [
return in_circle(0, radius/2, radius/2, x, y);
]
@Boolean in_small_white_circle (@Integer radius, @Integer x, @Integer y) [
return in_circle(0, 0-radius/2, radius/6, x, y);
]
@Boolean in_black_semi_circle (@Integer radius, @Integer x, @Integer y) [
return in_circle(0, 0-radius/2, radius/2, x, y);
]
@Boolean in_small_black_circle (@Integer radius, @Integer x, @Integer y) [
return in_circle(0, radius/2, radius/6, x, y);
]
@Void print_yin_yang(@Integer radius) [
var white = '.';
var black = '#';
var clear = ' ';
var scale_y = 1;
var scale_x = 2;
for (var sy = radius*scale_y; sy >= -(radius*scale_y); sy=sy-1) {
for (var sx = -(radius*scale_x); sx <= radius*scale_x; sx=sx+1) {
var x = sx/(scale_x);
var y = sy/(scale_y);
if (in_big_circle(radius, x, y)) {
if (in_while_semi_circle(radius, x, y))
if (in_small_black_circle(radius, x, y))
printf("%c", black);
else
printf("%c", white);
else if (in_black_semi_circle(radius, x, y))
if (in_small_white_circle(radius, x, y))
printf("%c", white);
else
printf("%c", black);
else if (x < 0)
printf("%c", white);
else
printf("%c", black);
} else printf("%c", clear);
}
printf("\n");
}
]
@Integer main [
print_yin_yang(17);
print_yin_yang(8);
return 0;
]

View file

@ -0,0 +1,24 @@
func circle (rad, cx, cy, fill='white', stroke='black') {
say "<circle cx='#{cx}' cy='#{cy}' r='#{rad}' fill='#{fill}' stroke='#{stroke}' stroke-width='1'/>";
}
func yin_yang (rad, cx, cy, fill='white', stroke='black', angle=90) {
var (c, w) = (1, 0);
angle != 0 && say "<g transform='rotate(#{angle}, #{cx}, #{cy})'>";
circle(rad, cx, cy, fill, stroke);
say("<path d='M #{cx} #{cy + rad}A #{rad/2} #{rad/2} 0 0 #{c} #{cx} #{cy} ",
"#{rad/2} #{rad/2} 0 0 #{w} #{cx} #{cy - rad} #{rad} #{rad} 0 0 #{c} #{cx} ",
"#{cy + rad} z' fill='#{stroke}' stroke='none' />");
circle(rad/5, cx, cy + rad/2, fill, stroke);
circle(rad/5, cx, cy - rad/2, stroke, fill);
angle != 0 && say "</g>";
}
say '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink">';
yin_yang(40, 50, 50);
yin_yang(20, 120, 120);
say '</svg>';

View file

@ -0,0 +1,29 @@
def svg:
"<svg width='100%' height='100%' version='1.1'
xmlns='http://www.w3.org/2000/svg'
xmlns:xlink='http://www.w3.org/1999/xlink'>" ;
def draw_yinyang(x; scale):
"<use xlink:href='#y' transform='translate(\(x),\(x)) scale(\(scale))'/>";
def define_yinyang:
"<defs>
<g id='y'>
<circle cx='0' cy='0' r='200' stroke='black'
fill='white' stroke-width='1'/>
<path d='M0 -200 A 200 200 0 0 0 0 200
100 100 0 0 0 0 0 100 100 0 0 1 0 -200
z' fill='black'/>
<circle cx='0' cy='100' r='33' fill='white'/>
<circle cx='0' cy='-100' r='33' fill='black'/>
</g>
</defs>" ;
def draw:
svg,
define_yinyang,
draw_yinyang(20; .05),
draw_yinyang(8 ; .02),
"</svg>" ;
draw

View file

@ -0,0 +1 @@
$ jq -M -r -n -f yin_and_yang.jq > yin_and_yang.svg