langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,60 @@
functor
import
Application
QTk at 'x-oz://system/wp/QTk.ozf'
define
proc {Start}
Label
Window = {CreateWindow ?Label}
Animation = {New LabelAnimation init(Label delay:125)}
in
{Window show}
{Animation go}
end
fun {CreateWindow ?Label}
Courier = {QTk.newFont font(family:courier size:14)}
GUI = td(
title:"Basic Animation"
label(text:"Hello World! " handle:Label font:Courier)
action:proc {$} {Application.exit 0} end
)
in
{QTk.build GUI}
end
class LabelAnimation from Time.repeat
attr
activeShifter:ShiftRight
otherShifter:ShiftLeft
feat
label
meth init(Label delay:Delay<=100)
self.label = Label
{self setRepAll(action:Animate delay:Delay)}
{Label bind(event:"<Button-1>" action:self#Revert)}
end
meth Animate
OldText = {self.label get(text:$)}
NewText = {@activeShifter OldText}
in
{self.label set(text:NewText)}
end
meth Revert
otherShifter := (activeShifter := @otherShifter)
end
end
fun {ShiftRight Xs}
{List.last Xs}|{List.take Xs {Length Xs}-1}
end
fun {ShiftLeft Xs}
{Append Xs.2 [Xs.1]}
end
{Start}
end

View file

@ -0,0 +1,30 @@
OpenWindow(0,0,0,500,100,"Hello World!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
text$ = "Hello World! "
direction = 1
LoadFont(0,"",60)
ButtonGadget(0,2,2,496,96,text$) : SetGadgetFont(0,FontID(0))
Repeat
event = WaitWindowEvent(50)
Select event
Case #PB_Event_Gadget
If EventGadget() = 0
direction*-1
EndIf
Case #PB_Event_CloseWindow
End
EndSelect
If ElapsedMilliseconds()-tick > 400
offset+direction
If offset > Len(text$)-1
offset = 0
ElseIf offset < 0
offset = Len(text$)-1
EndIf
SetGadgetText(0,Mid(text$,offset+1)+Left(text$,offset))
tick = ElapsedMilliseconds()
EndIf
ForEver

View file

@ -0,0 +1,45 @@
REBOL [
Title: "Basic Animation"
Author: oofoe
Date: 2009-12-06
URL: http://rosettacode.org/wiki/Basic_Animation
]
message: "Hello World! " how: 1
roll: func [
"Shifts a text string right or left by one character."
text [string!] "Text to shift."
direction [integer!] "Direction to shift -- right: 1, left: -1."
/local h t
][
either direction > 0 [
h: last text t: copy/part text ((length? text) - 1)
][
h: copy skip text 1 t: text/1
]
rejoin [h t]
]
; This next bit specifies the GUI panel. The window will have a
; gradient backdrop, over which will be composited the text, in a
; monospaced font with a drop-shadow. A timer (the 'rate' bit) is set
; to update 24 times per second. The 'engage' function in the 'feel'
; block listens for events on the text face. Time events update the
; animation and mouse-down change the animation's direction.
view layout [
backdrop effect [gradient 0x1 coal black]
vh1 as-is message ; 'as-is' prevents text trimming.
font [name: font-fixed]
rate 24
feel [
engage: func [f a e] [
case [
'time = a [set-face f message: roll message how] ; Animate.
'down = a [how: how * -1] ; Change direction.
]
]
]
]

View file

@ -0,0 +1,36 @@
Window(Controller
{
Xmin: 50
Ymin: 50
New()
{
super(.layout())
.txt = .FindControl('text')
.moveTimer = SetTimer(NULL, 0, 600, .moveTimerFunc)
}
direction: -1
moveTimer: false
layout()
{
return #(Vert (Static 'Hello World! ', size: 12, weight: 600,
notify:, name: 'text'))
}
moveTimerFunc(@unused)
{
str = .txt.Get()
.txt.Set(str.Substr(1 * .direction) $ str.Substr(0, (1 * .direction)))
}
Static_Click()
{
.direction = .direction * -1
}
Destroy()
{
if .moveTimer isnt false
{
KillTimer(NULL, .moveTimer)
ClearCallback(.moveTimerFunc)
}
super.Destroy()
}
})

View file

@ -0,0 +1,31 @@
VERSION 5.00
Begin VB.Form Form1
Begin VB.Timer Timer1
Interval = 250
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Hello World! "
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Everything above this line is hidden when in the IDE.
Private goRight As Boolean
Private Sub Label1_Click()
goRight = Not goRight
End Sub
Private Sub Timer1_Timer()
If goRight Then
x = Mid(Label1.Caption, 2) & Left(Label1.Caption, 1)
Else
x = Right(Label1.Caption, 1) & Left(Label1.Caption, Len(Label1.Caption) - 1)
End If
Label1.Caption = x
End Sub

View file

@ -0,0 +1,23 @@
include c:\cxpl\codes;
int CpuReg, Dir, I, J;
char Str;
string 0; \use zero-terminated strings, instead of MSb set
[CpuReg:= GetReg; \provides access to 8086 CPU registers
\ 0123456789012
Str:= "Hello World! ";
Clear;
Dir:= -1; \make string initially scroll to the right
I:= 0; \index to start of displayed portion of string
repeat Cursor(0, 0); \set cursor position to upper-left corner
for J:= 0 to 12 do
[ChOut(0, Str(I)); I:= I+1; if I>12 then I:= 0];
Sound(0, 2, 1); \delay about 1/9 second
I:= I+Dir; \step starting position of displayed string
if I<0 then I:=12; \wraparound
if I>12 then I:= 0;
CpuReg:= GetReg; \get mouse button press information
CpuReg(0):= 5; CpuReg(1):= 0;
SoftInt($33); \reverse direction if left button was pressed
if CpuReg(1) then Dir:= -Dir;
until KeyHit; \any keystroke terminates program
]