Hecl Builder
Easy Mobile Applications
2DTHINGCOPY

Average rating:
MIDP Version: 1.0
Description: Just a copy
Last updated: Mon Oct 06 02:25:05 +0000 2008 by
Bluedove2897
#-- start
set canvas [lcdui.canvas -title "2D Transformation" -autoflush 1 -fullscreen 1];
set p 0
set x 0
set y 0
set px 0
set py 0
set rot 0
set p_rot 0
set Xmax [$canvas cget -width]
set Ymax [$canvas cget -height]
#-- define the logo lable HECL
set logo [list]
#-- H
set sx [list [list 35 10] [list 35 -10] [list 35 0] [list 20 0] [list 20 10] [list 20 -10]]
set rx [list [list 35 10] [list 35 -10] [list 35 0] [list 20 0] [list 20 10] [list 20 -10]]
set index [llen $sx]
lappend $logo [list $sx $rx $index]
#-- E
set sx [list [list 5 10] [list 15 10] [list 15 0] [list 5 0] [list 15 0] [list 15 -10] [list 5 -10]]
set rx [list [list 5 10] [list 15 10] [list 15 0] [list 5 0] [list 15 0] [list 15 -10] [list 5 -10]]
set index [llen $sx]
lappend $logo [list $sx $rx $index]
#-- C
set sx [list [list -15 10] [list -5 10] [list -5 -10] [list -15 -10]]
set rx [list [list -15 10] [list -5 10] [list -5 -10] [list -15 -10]]
set index [llen $sx]
lappend $logo [list $sx $rx $index]
#-- L
set sx [list [list -25 -10] [list -25 10] [list -35 10]]
set rx [list [list -25 -10] [list -25 10] [list -35 10]]
set index [llen $sx]
lappend $logo [list $sx $rx $index]
proc rotate_dot {tr winkel sx rx} {
global x y
set r0 0
set r1 0
set beta [toRadians $winkel]
set r0 [- [- $x [* [- [lindex [lindex $sx $tr] 0] $x] [cos $beta]]] [* [- [lindex [lindex $sx $tr] 1] $y] [sin $beta] ]]
set r1 [+ [- $y [* [- [lindex [lindex $sx $tr] 1] $y] [cos $beta]]] [* [- [lindex [lindex $sx $tr] 0] $x] [sin $beta] ]]
lset $rx $tr [lset [lindex $rx $tr] 0 $r0]
lset $rx $tr [lset [lindex $rx $tr] 1 $r1]
}
$canvas setcurrent
set g [$canvas graphics]
while {true} {
set starttime [clock seconds]
$g color blue
$g frect [list 0 0] [list $Xmax $Ymax]
$g color white
$g line [list [/ $Xmax 2] [/ $Ymax 2]] [list [/ $Xmax 2] [/ $Ymax 2]]
set rot [% [+ $rot [+ $p_rot 360]] 360]
set winkel [% [- 360 $rot] 360]
set beta [toRadians $winkel]
set r0 [- [* [* 2 [- 0 $px]] [cos $beta]] [* [* 2 [- 0 $py]] [sin $beta]]]
set r1 [+ [* [* 2 [- 0 $py]] [cos $beta]] [* [* 2 [- 0 $px]] [sin $beta]]]
set x [+ $x $r0]
set y [+ $y $r1]
foreach e $logo {
set sx [lindex $e 0]
set rx [lindex $e 1]
set index [lindex $e 2]
for {set p 0} {< $p $index} {set p [+ $p 1]} {
rotate_dot $p $rot $sx $rx
}
for {set p 0} {< $p [- $index 1]} {set p [+ $p 1]} {
$g line [list [+ [- [/ $Xmax 2] $x] [lindex [lindex $rx $p] 0]] [+ [- [/ $Ymax 2] $y] [lindex [lindex $rx $p] 1]]] \
[list [+ [- [/ $Xmax 2] $x] [lindex [lindex $rx [+ $p 1]] 0]] [+ [- [/ $Ymax 2] $y] [lindex [lindex $rx [+ $p 1]] 1]]]
}
}
$g string [list 5 5] "[- [clock seconds] $starttime] FPS "
#-- set rotation factor
set p_rot -10
$canvas flush
}