September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
3
Task/Draw-a-clock/00META.yaml
Normal file
3
Task/Draw-a-clock/00META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
category:
|
||||
- Date and time
|
||||
83
Task/Draw-a-clock/FreeBASIC/draw-a-clock.freebasic
Normal file
83
Task/Draw-a-clock/FreeBASIC/draw-a-clock.freebasic
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
' version 05-04-2017
|
||||
' compile with: fbc -s gui
|
||||
|
||||
Const As Double deg2rad = Atn(1) / 45
|
||||
Const As UInteger w = 199, h = 199
|
||||
Const As UInteger x0 = w \ 2, y0 = h \ 2 ' center
|
||||
|
||||
Dim As UInteger x, x1, x2, x3, y, y1, y2, y3
|
||||
Dim As String sys_time, press
|
||||
Dim As Integer hours, minutes, seconds
|
||||
Dim As Double angle, a_sin, a_cos
|
||||
|
||||
ScreenRes w, h, 8 ' 8bit color depth (palette)
|
||||
WindowTitle "Simple Clock"
|
||||
|
||||
' create image 8bit (palette) and set pixels to 15 (white)
|
||||
Dim clockdial As Any Ptr = ImageCreate(w, h, 15, 8)
|
||||
|
||||
If clockdial = 0 Then
|
||||
Print "Failed to create image."
|
||||
Sleep
|
||||
End -1
|
||||
End If
|
||||
|
||||
' draw clockdial in memory
|
||||
Circle clockdial, (x0, y0), 94 ,0
|
||||
Circle clockdial, (x0, y0), 90 ,0
|
||||
|
||||
For x = 0 To 174 Step 6
|
||||
a_sin = Sin(x * deg2rad)
|
||||
a_cos = Cos(x * deg2rad)
|
||||
|
||||
x1 = 94 * a_sin : y1 = 94 * a_cos
|
||||
If x Mod 30 = 0 Then
|
||||
x2 = 85 * a_sin : y2 = 85 * a_cos
|
||||
Else
|
||||
x2 = 90 * a_sin : y2 = 90 * a_cos
|
||||
End If
|
||||
|
||||
Line clockdial, (x0 + x1, y0 + y1) - (x0 + x2, y0 + y2), 0
|
||||
Line clockdial, (x0 - x1, y0 - y1) - (x0 - x2, y0 - y2), 0
|
||||
Next
|
||||
|
||||
'draw clock
|
||||
Do
|
||||
sys_time = Time
|
||||
hours = (sys_time[0] - Asc("0")) * 10 + sys_time[1] - Asc("0")
|
||||
minutes = (sys_time[3] - Asc("0")) * 10 + sys_time[4] - Asc("0")
|
||||
seconds = (sys_time[6] - Asc("0")) * 10 + sys_time[7] - Asc("0")
|
||||
|
||||
If hours > 12 Then hours -= 12
|
||||
|
||||
angle = (180 - (hours * 30 + minutes / 2)) * deg2rad
|
||||
x1 = 65 * Sin(angle)
|
||||
y1 = 65 * Cos(angle)
|
||||
|
||||
angle = (180 - (minutes * 6 + seconds / 10)) * deg2rad
|
||||
x2 = 80 * Sin(angle)
|
||||
y2 = 80 * Cos(angle)
|
||||
|
||||
angle = (180 - seconds * 6) * deg2rad
|
||||
x3 = 90 * Sin(angle)
|
||||
y3 = 90 * Cos(angle)
|
||||
|
||||
ScreenLock
|
||||
' load image, setting pixels
|
||||
Put (0, 0), clockdial, PSet
|
||||
Line (x0, y0) - (x0 + x1, y0 + y1), 1 ' hour hand blue
|
||||
Line (x0, y0) - (x0 + x2, y0 + y2), 2 ' minute hand green
|
||||
Line (x0, y0) - (x0 + x3, y0 + y3), 12 ' second hand red
|
||||
ScreenUnLock
|
||||
|
||||
Sleep 300, 1 ' wait 300 ms, don't respond to keys pressed
|
||||
|
||||
' press esc or mouse click on close window to stop program
|
||||
press = InKey
|
||||
If press = Chr(27) Or press = Chr(255) + "k" Then Exit Do
|
||||
|
||||
Loop
|
||||
|
||||
ImageDestroy(clockdial)
|
||||
|
||||
End
|
||||
135
Task/Draw-a-clock/JavaScript/draw-a-clock-2.js
Normal file
135
Task/Draw-a-clock/JavaScript/draw-a-clock-2.js
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
canvas {
|
||||
background-color: black;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<canvas></canvas>
|
||||
<script>
|
||||
var canvas = document.querySelector("canvas");
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
canvas.addEventListener("click", function () {
|
||||
colorIndex = (colorIndex + 1) % colors.length;
|
||||
});
|
||||
|
||||
var g = canvas.getContext("2d");
|
||||
|
||||
var colors = [
|
||||
{ on: "#00FF00", off: "#002200" },
|
||||
{ on: "#FF0000", off: "#220000" },
|
||||
{ on: "#0000FF", off: "#000033" }
|
||||
];
|
||||
|
||||
var masks = ["1110111", "0010010", "1011101", "1011011", "0111010",
|
||||
"1101011", "1101111", "1010010", "1111111", "1111011"];
|
||||
|
||||
// 0, 0 is upper left; these relative units are multiplied by the size value later
|
||||
var startingPoints = [
|
||||
[0, 0], [0, 0], [8, 0], [0, 8], [0, 8], [8, 8], [0, 16]
|
||||
];
|
||||
|
||||
var isHorizontal = [1, 0, 0, 1, 0, 0, 1]; // bool
|
||||
|
||||
var vertices = [
|
||||
[
|
||||
// horizontal
|
||||
[0, 0], [1, 1], [7, 1], [8, 0], [7, -1], [1, -1]
|
||||
],
|
||||
[
|
||||
// vertical
|
||||
[0, 0], [-1, 1], [-1, 7], [0, 8], [1, 7], [1, 1]
|
||||
]
|
||||
];
|
||||
|
||||
// pixel values, to create small gaps between the elements (leds)
|
||||
var offsets = [
|
||||
[0, -1], [-1, 0], [1, 0], [0, 1], [-1, 2], [1, 2], [0, 3]
|
||||
]
|
||||
|
||||
var onColor, offColor, colorIndex = 0;
|
||||
|
||||
function drawDigitalClock(x, y, size) {
|
||||
|
||||
onColor = colors[colorIndex].on;
|
||||
offColor = colors[colorIndex].off;
|
||||
|
||||
g.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
var date = new Date();
|
||||
var segments = [date.getHours(), date.getMinutes(), date.getSeconds()];
|
||||
|
||||
segments.forEach(function (value, index) {
|
||||
x = drawDigits(x, y, size, value);
|
||||
if (index < 2) {
|
||||
x = drawSeparator(x, y, size);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function drawDigits(x, y, size, timeUnit) {
|
||||
|
||||
var digit1 = Math.floor(timeUnit / 10);
|
||||
var digit2 = timeUnit % 10;
|
||||
|
||||
x = drawElements(x, y, size, masks[digit1]);
|
||||
x = drawElements(x, y, size, masks[digit2]);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
function drawSeparator(x, y, size) {
|
||||
|
||||
g.fillStyle = onColor;
|
||||
g.fillRect(x + 0.5 * size, y + 3 * size, 2 * size, 2 * size);
|
||||
g.fillRect(x + 0.5 * size, y + 10 * size, 2 * size, 2 * size);
|
||||
|
||||
return x + size * 10;
|
||||
}
|
||||
|
||||
function drawElements(x, y, size, mask) {
|
||||
|
||||
startingPoints.forEach(function (point, i) {
|
||||
|
||||
g.fillStyle = mask[i] == '1' ? onColor : offColor;
|
||||
|
||||
var xx = x + point[0] * size + offsets[i][0];
|
||||
var yy = y + point[1] * size + offsets[i][1];
|
||||
var idx = isHorizontal[i] ? 0 : 1;
|
||||
|
||||
drawElement(xx, yy, size, vertices[idx]);
|
||||
});
|
||||
|
||||
return x + size * 15;
|
||||
}
|
||||
|
||||
function drawElement(x, y, size, vertices) {
|
||||
|
||||
g.beginPath();
|
||||
g.moveTo(x, y);
|
||||
|
||||
vertices.forEach(function (vertex) {
|
||||
g.lineTo(x + vertex[0] * size, y + vertex[1] * size);
|
||||
});
|
||||
|
||||
g.closePath();
|
||||
g.fill();
|
||||
}
|
||||
|
||||
setInterval(drawDigitalClock, 1000, 140, 200, 12);
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
71
Task/Draw-a-clock/Kotlin/draw-a-clock.kotlin
Normal file
71
Task/Draw-a-clock/Kotlin/draw-a-clock.kotlin
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// version 1.1
|
||||
|
||||
import java.awt.*
|
||||
import java.time.LocalTime
|
||||
import javax.swing.*
|
||||
|
||||
class Clock : JPanel() {
|
||||
private val degrees06: Float = (Math.PI / 30.0).toFloat()
|
||||
private val degrees30: Float = degrees06 * 5.0f
|
||||
private val degrees90: Float = degrees30 * 3.0f
|
||||
private val size = 590
|
||||
private val spacing = 40
|
||||
private val diameter = size - 2 * spacing
|
||||
private val cx = diameter / 2 + spacing
|
||||
private val cy = cx
|
||||
|
||||
init {
|
||||
preferredSize = Dimension(size, size)
|
||||
background = Color.white
|
||||
Timer(1000) {
|
||||
repaint()
|
||||
}.start()
|
||||
}
|
||||
|
||||
override public fun paintComponent(gg: Graphics) {
|
||||
super.paintComponent(gg)
|
||||
val g = gg as Graphics2D
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
drawFace(g)
|
||||
val time = LocalTime.now()
|
||||
val hour = time.hour
|
||||
val minute = time.minute
|
||||
val second = time.second
|
||||
var angle: Float = degrees90 - degrees06 * second
|
||||
drawHand(g, angle, diameter / 2 - 30, Color.red)
|
||||
val minsecs: Float = minute + second / 60.0f
|
||||
angle = degrees90 - degrees06 * minsecs
|
||||
drawHand(g, angle, diameter / 3 + 10, Color.black)
|
||||
val hourmins: Float = hour + minsecs / 60.0f
|
||||
angle = degrees90 - degrees30 * hourmins
|
||||
drawHand(g, angle, diameter / 4 + 10, Color.black)
|
||||
}
|
||||
|
||||
private fun drawFace(g: Graphics2D) {
|
||||
g.stroke = BasicStroke(2.0f)
|
||||
g.color = Color.yellow
|
||||
g.fillOval(spacing, spacing, diameter, diameter)
|
||||
g.color = Color.black
|
||||
g.drawOval(spacing, spacing, diameter, diameter)
|
||||
}
|
||||
|
||||
private fun drawHand(g: Graphics2D, angle: Float, radius: Int, color: Color) {
|
||||
val x: Int = cx + (radius.toDouble() * Math.cos(angle.toDouble())).toInt()
|
||||
val y: Int = cy - (radius.toDouble() * Math.sin(angle.toDouble())).toInt()
|
||||
g.color = color
|
||||
g.drawLine(cx, cy, x, y)
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
SwingUtilities.invokeLater {
|
||||
val f = JFrame()
|
||||
f.defaultCloseOperation = JFrame.EXIT_ON_CLOSE
|
||||
f.title = "Clock"
|
||||
f.isResizable = false
|
||||
f.add(Clock(), BorderLayout.CENTER)
|
||||
f.pack()
|
||||
f.setLocationRelativeTo(null)
|
||||
f.isVisible = true
|
||||
}
|
||||
}
|
||||
279
Task/Draw-a-clock/OoRexx/draw-a-clock-1.rexx
Normal file
279
Task/Draw-a-clock/OoRexx/draw-a-clock-1.rexx
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
/* REXX ---------------------------------------------------------------
|
||||
* 09.02.2014 Walter Pachl with a little, well considerable, help from
|
||||
* a friend (Mark Miesfeld)
|
||||
* 1) downstripped an example contained in the ooRexx distribution
|
||||
* 2) constructed the squares for seconds, minutes, and hours
|
||||
* 3) constructed second-, minute- and hour hand
|
||||
* 5) removed lots of unnecessary code (courtesy mark Miesfeld again)
|
||||
* 6) painted the background white
|
||||
* 7) display date as well as time as text
|
||||
* 21.02.2014 Attempts to add a minimize icon keep failing
|
||||
*--------------------------------------------------------------------*/
|
||||
d = .drawDlg~new
|
||||
if d~initCode <> 0 then do
|
||||
say 'The Draw dialog was not created correctly. Aborting.'
|
||||
return d~initCode
|
||||
end
|
||||
d~execute("SHOWTOP")
|
||||
return 0
|
||||
|
||||
::requires "ooDialog.cls"
|
||||
::requires 'rxmath' library
|
||||
|
||||
::class 'drawDlg' subclass UserDialog
|
||||
|
||||
::attribute interrupted unguarded
|
||||
|
||||
::method init
|
||||
expose walterFont
|
||||
|
||||
forward class (super) continue
|
||||
-- colornames:
|
||||
-- 1 dark red 7 light grey 13 red
|
||||
-- 2 dark green 8 pale green 14 light green
|
||||
-- 3 dark yellow 9 light blue 15 yellow
|
||||
-- 4 dark blue 10 white 16 blue
|
||||
-- 5 purple 11 grey 17 pink
|
||||
-- 6 blue grey 12 dark grey 18 turquoise
|
||||
|
||||
self~interrupted = .true
|
||||
|
||||
-- Create a font to write the nice big letters and digits
|
||||
opts = .directory~new
|
||||
opts~weight = 700
|
||||
walterFont = self~createFontEx("Arial",14,opts)
|
||||
|
||||
-- if \self~createcenter(200, 230,"Walter's Clock","MINIMIZEBOX", ,"System",14) then
|
||||
if \self~createcenter(200, 230,"Walter's Clock",,,"System",14) then
|
||||
self~initCode = 1
|
||||
-- self~connectDraw(100, "clock", .true)
|
||||
|
||||
::method defineDialog
|
||||
-- self~createPushButton(/*IDC_PB_DRAW*/100,0,0,240,200,"NOTAB OWNERDRAW") -- The drawing surface.
|
||||
-- self~createPushButton(/*IDC_PB_DRAW*/100,0,0,240,180,"DISABLED NOTAB") -- better. ???
|
||||
self~createPushButton(/*IDC_PB_DRAW*/100,0,0,200,200,"DISABLED NOTAB") -- better. ???
|
||||
|
||||
self~createPushButton(IDCANCEL,160,212, 35, 12,,"&Cancel")
|
||||
|
||||
::method initDialog unguarded
|
||||
expose x y dc myPen change
|
||||
change = 0
|
||||
x = self~factorx
|
||||
y = self~factory
|
||||
dc = self~getButtonDC(100)
|
||||
--+ myPen = self~createPen(1,'solid',0)
|
||||
t = .TimeSpan~fromMicroSeconds(500000) -- .5 seconds
|
||||
msg = .Message~new(self, 'clock')
|
||||
alrm = .Alarm~new(t, msg)
|
||||
|
||||
::method interrupt unguarded
|
||||
|
||||
self~interrupted = .true
|
||||
|
||||
::method cancel unguarded -- Stop the drawing program and quit.
|
||||
expose x y
|
||||
self~hide
|
||||
self~interrupted = .true
|
||||
return self~cancel:super
|
||||
|
||||
::method leaving unguarded -- Best place to clean up resources
|
||||
expose dc myPen walterFont
|
||||
|
||||
--+ self~deleteObject(myPen)
|
||||
self~freeButtonDC(/*IDC_PB_DRAW*/100,dc)
|
||||
self~deleteFont(walterFont)
|
||||
|
||||
::method clock unguarded /* draw individual pixels */
|
||||
expose x y dc myPen change walterFont
|
||||
-- Say 'clock started'
|
||||
mx = trunc(20*x); my = trunc(20*y); size = 400
|
||||
|
||||
--+ curPen = self~objectToDC(dc, myPen)
|
||||
|
||||
-- Select the nice big letters and digits into the device context to use to
|
||||
-- to write with:
|
||||
curFont = self~fontToDC(dc, walterFont)
|
||||
|
||||
-- Create a white brush and select it into the device to paint with.
|
||||
whiteBrush = self~createBrush(10)
|
||||
curBrush = self~objectToDC(dc, whiteBrush)
|
||||
|
||||
-- Paint the drawing area surface with the white brush
|
||||
-- self~rectangle(dc, 1, 1, 500, 450, 'FILL') -- how does that relate to the 180 above ???
|
||||
-- self~rectangle(dc, 1, 1, 480, 400, 'FILL') -- how does that relate to the 180 above ???
|
||||
|
||||
button = self~newPushButton(100)
|
||||
clRect = button~clientRect; -- Say clRect
|
||||
self~rectangle(dc, clRect~left+10, clRect~top+10, clRect~right-10, clRect~bottom-10, 'FILL')
|
||||
|
||||
self~transparentText(dc)
|
||||
self~writeDirect(dc, 55,20*y,"Walter's Clock")
|
||||
self~writeDirect(dc,236, 56,'12')
|
||||
self~writeDirect(dc,428,220,'3')
|
||||
self~writeDirect(dc,245,375,'6')
|
||||
self~writeDirect(dc, 60,220,'9')
|
||||
self~opaqueText(dc)
|
||||
|
||||
-- These 5 lines just have the effect of showing "Walter's Clock" first
|
||||
-- for a brief instant before the other drawing shows. If you want it all
|
||||
-- to show at once, then remove this.
|
||||
/*
|
||||
if change \= 2 then do
|
||||
call msSleep 1000
|
||||
change = 2
|
||||
end
|
||||
*/
|
||||
self~interrupted = .false
|
||||
|
||||
sec=0
|
||||
min=0
|
||||
hhh=0
|
||||
fact=rxCalcPi()/180
|
||||
Parse Value '-1 -1 -1 -1' With hho mmo sso hopo
|
||||
|
||||
do dalpha=0 To 359 by 30 until self~interrupted
|
||||
alpha = dalpha*fact
|
||||
zxa=trunc(250+124*rxCalcSin(alpha,,'R'))
|
||||
zya=trunc(230-110*rxCalcCos(alpha,,'R'))
|
||||
hhh=right(hhh,2,0)
|
||||
hhh.hhh=right(zxa,3) right(zya,3)
|
||||
hhh+=1
|
||||
self~draw_square(dc,zxa,zya,3,5)
|
||||
self~draw_square(dc,zxa,zya,2,10)
|
||||
End
|
||||
Do a=0 To 59
|
||||
a=right(a,2,0)
|
||||
alpha=a*6*fact
|
||||
sin.a=rxCalcSin(alpha,,'R')
|
||||
cos.a=rxCalcCos(alpha,,'R')
|
||||
sin.0mhh.a=sin.a
|
||||
cos.0mhh.a=cos.a
|
||||
End
|
||||
Do hoi=0 To 12*60-1
|
||||
hoi=right(hoi,3,0)
|
||||
alpha=(hoi/2)*fact
|
||||
sin.0hoh.hoi=rxCalcSin(alpha,,'R')
|
||||
cos.0hoh.hoi=rxCalcCos(alpha,,'R')
|
||||
End
|
||||
do dalpha=0 To 359 by 6 until self~interrupted
|
||||
alpha = dalpha*fact
|
||||
zxa=trunc(250+165*rxCalcSin(alpha,,'R'))
|
||||
zya=trunc(230-140*rxCalcCos(alpha,,'R'))
|
||||
sec=right(min,2,0)
|
||||
sec.sec=right(zxa,3) right(zya,3)
|
||||
sec+=1
|
||||
self~draw_square(dc,zxa,zya,3,5)
|
||||
self~draw_square(dc,zxa,zya,2,10)
|
||||
zxa=trunc(250+140*rxCalcSin(alpha,,'R'))
|
||||
zya=trunc(230-125*rxCalcCos(alpha,,'R'))
|
||||
min=right(min,2,0)
|
||||
min.min=right(zxa,3) right(zya,3)
|
||||
--Call lineout 'pos.xxx',right(min,2) 'min='min.min
|
||||
min+=1
|
||||
self~draw_square(dc,zxa,zya,3,5)
|
||||
self~draw_square(dc,zxa,zya,2,10)
|
||||
End
|
||||
|
||||
do dalpha=0 by 6 until self~interrupted
|
||||
alpha=dalpha*fact
|
||||
zxa=trunc(250+165*rxCalcSin(alpha,,'R'))
|
||||
zya=trunc(230-140*rxCalcCos(alpha,,'R'))
|
||||
time=time()
|
||||
parse Var time hh ':' mm ':' ss
|
||||
If hh>=12 Then hh=right(hh-12,2,0)
|
||||
self~writeDirect(dc, 355,40,time)
|
||||
date=date()
|
||||
self~writeDirect(dc, 355,60,date)
|
||||
If hh<>hho Then Do
|
||||
If hho>=0 Then Do
|
||||
Parse Var hhh.hho hx hy
|
||||
self~draw_square(dc,hx,hy,2,10)
|
||||
End
|
||||
Parse Var hhh.hh hx hy
|
||||
self~draw_square(dc,hx,hy,2,2)
|
||||
End
|
||||
If mm<>mmo Then Do
|
||||
If mmo>=0 Then Do
|
||||
Parse Var min.mmo mx my
|
||||
self~draw_square(dc,mx,my,2,10)
|
||||
End
|
||||
Parse Var min.mm mx my
|
||||
self~draw_square(dc,mx,my,2,2)
|
||||
End
|
||||
If ss<>sso Then Do
|
||||
If sso>=0 Then Do
|
||||
Parse Var sec.sso sx sy
|
||||
self~draw_square(dc,sx,sy,2,10)
|
||||
self~draw_second_hand(dc,sso,sin.,cos.,10)
|
||||
End
|
||||
Parse Var sec.ss sx sy
|
||||
self~draw_square(dc,sx,sy,2, 2)
|
||||
self~draw_second_hand(dc,ss,sin.,cos.,16)
|
||||
self~draw_square(dc,250,230,4,1)
|
||||
hop=right(hh*60+mm,3,0)
|
||||
self~draw_hour_hand(dc,hop,sin.,cos.,13)
|
||||
self~draw_minute_hand(dc,mm,sin.,cos.,14)
|
||||
End
|
||||
If mm<>mmo Then Do
|
||||
If hopo>=0 Then
|
||||
self~draw_hour_hand(dc,hopo,sin.,cos.,10)
|
||||
hop=right(hh*60+mm,3,0)
|
||||
self~draw_hour_hand(dc,hop,sin.,cos.,13)
|
||||
hopo=hop
|
||||
If mmo>=0 Then
|
||||
self~draw_minute_hand(dc,mmo,sin.,cos.,10)
|
||||
self~draw_minute_hand(dc,mm,sin.,cos.,14)
|
||||
End
|
||||
self~draw_square(dc,250,230,4,1)
|
||||
hho=hh
|
||||
mmo=mm
|
||||
sso=ss
|
||||
|
||||
call msSleep 100
|
||||
self~pause
|
||||
end
|
||||
-- if kpix >= size then kpix = 1
|
||||
|
||||
self~interrupted = .true
|
||||
--+ self~objectToDC(dc, curPen)
|
||||
self~objectToDC(dc, curBrush)
|
||||
|
||||
::method pause
|
||||
j = msSleep(10)
|
||||
|
||||
::method draw_square
|
||||
Use Arg dc, x, y, d, c
|
||||
Do zx=x-d to x+d
|
||||
Do zy=y-d to y+d
|
||||
self~drawPixel(dc, zx, zy, c)
|
||||
End
|
||||
End
|
||||
|
||||
::method draw_hour_hand
|
||||
Use Arg dc, hp, sin., cos., color
|
||||
Do p=1 To 60
|
||||
zx=trunc(250+p*sin.0hoh.hp)
|
||||
zy=trunc(230-p*cos.0hoh.hp)
|
||||
self~draw_square(dc, zx, zy, 2, color)
|
||||
End
|
||||
|
||||
::method draw_minute_hand
|
||||
Use Arg dc, mp, sin., cos., color
|
||||
Do p=1 To 80
|
||||
zx=trunc(250+p*sin.0mhh.mp)
|
||||
zy=trunc(230-p*cos.0mhh.mp)
|
||||
self~draw_square(dc, zx, zy, 1, color)
|
||||
End
|
||||
|
||||
::method draw_second_hand
|
||||
Use Arg dc, sp, sin., cos., color
|
||||
Do p=1 To 113
|
||||
zx=trunc(250+p*sin.sp)
|
||||
zy=trunc(230-p*(140/165)*cos.sp)
|
||||
self~draw_square(dc, zx, zy, 0, color)
|
||||
End
|
||||
|
||||
::method quot
|
||||
Parse Arg x,y
|
||||
If y=0 Then Return '??'
|
||||
Else Return x/y
|
||||
143
Task/Draw-a-clock/OoRexx/draw-a-clock-2.rexx
Normal file
143
Task/Draw-a-clock/OoRexx/draw-a-clock-2.rexx
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/* REXX ---------------------------------------------------------------
|
||||
Name: clock.rxj
|
||||
Purpose: create a graphical clock that shows the current time
|
||||
-- modelled after the Java program
|
||||
at <?http:?//rosettacode.?org/wiki/Draw_a_clock#Java>?
|
||||
|
||||
Needs: - ooRexx (cf. https://sourceforge.net/projects/oorexx/ )
|
||||
- BSF4ooRexx (Rexx-Java-bridge, cf.
|
||||
https://sourceforge.net/projects/bsf4oorexx/ )
|
||||
- Java (cf. http://www.java.com )
|
||||
Created: 2014-09-04
|
||||
Author: Rony G. Flatscher
|
||||
*--------------------------------------------------------------------*/
|
||||
-- import Java classes, make them available as ooRexx classes
|
||||
call bsf.import "java.awt.Color" , "awtColor"
|
||||
call bsf.import "java.awt.RenderingHints", "awtRenderingHints"
|
||||
call bsf.import "java.lang.Math" , "jMath"
|
||||
call bsf.import "javax.swing.JFrame" , "swingJFrame"
|
||||
call bsf.import "javax.swing.Timer" , "swingTimer"
|
||||
|
||||
rxClock=.RexxClock~new -- create Rexx clock object
|
||||
jrxClock=BSFCreateRexxProxy(rxClock) -- box Rexx object into a Java object (a Java RexxProxy)
|
||||
|
||||
/* extend Java class JPanel, make sure 'paintComponent' method invocations will get
|
||||
forwarded to a RexxProxy object that needs to be supplied upon instantiating this
|
||||
extended Java class; this method is defined in JPanel's superclass 'javax.swing.JComponent' */
|
||||
exjClz=bsf.createProxyClass("javax.swing.JPanel", "RexxJavaClock", "javax.swing.JComponent paintComponent")
|
||||
javaClock=exjClz~new(jrxClock) -- create a Java object, supply it the Java RexxProxy that processes method invocations
|
||||
javaClock~setPreferredSize(.bsf~new("java.awt.Dimension", rxClock~size, rxClock~size))
|
||||
javaClock~setBackground(.awtColor~white)
|
||||
|
||||
-- create a JFrame, configure it a little bit
|
||||
f=.swingJFrame~new
|
||||
f~defaultCloseOperation=.swingJFrame~EXIT_ON_CLOSE
|
||||
f~title ="ooRexx Clock"
|
||||
f~resizable =.false
|
||||
-- add the clock (a JPanel) to it
|
||||
f~contentPane~add(javaClock, bsf.loadClass("java.awt.BorderLayout")~CENTER)
|
||||
f~pack -- let the layout manager do its work
|
||||
f~locationRelativeTo =.nil -- no specific location (will be centered)
|
||||
|
||||
/* create Rexx object that sends repaint messages to cause the clock to be updated whenever
|
||||
the swing Timer (see below) issues the "actionPerformed" event; to release the lock when
|
||||
the 'windowClosing' event is issued */
|
||||
rxEH=.RexxEventHandler~new
|
||||
|
||||
/* box Rexx object as a Java object, supply the Java object (javaClock) as user data (will be
|
||||
be made available under the entry name "userdata" in the slotDir directory, appended
|
||||
to callbacks as additional argument); declare this Java proxy object to implement
|
||||
the interfaces 'java.awt.event.ActionListener' and 'java.awt.event.WindowListener' */
|
||||
jrxEH=BSFCreateRexxProxy(rxEH, javaClock, "java.awt.event.ActionListener", "java.awt.event.WindowListener")
|
||||
|
||||
/* SwingTimer will cause every second the actionPerformed() event to be issued,
|
||||
bsf.dispatch() to bypass ooRexx method resolution into .Object (has a 'start' method) */
|
||||
.swingTimer~new(1000, jrxEH)~bsf.dispatch("start")
|
||||
f~addWindowListener(jrxEH) -- this allows us to get notified when the JFrame gets closed
|
||||
f~~setVisible(.true)~~toFront -- show JFrame, make sure it is in the very front
|
||||
|
||||
say "..." pp(.DateTime~new) "Rexx main program, now waiting until JFrame gets closed ..."
|
||||
rxEH~wait -- wait
|
||||
say "..." pp(.DateTime~new) "Rexx main program, JFrame got closed."
|
||||
|
||||
|
||||
::requires "BSF.CLS" -- get the Java camouflaging support for ooRexx
|
||||
|
||||
/* This class controls the painting of the clock. */
|
||||
::class RexxClock -- will be used for an extension of javax.swing.JPanel overriding paintComponent
|
||||
::method init -- constructor, used for initializing
|
||||
expose degrees06 degrees30 degrees90 size spacing diameter x y
|
||||
|
||||
degrees06 = .JMath~toRadians(6)
|
||||
degrees30 = degrees06 * 5
|
||||
degrees90 = degrees30 * 3
|
||||
|
||||
size = 550
|
||||
spacing = 20;
|
||||
diameter = size - 2 * spacing
|
||||
x = trunc(diameter / 2) + spacing
|
||||
y = trunc(diameter / 2) + spacing
|
||||
|
||||
::attribute size get -- make size accessible for clients
|
||||
|
||||
::method paintComponent
|
||||
expose degrees06 degrees30 degrees90 size spacing diameter x y
|
||||
use arg g, slotDir
|
||||
-- call dump2 slotDir, .datetime~new "- paintComponent's slotDir:"
|
||||
|
||||
jobj=slotDir~javaObject -- as the Java object invoked paintComponent the message to the rexx object will supply that Java object
|
||||
jobj~paintComponent_forwardToSuper(g) -- now invoke the method in the (Java) superclass first
|
||||
|
||||
g~setRenderingHint(.awtRenderingHints~KEY_ANTIALIASING, .awtRenderingHints~VALUE_ANTIALIAS_ON)
|
||||
|
||||
g~setColor(.awtColor~black)
|
||||
g~drawOval(spacing, spacing, diameter, diameter)
|
||||
date=.dateTime~new -- use ooRexx' date and time
|
||||
|
||||
angle = degrees90 - (degrees06 * date~seconds)
|
||||
self~drawHand(g, angle, diameter / 2 - 30, .awtColor~red)
|
||||
|
||||
minsecs = (date~minutes + date~seconds / 60)
|
||||
angle = degrees90 - (degrees06 * minsecs)
|
||||
self~drawHand(g, angle, diameter / 3 + 10, .awtColor~green)
|
||||
|
||||
hourmins = (date~hours + minsecs / 60)
|
||||
angle = degrees90 - (degrees30 * hourmins)
|
||||
self~drawHand(g, angle, diameter / 4 + 10, .awtColor~black)
|
||||
|
||||
|
||||
::method drawHand
|
||||
expose x y
|
||||
use arg g, angle, radius, color
|
||||
|
||||
x2 = trunc(x + radius * .jMath~cos(angle))
|
||||
y2 = trunc(y + radius * .jMath~sin(-angle)) -- flip y-axis
|
||||
g~setColor(color)
|
||||
g~drawLine(x, y, x2, y2)
|
||||
|
||||
|
||||
|
||||
/* The following Rexx class implements the event handlers for a java.awt.event.WindowListener to be
|
||||
able to learn when the JFrame gets closed (event "windowClosing").
|
||||
|
||||
In addition it implements the java.awt.event.ActionListener for updating the clock every second
|
||||
(using a swing Timer that causes the "actionPerformed" event to be issued).
|
||||
*/
|
||||
::class RexxEventHandler
|
||||
::method init -- constructor for initialization
|
||||
expose wait -- object variable to serve as a control variable
|
||||
wait=.true -- initialize lock
|
||||
|
||||
::method wait -- method to allow for blocking
|
||||
expose wait
|
||||
guard on when wait<>.true -- the caller will be blocked until this condition turns to .false
|
||||
|
||||
::method windowClosing -- Window event when window gets closed, release wait lock
|
||||
expose wait
|
||||
wait=.false -- release lock
|
||||
|
||||
::method unknown -- catch all other window-events
|
||||
|
||||
::method actionPerformed -- this event will be caused every second by the swing Timer
|
||||
use arg eventObj, slotDir
|
||||
slotDir~userData~repaint -- fetch the Java object and send it the repaint message
|
||||
140
Task/Draw-a-clock/Phix/draw-a-clock.phix
Normal file
140
Task/Draw-a-clock/Phix/draw-a-clock.phix
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
--
|
||||
-- demo\rosetta\Clock.exw
|
||||
--
|
||||
include pGUI.e
|
||||
|
||||
constant USE_OPENGL = 01
|
||||
|
||||
Ihandle dlg, canvas, hTimer
|
||||
cdCanvas cd_canvas
|
||||
|
||||
procedure draw_hand(atom degrees, atom r, baseangle, baselen, cx, cy)
|
||||
atom a = PI-(degrees+90)*PI/180
|
||||
-- tip
|
||||
atom x1 = cos(a)*(r)
|
||||
atom y1 = sin(a)*(r)
|
||||
-- base
|
||||
atom x2 = cos(a+PI-baseangle)*baselen
|
||||
atom y2 = sin(a+PI-baseangle)*baselen
|
||||
atom x3 = cos(a+PI+baseangle)*baselen
|
||||
atom y3 = sin(a+PI+baseangle)*baselen
|
||||
cdCanvasLineWidth(cd_canvas,1)
|
||||
cdCanvasLine(cd_canvas,cx+x1,cy+y1,cx+x2,cy+y2)
|
||||
cdCanvasLine(cd_canvas,cx+x2,cy+y2,cx+x3,cy+y3)
|
||||
cdCanvasLine(cd_canvas,cx+x3,cy+y3,cx+x1,cy+y1)
|
||||
cdCanvasBegin(cd_canvas,CD_FILL)
|
||||
cdCanvasVertex(cd_canvas,cx+x1,cy+y1)
|
||||
cdCanvasVertex(cd_canvas,cx+x2,cy+y2)
|
||||
cdCanvasVertex(cd_canvas,cx+x3,cy+y3)
|
||||
cdCanvasEnd(cd_canvas)
|
||||
end procedure
|
||||
|
||||
procedure draw_clock(atom cx, cy, d)
|
||||
atom w = 2+floor(d/25)
|
||||
cdCanvasFont(cd_canvas, "Helvetica", CD_PLAIN, floor(d/15))
|
||||
cdCanvasLineWidth(cd_canvas, w)
|
||||
cdCanvasArc(cd_canvas, cx, cy, d, d, 0, 360)
|
||||
d -= w+8
|
||||
w = 1+floor(d/50)
|
||||
for i=6 to 360 by 6 do
|
||||
integer h = remainder(i,30)=0
|
||||
cdCanvasLineWidth(cd_canvas, floor(w*(1+h)/3))
|
||||
atom a = PI-(i+90)*PI/180
|
||||
atom x1 = cos(a)*d/2, x2 = cos(a)*(d/2-w*(2+h)*.66)
|
||||
atom y1 = sin(a)*d/2, y2 = sin(a)*(d/2-w*(2+h)*.66)
|
||||
cdCanvasLine(cd_canvas, cx+x1, cy+y1, cx+x2, cy+y2)
|
||||
if h then
|
||||
x1 = cos(a)*(d/2-w*4.5)
|
||||
y1 = sin(a)*(d/2-w*4.5)
|
||||
cdCanvasText(cd_canvas,cx+x1,cy+y1,sprintf("%d",{i/30}))
|
||||
end if
|
||||
end for
|
||||
atom {hour,mins,secs,msecs} = date(true)[DT_HOUR..DT_MSEC]
|
||||
if IupGetInt(hTimer,"TIME")<1000 then
|
||||
-- (if showing once a second, always land on exact
|
||||
-- seconds, ie completely ignore msecs, otherwise
|
||||
-- show smooth running (fractional) second hand.)
|
||||
secs += msecs/1000
|
||||
end if
|
||||
mins += secs/60
|
||||
hour += mins/60
|
||||
atom r = d/2
|
||||
draw_hand(hour*360/12,r-w*9,0.3,d/20,cx,cy)
|
||||
draw_hand(mins*360/60,r-w*2,0.2,d/16,cx,cy)
|
||||
cdCanvasSetForeground(cd_canvas, CD_RED)
|
||||
draw_hand(secs*360/60,r-w*2,0.05,d/16,cx,cy)
|
||||
cdCanvasSetForeground(cd_canvas, CD_BLACK)
|
||||
end procedure
|
||||
|
||||
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
|
||||
integer {width, height} = IupGetIntInt(canvas, "DRAWSIZE")
|
||||
integer r = floor(min(width,height)*0.9)
|
||||
integer cx = floor(width/2)
|
||||
integer cy = floor(height/2)
|
||||
cdCanvasActivate(cd_canvas)
|
||||
cdCanvasClear(cd_canvas)
|
||||
draw_clock(cx,cy,r)
|
||||
cdCanvasFlush(cd_canvas)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function timer_cb(Ihandle /*ih*/)
|
||||
IupUpdate(canvas)
|
||||
return IUP_IGNORE
|
||||
end function
|
||||
|
||||
function map_cb(Ihandle ih)
|
||||
if USE_OPENGL then
|
||||
atom res = IupGetDouble(NULL, "SCREENDPI")/25.4
|
||||
IupGLMakeCurrent(canvas)
|
||||
cd_canvas = cdCreateCanvas(CD_GL, "10x10 %g", {res})
|
||||
else
|
||||
cd_canvas = cdCreateCanvas(CD_IUPDBUFFER, canvas)
|
||||
end if
|
||||
cdCanvasSetBackground(cd_canvas, CD_WHITE)
|
||||
cdCanvasSetForeground(cd_canvas, CD_BLACK)
|
||||
{} = cdCanvasTextAlignment(cd_canvas, CD_CENTER)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function canvas_resize_cb(Ihandle /*canvas*/)
|
||||
if USE_OPENGL then
|
||||
integer {canvas_width, canvas_height} = IupGetIntInt(canvas, "DRAWSIZE")
|
||||
atom res = IupGetDouble(NULL, "SCREENDPI")/25.4
|
||||
cdCanvasSetAttribute(cd_canvas, "SIZE", "%dx%d %g", {canvas_width, canvas_height, res})
|
||||
end if
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function esc_close(Ihandle /*ih*/, atom c)
|
||||
if c=K_ESC then return IUP_CLOSE end if
|
||||
return IUP_CONTINUE
|
||||
end function
|
||||
|
||||
procedure main()
|
||||
IupOpen()
|
||||
|
||||
if USE_OPENGL then
|
||||
canvas = IupGLCanvas()
|
||||
else
|
||||
canvas = IupCanvas()
|
||||
end if
|
||||
IupSetAttribute(canvas, "RASTERSIZE", "350x350") -- initial size
|
||||
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
|
||||
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
|
||||
IupSetCallback(canvas, "RESIZE_CB", Icallback("canvas_resize_cb"))
|
||||
|
||||
hTimer = IupTimer(Icallback("timer_cb"), 40) -- smooth secs
|
||||
-- hTimer = IupTimer(Icallback("timer_cb"), 1000) -- tick seconds
|
||||
|
||||
dlg = IupDialog(canvas)
|
||||
IupSetAttribute(dlg, "TITLE", "Clock")
|
||||
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
|
||||
|
||||
IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
|
||||
IupSetAttribute(canvas, "RASTERSIZE", NULL) -- release the minimum limitation
|
||||
IupMainLoop()
|
||||
IupClose()
|
||||
end procedure
|
||||
|
||||
main()
|
||||
27
Task/Draw-a-clock/Rust/draw-a-clock.rust
Normal file
27
Task/Draw-a-clock/Rust/draw-a-clock.rust
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// cargo-deps: time="0.1"
|
||||
extern crate time;
|
||||
use std::thread;
|
||||
|
||||
static TOP: &'static str = " ⡎⢉⢵ ⠀⢺⠀ ⠊⠉⡱ ⠊⣉⡱ ⢀⠔⡇ ⣏⣉⡉ ⣎⣉⡁ ⠊⢉⠝ ⢎⣉⡱ ⡎⠉⢱ ⠀⠶⠀";
|
||||
static BOT: &'static str = " ⢗⣁⡸ ⢀⣸⣀ ⣔⣉⣀ ⢄⣀⡸ ⠉⠉⡏ ⢄⣀⡸ ⢇⣀⡸ ⢰⠁⠀ ⢇⣀⡸ ⢈⣉⡹ ⠀⠶⠀";
|
||||
|
||||
fn main() {
|
||||
let top: Vec<&str> = TOP.split_whitespace().collect();
|
||||
let bot: Vec<&str> = BOT.split_whitespace().collect();
|
||||
|
||||
loop {
|
||||
let tm = &time::now().rfc822().to_string()[17..25];
|
||||
let top_str: String = tm.chars().map(|x| top[x as usize - '0' as usize]).collect();
|
||||
let bot_str: String = tm.chars().map(|x| bot[x as usize - '0' as usize]).collect();
|
||||
|
||||
clear_screen();
|
||||
println!("{}", top_str);
|
||||
println!("{}", bot_str);
|
||||
|
||||
thread::sleep(std::time::Duration::from_secs(1));
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_screen() {
|
||||
println!("{}[H{}[J", 27 as char, 27 as char);
|
||||
}
|
||||
59
Task/Draw-a-clock/Scheme/draw-a-clock.ss
Normal file
59
Task/Draw-a-clock/Scheme/draw-a-clock.ss
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
(import (scheme base)
|
||||
(scheme inexact)
|
||||
(scheme time)
|
||||
(pstk))
|
||||
|
||||
(define PI 3.1415927)
|
||||
|
||||
;; Draws the hands on the canvas using the current time, and repeats each second
|
||||
(define (hands canvas)
|
||||
(canvas 'delete 'withtag "hands")
|
||||
|
||||
(let* ((time (current-second)) ; no time locality used, so displays time in GMT
|
||||
(hours (floor (/ time 3600)))
|
||||
(rem (- time (* hours 3600)))
|
||||
(mins (floor (/ rem 60)))
|
||||
(secs (- rem (* mins 60)))
|
||||
(second-angle (* secs (* 2 PI 1/60)))
|
||||
(minute-angle (* mins (* 2 PI 1/60)))
|
||||
(hour-angle (* hours (* 2 PI 1/12))))
|
||||
(canvas 'create 'line ; second hand
|
||||
100 100
|
||||
(+ 100 (* 90 (sin second-angle)))
|
||||
(- 100 (* 90 (cos second-angle)))
|
||||
'width: 1 'tags: "hands")
|
||||
(canvas 'create 'line ; minute hand
|
||||
100 100
|
||||
(+ 100 (* 85 (sin minute-angle)))
|
||||
(- 100 (* 85 (cos minute-angle)))
|
||||
'width: 3
|
||||
'capstyle: "projecting"
|
||||
'tags: "hands")
|
||||
(canvas 'create 'line ; hour hand
|
||||
100 100
|
||||
(+ 100 (* 60 (sin hour-angle)))
|
||||
(- 100 (* 60 (cos hour-angle)))
|
||||
'width: 7
|
||||
'capstyle: "projecting"
|
||||
'tags: "hands"))
|
||||
(tk/after 1000 (lambda () (hands canvas))))
|
||||
|
||||
;; Create the initial frame, clock frame and hours
|
||||
(let ((tk (tk-start)))
|
||||
(tk/wm 'title tk "GMT Clock")
|
||||
|
||||
(let ((canvas (tk 'create-widget 'canvas)))
|
||||
(tk/pack canvas)
|
||||
(canvas 'configure 'height: 200 'width: 200)
|
||||
(canvas 'create 'oval 2 2 198 198 'fill: "white" 'outline: "black")
|
||||
(do ((h 1 (+ 1 h)))
|
||||
((> h 12) )
|
||||
(let ((angle (- (/ PI 2) (* h PI 1/6))))
|
||||
(canvas 'create 'text
|
||||
(+ 100 (* 90 (cos angle)))
|
||||
(- 100 (* 90 (sin angle)))
|
||||
'text: (number->string h)
|
||||
'font: "{Helvetica -12}")))
|
||||
|
||||
(hands canvas))
|
||||
(tk-event-loop tk))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
STDOUT.autoflush(1)
|
||||
STDOUT.autoflush(true)
|
||||
|
||||
var (rows, cols) = `stty size`.words.map{.to_i}...
|
||||
var (rows, cols) = `stty size`.nums...
|
||||
|
||||
var x = (rows/2 - 1 -> int)
|
||||
var y = (cols/2 - 16 -> int)
|
||||
|
|
@ -12,20 +12,20 @@ var chars = [
|
|||
].map {|s| s.split(3) }
|
||||
|
||||
func position(i,j) {
|
||||
"\e[%d;%dH"%(i, j)
|
||||
"\e[%d;%dH" % (i, j)
|
||||
}
|
||||
|
||||
func indices {
|
||||
var t = Time.local;
|
||||
"%02d:%02d:%02d"%(t.hour, t.min, t.sec).split(1).map{|c| c.ord - '0'.ord}...
|
||||
var t = Time.local
|
||||
"%02d:%02d:%02d" % (t.hour, t.min, t.sec) -> split(1).map{|c| c.ord - '0'.ord }
|
||||
}
|
||||
|
||||
loop {
|
||||
print "\e[H\e[J";
|
||||
chars.range.each { |i|
|
||||
print position(x + i, y);
|
||||
print [chars[i][indices()]].join(' ');
|
||||
print "\e[H\e[J"
|
||||
for i in ^chars {
|
||||
print position(x + i, y)
|
||||
print [chars[i][indices()]].join(' ')
|
||||
}
|
||||
print position(1, 1);
|
||||
Sys.sleep(1);
|
||||
print position(1, 1)
|
||||
Sys.sleep(0.1)
|
||||
}
|
||||
|
|
|
|||
10
Task/Draw-a-clock/Zkl/draw-a-clock.zkl
Normal file
10
Task/Draw-a-clock/Zkl/draw-a-clock.zkl
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
var
|
||||
t=T("⡎⢉⢵","⠀⢺⠀","⠊⠉⡱","⠊⣉⡱","⢀⠔⡇","⣏⣉⡉","⣎⣉⡁","⠊⢉⠝","⢎⣉⡱","⡎⠉⢱","⠀⠶⠀"),
|
||||
b=T("⢗⣁⡸","⢀⣸⣀","⣔⣉⣀","⢄⣀⡸","⠉⠉⡏","⢄⣀⡸","⢇⣀⡸","⢰⠁⠀","⢇⣀⡸","⢈⣉⡹","⠀⠶ ");
|
||||
while(True){
|
||||
x:=Time.Date.ctime()[11,8] // or Time.Date.to24HString() (no seconds)
|
||||
.pump(List,fcn(n){ n.toAsc() - 0x30 }); //-->L(2,3,10,4,3,10,5,2)
|
||||
print("\e[H\e[J"); // home and clear screen on ANSI terminals
|
||||
println(x.pump(String,t.get),"\n",x.pump(String,b.get));
|
||||
Atomic.sleep(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue