Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
88
Task/Draw-a-clock/Evaldraw/draw-a-clock.evaldraw
Normal file
88
Task/Draw-a-clock/Evaldraw/draw-a-clock.evaldraw
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
(){
|
||||
cls(0);
|
||||
drawclock(150);
|
||||
}
|
||||
drawclock(rad) {
|
||||
hand_color = 0x6a6a6a;
|
||||
seconds_color = 0xff0000;
|
||||
radius_notches = rad*.95;
|
||||
radius_numbers = rad*.85;
|
||||
small_notch_size =rad*0.04;
|
||||
big_notch_size = rad*0.08;
|
||||
cx=rad+1;
|
||||
cy=rad+1;
|
||||
|
||||
// Face background
|
||||
setcol(0x5aaaaa); drawsph(cx,cy,rad);
|
||||
|
||||
// Highlight from stopwatch.kc
|
||||
setcol(0xffffff); gldisable(GL_DEPTH_TEST);
|
||||
glbegin(GL_COMPLEX); glsettex("whitepix.tga");
|
||||
for(a=3.5;a<=4.5;a+=.25) { gltexcoord(0,0); glvertex(cos(a)*rad*.55+cx,sin(a)*rad*.55+cy); }
|
||||
for(a=4.5;a>=3.5;a-=.25) { gltexcoord(0,0); glvertex(cos(a)*rad*.45+cx,sin(a)*rad*.45+cy); }
|
||||
glend();
|
||||
|
||||
moveto(cx-4*6, cy-.5*rad);
|
||||
setfont(6,8);
|
||||
setcol(0); printf("Evaltime");
|
||||
|
||||
// Face
|
||||
setcol(0x015151);
|
||||
hr=0;
|
||||
for(i=0; i<60; i++)
|
||||
{
|
||||
a = i/60*2*pi - pi/2;
|
||||
ca=cos(a);
|
||||
sa=sin(a);
|
||||
if (i%5==0)
|
||||
{
|
||||
hour = hr; if (hour==0) hour=12;
|
||||
draw_hour(cx,cy,ca,sa,radius_numbers,hour);
|
||||
hr++;
|
||||
|
||||
r=radius_notches;
|
||||
x=cx + ca*r; y=cy+sa*r;
|
||||
drawcone(x,y,big_notch_size*.5,x+big_notch_size*ca,y+big_notch_size*sa,-big_notch_size*.5,0);
|
||||
} else {
|
||||
r=radius_notches;
|
||||
x=cx + ca*r; y=cy+sa*r;
|
||||
drawcone(x,y,small_notch_size*.5,x+small_notch_size*ca,y+small_notch_size*sa,-small_notch_size*.5,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int_hours = klock(6);
|
||||
int_minutes = klock(7);
|
||||
int_seconds = klock(8);
|
||||
int_millis = klock(9);
|
||||
|
||||
// Hour and Minute hand
|
||||
hours = (int_hours+int_minutes/60.0) / 24.0;
|
||||
a = hours * 2*pi - pi/2;
|
||||
drawhand(cx,cy,a, rad*.64, 6,4, hand_color);
|
||||
a = ( (int_minutes+int_seconds/60+int_millis/1000/60) / 60) * 2*pi - pi/2;
|
||||
drawhand(cx,cy,a, rad*.84, 4,2, hand_color);
|
||||
|
||||
a = ((int_seconds+int_millis/1000) / 60) * 2*pi - pi/2;
|
||||
drawhand(cx,cy,a, rad*.9, 3,1, seconds_color);
|
||||
}
|
||||
|
||||
draw_hour(cx,cy,ca,sa,r,hr) {
|
||||
x=cx + ca*r; y=cy+sa*r;
|
||||
ofs=0; if(hr>9 || hr==0) ofs=5;
|
||||
setfont(9,16);
|
||||
moveto(x-4.5-ofs,y-8);
|
||||
printf("%g", hr);
|
||||
}
|
||||
drawhand(cx,cy,angle,forward,r0,r1,kolor) {
|
||||
back = .19*forward;
|
||||
sx=cx - cos(angle)*back;
|
||||
sy=cy - sin(angle)*back;
|
||||
ex=cx + cos(angle)*forward;
|
||||
ey=cy + sin(angle)*forward;
|
||||
setcol(0);
|
||||
drawcone(sx,sy,r0+1,ex,ey,r1+1);
|
||||
setcol(kolor);
|
||||
drawsph(cx,cy,r0+3);
|
||||
drawcone(sx,sy,-r0,ex,ey,r1);
|
||||
}
|
||||
77
Task/Draw-a-clock/Quackery/draw-a-clock.quackery
Normal file
77
Task/Draw-a-clock/Quackery/draw-a-clock.quackery
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
[ $ "turtleduck.qky" loadfile
|
||||
$ "bigrat.qky" loadfile ] now!
|
||||
|
||||
[ $ \
|
||||
import datetime
|
||||
sec = datetime.timedelta(seconds=1)
|
||||
time_will_be = datetime.datetime.now()+sec
|
||||
hours = time_will_be.hour
|
||||
minutes = time_will_be.minute
|
||||
seconds = time_will_be.second
|
||||
to_stack([hours, minutes, seconds])
|
||||
\ python ] is time+1 ( --> [ )
|
||||
|
||||
|
||||
[ $ \
|
||||
import time
|
||||
current_time = time.time()
|
||||
time_to_sleep = 1.0 - (current_time % 1.0)
|
||||
time.sleep(time_to_sleep)
|
||||
\ python ] is wait ( --> )
|
||||
|
||||
[ 3 wide
|
||||
60 times
|
||||
[ 240 1 fly
|
||||
10 1 walk
|
||||
-250 1 fly
|
||||
1 60 turn ]
|
||||
7 wide
|
||||
12 times
|
||||
[ 235 1 fly
|
||||
12 1 walk
|
||||
-247 1 fly
|
||||
1 12 turn ]
|
||||
9 wide
|
||||
4 times
|
||||
[ 233 1 fly
|
||||
14 1 walk
|
||||
-247 1 fly
|
||||
1 4 turn ]
|
||||
1 wide
|
||||
' [ 0 0 0 ] fill
|
||||
[ 10 1 circle ] ] is face ( --> )
|
||||
|
||||
[ 12 wide
|
||||
unpack rot dip
|
||||
[ 43200 rot
|
||||
720 v+ ]
|
||||
12 v+
|
||||
2dup turn
|
||||
175 1 walk
|
||||
-175 1 fly
|
||||
-v turn ] is hour ( [ --> )
|
||||
|
||||
[ 8 wide
|
||||
unpack rot drop
|
||||
3600 rot
|
||||
60 v+
|
||||
2dup turn
|
||||
200 1 walk
|
||||
-200 1 fly
|
||||
-v turn ] is minute ( [ --> )
|
||||
|
||||
[ 4 wide
|
||||
2 peek
|
||||
dup 60 turn
|
||||
225 1 walk
|
||||
-225 1 fly
|
||||
negate 60 turn ] is second ( [ --> )
|
||||
|
||||
[ turtle
|
||||
0 frames
|
||||
[ clear -1 4 turn
|
||||
face
|
||||
time+1 dup dup
|
||||
second minute hour
|
||||
wait
|
||||
frame 1 4 turn again ] ] is clock ( --> )
|
||||
11
Task/Draw-a-clock/Raku/draw-a-clock-2.raku
Normal file
11
Task/Draw-a-clock/Raku/draw-a-clock-2.raku
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
constant @t = < ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀>;
|
||||
constant @b = < ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀>;
|
||||
|
||||
signal(SIGINT).tap: { print "\e[?25h\n"; exit }
|
||||
print "\e7\e[?25l"; # saves cursor position, make it invisible
|
||||
loop {
|
||||
my @x = DateTime.now.Str.substr(11,8).ords X- ord('0');
|
||||
put ~.[@x] for @t, @b;
|
||||
sleep 1;
|
||||
print "\e8"; # restores cursor position
|
||||
}
|
||||
10
Task/Draw-a-clock/Raku/draw-a-clock-3.raku
Normal file
10
Task/Draw-a-clock/Raku/draw-a-clock-3.raku
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
print "\e7";
|
||||
loop {
|
||||
my $time = DateTime.now;
|
||||
put '#' x $_ ~ '.' x (24 - $_) given $time.hour.round;
|
||||
put '#' x $_ ~ '.' x (60 - $_) given $time.minute.round;
|
||||
put '#' x $_ ~ '.' x (60 - $_) given $time.second.round;
|
||||
sleep 1;
|
||||
print "\e8";
|
||||
}
|
||||
END put "\n";
|
||||
168
Task/Draw-a-clock/Yabasic/draw-a-clock-2.basic
Normal file
168
Task/Draw-a-clock/Yabasic/draw-a-clock-2.basic
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#!/usr/bin/yabasic
|
||||
REM yaclock
|
||||
DEG_PER_RAD = 57.257751
|
||||
|
||||
winx = 480
|
||||
winy = 480
|
||||
|
||||
radius = min(winx,winy) / 2 - 1
|
||||
hx = (winx/2) - 1
|
||||
hy = (winy/2) - 1
|
||||
|
||||
REM length of the hands (90% of the radius of the clock face)
|
||||
shand = int(radius * .9)
|
||||
mhand = int(radius * .9)
|
||||
hhand = int(radius * .5)
|
||||
|
||||
REM drop coords by one since graphics are 0 based
|
||||
|
||||
winx = winx - 1
|
||||
winy = winy - 1
|
||||
|
||||
clear screen
|
||||
|
||||
open window winx,winy
|
||||
|
||||
clockface()
|
||||
|
||||
do
|
||||
|
||||
hour = val(mid$(time$,1,2))
|
||||
mins = val(mid$(time$,4,2))
|
||||
sec = val(mid$(time$,7,2))
|
||||
|
||||
updatehand("sec")
|
||||
updatehand("mins")
|
||||
updatehand("hour")
|
||||
|
||||
pause .25
|
||||
|
||||
loop
|
||||
|
||||
sub updatehand(hand$)
|
||||
|
||||
switch(hand$)
|
||||
case "sec"
|
||||
h_len = shand
|
||||
angle = sec * 6
|
||||
width = 6
|
||||
color 255,0,0
|
||||
ox = osx
|
||||
oy = osy
|
||||
oxm1 = osxm1
|
||||
oxm2 = osxm2
|
||||
oym1 = osym1
|
||||
oym2 = osym2
|
||||
break
|
||||
case "mins"
|
||||
h_len = mhand
|
||||
angle = mins * 6 + int(sec/10)
|
||||
width = 12
|
||||
color 0,255,0
|
||||
ox = omx
|
||||
oy = omy
|
||||
oxm1 = omxm1
|
||||
oxm2 = omxm2
|
||||
oym1 = omym1
|
||||
oym2 = omym2
|
||||
break
|
||||
case "hour"
|
||||
h_len = hhand
|
||||
angle = ((hour * 30) + (minutes / 12) * 6) + int(mins/2)
|
||||
width = 15
|
||||
color 0,0,255
|
||||
ox = ohx
|
||||
oy = ohy
|
||||
oxm1 = ohxm1
|
||||
oxm2 = ohxm2
|
||||
oym1 = ohym1
|
||||
oym2 = ohym2
|
||||
break
|
||||
end switch
|
||||
|
||||
h_angle1 = angle - width
|
||||
if h_angle1 < 0 then
|
||||
h_angle1 = h_angle1 + 360
|
||||
endif
|
||||
h_angle1 = h_angle1 / DEG_PER_RAD
|
||||
|
||||
h_angle2 = angle + width
|
||||
if h_angle2 > 360 then
|
||||
h_angle2 = h_angle2 - 360
|
||||
endif
|
||||
h_angle2 = h_angle2 / DEG_PER_RAD
|
||||
|
||||
angle = angle / DEG_PER_RAD
|
||||
|
||||
x = (hx + (sin(angle) * h_len))
|
||||
xm1 = (hx + (sin(h_angle1) * int(h_len * .2)))
|
||||
xm2 = (hx + (sin(h_angle2) * int(h_len * .2)))
|
||||
|
||||
y = (hy - (cos(angle) * h_len))
|
||||
ym1 = (hy - (cos(h_angle1) * int(h_len * .2)))
|
||||
ym2 = (hy - (cos(h_angle2) * int(h_len * .2)))
|
||||
|
||||
clear line hx,hy,oxm1,oym1
|
||||
clear line hx,hy,oxm2,oym2
|
||||
clear line oxm1,oym1,ox,oy
|
||||
clear line oxm2,oym2,ox,oy
|
||||
line hx,hy,xm1,ym1
|
||||
line hx,hy,xm2,ym2
|
||||
line xm1,ym1,x,y
|
||||
line xm2,ym2,x,y
|
||||
|
||||
REM save off the old vals
|
||||
switch(hand$)
|
||||
case "sec"
|
||||
osx = x
|
||||
osy = y
|
||||
osxm1 = xm1
|
||||
osxm2 = xm2
|
||||
osym1 = ym1
|
||||
osym2 = ym2
|
||||
break
|
||||
case "mins"
|
||||
omx = x
|
||||
omy = y
|
||||
omxm1 = xm1
|
||||
omxm2 = xm2
|
||||
omym1 = ym1
|
||||
omym2 = ym2
|
||||
break
|
||||
case "hour"
|
||||
ohx = x
|
||||
ohy = y
|
||||
ohxm1 = xm1
|
||||
ohxm2 = xm2
|
||||
ohym1 = ym1
|
||||
ohym2 = ym2
|
||||
break
|
||||
end switch
|
||||
end sub
|
||||
|
||||
sub clockface()
|
||||
circle hx,hy,radius
|
||||
|
||||
htick = radius / 10
|
||||
mtick = htick / 2
|
||||
|
||||
for z=0 to 360 step 6
|
||||
REM Begin at zero deg and stop before 360 deg
|
||||
|
||||
REM draw the hour markers
|
||||
angle = z
|
||||
angle = angle / DEG_PER_RAD
|
||||
x2 = (hx + (sin(angle) * radius))
|
||||
y2 = (hy - (cos(angle) * radius))
|
||||
if mod(z,30) = 0 then
|
||||
tick = htick
|
||||
else
|
||||
tick = mtick
|
||||
endif
|
||||
x3 = (hx + (sin(angle) * (radius - tick)))
|
||||
y3 = (hy - (cos(angle) * (radius - tick)))
|
||||
color 255,0,0
|
||||
line x2,y2,x3,y3
|
||||
color 0,0,0
|
||||
next z
|
||||
end sub
|
||||
Loading…
Add table
Add a link
Reference in a new issue