June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,9 +1,9 @@
|
|||
DIM C AS STRING = "Hello World! ", SIZE AS USHORT = LEN(C)
|
||||
DIM DIRECTION AS BYTE = 0
|
||||
DIM AS INTEGER X, Y, BTNS
|
||||
DIM BUTHELD AS BYTE = 0
|
||||
DIM HELD AS BYTE = 0
|
||||
|
||||
SCREEN 12
|
||||
SCREEN 19
|
||||
|
||||
DO
|
||||
LOCATE 1, 1
|
||||
|
|
@ -11,15 +11,14 @@ DO
|
|||
|
||||
GETMOUSE X, Y, , BTNS
|
||||
|
||||
IF BTNS <> 0 THEN
|
||||
IF BUTHELD = 0 THEN 'remember if it was pressed, to not react
|
||||
BUTHELD = 1 'every frame on the mouse being just held
|
||||
IF (X >= 0 AND X < SIZE * 8) AND (Y >= 0 AND Y < 16) THEN
|
||||
DIRECTION = 1 - DIRECTION
|
||||
END IF
|
||||
IF BTNS <> 0 AND HELD = 0 THEN
|
||||
'remember if it was pressed, to not react every frame
|
||||
HELD = 1
|
||||
IF X >= 0 AND X < SIZE * 8 AND Y >= 0 AND Y < 16 THEN
|
||||
DIRECTION = 1 - DIRECTION
|
||||
END IF
|
||||
ELSE
|
||||
BUTHELD = 0
|
||||
HELD = 0
|
||||
END IF
|
||||
|
||||
IF INKEY = CHR(255) + CHR(107) THEN EXIT DO
|
||||
|
|
|
|||
26
Task/Animation/J/animation-1.j
Normal file
26
Task/Animation/J/animation-1.j
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
coinsert'jgl2' [ require'gl2'
|
||||
|
||||
MESSAGE =: 'Hello World! '
|
||||
TIMER_INTERVAL =: 0.5 * 1000 NB. Milliseconds
|
||||
DIRECTION =: -1 NB. Initial direction is right -->
|
||||
|
||||
ANIM =: noun define
|
||||
pc anim closeok;pn "Basic Animation in J";
|
||||
minwh 350 5;
|
||||
cc isi isigraph flush;
|
||||
pcenter;pshow;
|
||||
)
|
||||
|
||||
anim_run =: verb def 'wd ANIM,''; ptimer '',":TIMER_INTERVAL' NB. Set form timer
|
||||
anim_timer =: verb def 'glpaint MESSAGE=: DIRECTION |. MESSAGE' NB. Rotate MESSAGE according to DIRECTION
|
||||
anim_isi_mbldown=: verb def 'DIRECTION=: - DIRECTION' NB. Reverse direction when user clicks
|
||||
anim_close =: verb def 'wd ''timer 0; pclose; reset'' ' NB. Shut down timer
|
||||
anim_isi_paint =: verb define
|
||||
glclear '' NB. Clear out old drawing
|
||||
glrgb 255 0 0
|
||||
gltextcolor''
|
||||
glfont '"courier new" 36'
|
||||
gltext MESSAGE
|
||||
)
|
||||
|
||||
anim_run ''
|
||||
35
Task/Animation/Julia/animation-1.julia
Normal file
35
Task/Animation/Julia/animation-1.julia
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Tk
|
||||
|
||||
const frameinterval = 0.12 # partial seconds between change on screen display
|
||||
|
||||
function windowanim(stepinterval::Float64)
|
||||
wind = Window("Animation", 300, 100)
|
||||
frm = Frame(wind)
|
||||
hello = "Hello World! "
|
||||
but = Button(frm, width=30, text=hello)
|
||||
rightward = true
|
||||
callback(s) = (rightward = !rightward)
|
||||
bind(but, "command", callback)
|
||||
pack(frm, expand=true, fill = "both")
|
||||
pack(but, expand=true, fill = "both")
|
||||
permut = [hello[i:end] * hello[1:i-1] for i in length(hello)+1:-1:2]
|
||||
ppos = 1
|
||||
pmod = length(permut)
|
||||
while true
|
||||
but[:text] = permut[ppos]
|
||||
sleep(stepinterval)
|
||||
if rightward
|
||||
ppos += 1
|
||||
if ppos > pmod
|
||||
ppos = 1
|
||||
end
|
||||
else
|
||||
ppos -= 1
|
||||
if ppos < 1
|
||||
ppos = pmod
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
windowanim(frameinterval)
|
||||
35
Task/Animation/Julia/animation-2.julia
Normal file
35
Task/Animation/Julia/animation-2.julia
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using Gtk.ShortNames
|
||||
|
||||
const frameinterval = 0.12 # partial seconds between change on screen display
|
||||
|
||||
function textanimation(stepinterval::Float64)
|
||||
hello = "Hello World! "
|
||||
win = Window("Animation", 210, 40) |> (Frame() |> (but = Button("Switch Directions")))
|
||||
rightward = true
|
||||
switchdirections(s) = (rightward = !rightward)
|
||||
signal_connect(switchdirections, but, "clicked")
|
||||
permut = [hello[i:end] * hello[1:i-1] for i in length(hello)+1:-1:2]
|
||||
ppos = 1
|
||||
pmod = length(permut)
|
||||
nobreak = true
|
||||
endit(w) = (nobreak = false)
|
||||
signal_connect(endit, win, :destroy)
|
||||
showall(win)
|
||||
while nobreak
|
||||
setproperty!(but, :label, permut[ppos])
|
||||
sleep(stepinterval)
|
||||
if rightward
|
||||
ppos += 1
|
||||
if(ppos > pmod)
|
||||
ppos = 1
|
||||
end
|
||||
else
|
||||
ppos -= 1
|
||||
if(ppos < 1)
|
||||
ppos = pmod
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
textanimation(frameinterval)
|
||||
1
Task/Animation/Maple/animation-1.maple
Normal file
1
Task/Animation/Maple/animation-1.maple
Normal file
|
|
@ -0,0 +1 @@
|
|||
ScrollText(GP("Text",value),"Forward",65);
|
||||
1
Task/Animation/Maple/animation-2.maple
Normal file
1
Task/Animation/Maple/animation-2.maple
Normal file
|
|
@ -0,0 +1 @@
|
|||
ScrollText(GP("Text",value),"Reverse",65);
|
||||
18
Task/Animation/Maple/animation-3.maple
Normal file
18
Task/Animation/Maple/animation-3.maple
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty);
|
||||
SP("Text",value,"Hello World! ");
|
||||
ScrollText := proc( msg, direction::identical("Forward","Reverse"),n::posint:=20 )
|
||||
local word, count;
|
||||
word:=msg;
|
||||
count:=0;
|
||||
|
||||
while count<n do
|
||||
if direction = "Reverse" then
|
||||
word:=cat(word[2..-1],word[1]):
|
||||
else
|
||||
word:=cat(word[-1],word[1..-2]):
|
||||
end if;
|
||||
SP("Text",value,word,refresh);
|
||||
Threads:-Sleep(0.1);
|
||||
count:=count+1:
|
||||
end do:
|
||||
end proc:
|
||||
|
|
@ -1,55 +1,44 @@
|
|||
import pygame, sys
|
||||
from pygame.locals import *
|
||||
pygame.init()
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
|
||||
YSIZE = 40
|
||||
XSIZE = 150
|
||||
from PyQt5.QtCore import QBasicTimer, Qt
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QApplication, QLabel
|
||||
|
||||
TEXT = "Hello World! "
|
||||
FONTSIZE = 32
|
||||
|
||||
LEFT = False
|
||||
RIGHT = True
|
||||
class Marquee(QLabel):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.right_to_left_direction = True
|
||||
self.initUI()
|
||||
self.timer = QBasicTimer()
|
||||
self.timer.start(80, self)
|
||||
|
||||
DIR = RIGHT
|
||||
def initUI(self):
|
||||
self.setWindowFlags(Qt.FramelessWindowHint)
|
||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||
self.setText("Hello World! ")
|
||||
self.setFont(QFont(None, 50, QFont.Bold))
|
||||
# make more irritating for the authenticity with <marquee> element
|
||||
self.setStyleSheet("QLabel {color: cyan; }")
|
||||
|
||||
TIMETICK = 180
|
||||
TICK = USEREVENT + 2
|
||||
def timerEvent(self, event):
|
||||
i = 1 if self.right_to_left_direction else -1
|
||||
self.setText(self.text()[i:] + self.text()[:i]) # rotate
|
||||
|
||||
TEXTBOX = pygame.Rect(10,10,XSIZE,YSIZE)
|
||||
def mouseReleaseEvent(self, event): # change direction on mouse release
|
||||
self.right_to_left_direction = not self.right_to_left_direction
|
||||
|
||||
pygame.time.set_timer(TICK, TIMETICK)
|
||||
def keyPressEvent(self, event): # exit on Esc
|
||||
if event.key() == Qt.Key_Escape:
|
||||
self.close()
|
||||
|
||||
window = pygame.display.set_mode((XSIZE, YSIZE))
|
||||
pygame.display.set_caption("Animation")
|
||||
|
||||
font = pygame.font.SysFont(None, FONTSIZE)
|
||||
screen = pygame.display.get_surface()
|
||||
|
||||
def rotate():
|
||||
index = DIR and -1 or 1
|
||||
global TEXT
|
||||
TEXT = TEXT[index:]+TEXT[:index]
|
||||
|
||||
def click(position):
|
||||
if TEXTBOX.collidepoint(position):
|
||||
global DIR
|
||||
DIR = not DIR
|
||||
|
||||
def draw():
|
||||
surface = font.render(TEXT, True, (255,255,255), (0,0,0))
|
||||
global TEXTBOX
|
||||
TEXTBOX = screen.blit(surface, TEXTBOX)
|
||||
|
||||
def input(event):
|
||||
if event.type == QUIT:
|
||||
sys.exit(0)
|
||||
elif event.type == MOUSEBUTTONDOWN:
|
||||
click(event.pos)
|
||||
elif event.type == TICK:
|
||||
draw()
|
||||
rotate()
|
||||
|
||||
while True:
|
||||
input(pygame.event.wait())
|
||||
pygame.display.flip()
|
||||
app = QApplication(sys.argv)
|
||||
w = Marquee()
|
||||
# center widget on the screen
|
||||
w.adjustSize() # update w.rect() now
|
||||
w.move(QApplication.instance().desktop().screen().rect().center()
|
||||
- w.rect().center())
|
||||
w.show()
|
||||
sys.exit(app.exec())
|
||||
|
|
|
|||
|
|
@ -1,23 +1,55 @@
|
|||
import Tkinter as tki
|
||||
import pygame, sys
|
||||
from pygame.locals import *
|
||||
pygame.init()
|
||||
|
||||
def scroll_text(s, how_many):
|
||||
return s[how_many:] + s[:how_many]
|
||||
YSIZE = 40
|
||||
XSIZE = 150
|
||||
|
||||
direction = 1
|
||||
tk = tki.Tk()
|
||||
var = tki.Variable(tk)
|
||||
TEXT = "Hello World! "
|
||||
FONTSIZE = 32
|
||||
|
||||
def mouse_handler(point):
|
||||
global direction
|
||||
direction *= -1
|
||||
LEFT = False
|
||||
RIGHT = True
|
||||
|
||||
def timer_handler():
|
||||
var.set(scroll_text(var.get(),direction))
|
||||
tk.after(125, timer_handler)
|
||||
DIR = RIGHT
|
||||
|
||||
var.set('Hello, World! ')
|
||||
tki.Label(tk, textvariable=var).pack()
|
||||
tk.bind("<Button-1>", mouse_handler)
|
||||
tk.after(125, timer_handler)
|
||||
tk.title('Python Animation')
|
||||
tki.mainloop()
|
||||
TIMETICK = 180
|
||||
TICK = USEREVENT + 2
|
||||
|
||||
TEXTBOX = pygame.Rect(10,10,XSIZE,YSIZE)
|
||||
|
||||
pygame.time.set_timer(TICK, TIMETICK)
|
||||
|
||||
window = pygame.display.set_mode((XSIZE, YSIZE))
|
||||
pygame.display.set_caption("Animation")
|
||||
|
||||
font = pygame.font.SysFont(None, FONTSIZE)
|
||||
screen = pygame.display.get_surface()
|
||||
|
||||
def rotate():
|
||||
index = DIR and -1 or 1
|
||||
global TEXT
|
||||
TEXT = TEXT[index:]+TEXT[:index]
|
||||
|
||||
def click(position):
|
||||
if TEXTBOX.collidepoint(position):
|
||||
global DIR
|
||||
DIR = not DIR
|
||||
|
||||
def draw():
|
||||
surface = font.render(TEXT, True, (255,255,255), (0,0,0))
|
||||
global TEXTBOX
|
||||
TEXTBOX = screen.blit(surface, TEXTBOX)
|
||||
|
||||
def input(event):
|
||||
if event.type == QUIT:
|
||||
sys.exit(0)
|
||||
elif event.type == MOUSEBUTTONDOWN:
|
||||
click(event.pos)
|
||||
elif event.type == TICK:
|
||||
draw()
|
||||
rotate()
|
||||
|
||||
while True:
|
||||
input(pygame.event.wait())
|
||||
pygame.display.flip()
|
||||
|
|
|
|||
23
Task/Animation/Python/animation-3.py
Normal file
23
Task/Animation/Python/animation-3.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import Tkinter as tki
|
||||
|
||||
def scroll_text(s, how_many):
|
||||
return s[how_many:] + s[:how_many]
|
||||
|
||||
direction = 1
|
||||
tk = tki.Tk()
|
||||
var = tki.Variable(tk)
|
||||
|
||||
def mouse_handler(point):
|
||||
global direction
|
||||
direction *= -1
|
||||
|
||||
def timer_handler():
|
||||
var.set(scroll_text(var.get(),direction))
|
||||
tk.after(125, timer_handler)
|
||||
|
||||
var.set('Hello, World! ')
|
||||
tki.Label(tk, textvariable=var).pack()
|
||||
tk.bind("<Button-1>", mouse_handler)
|
||||
tk.after(125, timer_handler)
|
||||
tk.title('Python Animation')
|
||||
tki.mainloop()
|
||||
43
Task/Animation/Ring/animation.ring
Normal file
43
Task/Animation/Ring/animation.ring
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Project : Animation
|
||||
# Date : 2018/01/18
|
||||
# Author : Gal Zsolt [~ CalmoSoft ~]
|
||||
# Email : <calmosoft@gmail.com>
|
||||
|
||||
Load "guilib.ring"
|
||||
load "stdlib.ring"
|
||||
rotate = false
|
||||
|
||||
MyApp = New qApp {
|
||||
win1 = new qWidget() {
|
||||
setwindowtitle("Hello World")
|
||||
setGeometry(100,100,370,250)
|
||||
|
||||
lineedit1 = new qlineedit(win1) {
|
||||
setGeometry(10,100,350,30)
|
||||
lineedit1.settext(" Hello World! ")
|
||||
myfilter = new qallevents(lineedit1)
|
||||
myfilter.setMouseButtonPressevent("rotatetext()")
|
||||
installeventfilter(myfilter)}
|
||||
show()}
|
||||
exec()}
|
||||
|
||||
func rotatetext()
|
||||
rotate = not rotate
|
||||
strold = " Hello World! "
|
||||
for n = 1 to 15
|
||||
if rotate = true
|
||||
see "str = " + '"' + strold + '"' + nl
|
||||
strnew = right(strold, 1) + left(strold, len(strold) - 1)
|
||||
lineedit1.settext(strnew)
|
||||
strold = strnew
|
||||
sleep(1)
|
||||
ok
|
||||
if rotate = false
|
||||
see "str = " + '"' + strold + '"' + nl
|
||||
strnew = right(strold, len(strold) - 1) + left(strold, 1)
|
||||
lineedit1.settext(strnew)
|
||||
strold = strnew
|
||||
sleep(1)
|
||||
ok
|
||||
next
|
||||
see nl
|
||||
Loading…
Add table
Add a link
Reference in a new issue