KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

There is no Spoon ... continued
Goto page 1, 2  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> Fun & Games
View previous topic :: View next topic  
Author Message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 7:10 am    Post subject: There is no Spoon ... continued Reply with quote

Hi there,

as you can read in this topic : Its Coming! on korg I 'promised' to do some kforms tweaking on Shawn's Matrix emulator first posted here ... Thats what you get from that :

Code:
break on
; Matrix code emulation for KiXforms based on Shawn's console sample
; Requires:
;   KiXtart  4.10
;   KiXforms 2.3.0 (build 38)

global $greenie[15,2], $blankie[15,2], $t, $S

$v    = '0.9'
$vMin = 0.09    ;delay for slowest
$vMax = 0.04    ;delay for fastest
$ini  = @scriptdir + "\matrix.ini"

srnd(@msecs)

if not exist($ini)
    $t = $vMin
    $S = 0
else
    $S = val(readprofilestring($ini,"Speed","Value"))
    $t = (cdbl(101-$S) * $vMin - $vMax) / 100
endif

$f                    = createobject("KiXtart.Form")
$f.Caption            = 'Matrix Code Emulator for KiXforms ' + $v
$f.Size               = 635,485
$f.MinSize            = 400,300
$f.BorderStyle        = 2
$f.Resizable          = 0
$f.Backcolor          = 'Black'
$f.FontName           = 'Courier New'
$f.ForeColor          = 'Lime'

$tmr                  = $f.timer
$tmr.Interval         = $t * 3000
$tmr.OnTimer          = "f_timer($$tmr.Interval)"

$grpSpeed             = $f.GroupBox("Speed",5,0,140,32)
$grpSpeed.ForeColor   = 'Lime'
$grpSpeed.BorderStyle = 1

$sld                  = $grpSpeed.Slider(,10,18,120,10)
$sld.Value            = $S
$sld.Max              = 99
$sld.Tooltip          = 'Accelerate: ' + $sld.Value + '%%'
$sld.OnChange         = "sld_Change($$sld.Value)"
$sld.OnScroll         = "sld_scroll($$sld.Value)"

$lblSep               = $f.Label('',1,38,$f.ClientWidth-2,2)
$lblSep.BorderStyle   = 5

$Matrix               = $f.ListView ;Yes, it is a listview :D
$Matrix.Location      = 0,42
$Matrix.HeaderStyle   = 0
$Matrix.BorderStyle   = 0
$Matrix.BackColor     = 'Black'
$Matrix.FontName      = 'Comic Sans MS'
$Matrix.FontSize      = 8
$Matrix.FontBold      = 1
$Matrix.ForeColor     = 'Green'
$Matrix.Size          = $f.ClientWidth, $f.ClientHeight - 42
$Matrix.Columns.Count = $Matrix.ClientWidth / 11.5
for each $column in $Matrix.Columns
    $column.Width = $Matrix.ClientWidth / $Matrix.Columns.Count
next
$MatrixCols           = $Matrix.Columns.Count
$MatrixRows           = $Matrix.ClientHeight / 18.7
for $i = 0 to $MatrixRows
    $_ = $Matrix.Items.Add("")
next

for $i = 0 to 15
    $greenie[$i,0] = rnd($MatrixRows+1)
    $greenie[$i,1] = rnd($Matrix.Columns.Count+1)
next

for $i = 0 to 15
    $blankie[$i,0] = rnd($MatrixRows+1)
    $blankie[$i,1] = rnd($Matrix.Columns.Count+1)
next

$f.Center
$f.Show
while $f.visible
 $ = execute($f.DoEvents)
loop

exit 1

function f_timer($t)
    for $i = 0 to 15
        $Matrix.ForeColor = 'Green'
        $c=rnd(100)+100
        if $c=7 or $c=149
            $c=150
        endif
        if $greenie[$i,0]
            $Matrix.Items($greenie[$i,0]).Subitems($greenie[$i,1]).Text = chr($c)
        endif
        if $greenie[$i,0] < $MatrixRows + 1
            $greenie[$i,0] = $greenie[$i,0] + 1
            $Matrix.ForeColor = 'Lime'
            $Matrix.Items($greenie[$i,0]).Subitems($greenie[$i,1]).Text = chr($c)
        else
            $greenie[$i,0] = rnd(9)
            $greenie[$i,1] = rnd($MatrixCols + 1)
        endif
        sleep $t
    next
    for $i = 0 to 15
        $Matrix.Items($blankie[$i,0]).Subitems($blankie[$i,1]).Text = ""
        $blankie[$i,0] = $blankie[$i,0] + 1
        if $blankie[$i,0] = $MatrixRows + 1
            $blankie[$i,0] = 0
            $blankie[$i,1] = rnd($MatrixCols + 1)
        endif
        sleep $t
    next
    sleep $t
endfunction

function sld_scroll($v)
    $sld.ToolTip  = 'Accelerate: ' + $v + '%%'
    $t = (cdbl(101-$v) * $vMin - $vMax) / 100
    $_ = writeprofilestring($ini,"Speed","Value",$v)
    $tmr.Interval = $t * 3000
endfunction


It's not perfect and if you accelerate over 60 to 70% it is (still) quite a CPU hog Rolling Eyes

Please feel free to improve the code, but please no KiXgolfing Shocked (keep it readable!), or just add some new features like selectable fonts or Resizability Wink

I will step back for some days and wait for improvements ...

Have fun !

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
ntdoc
KiXforms Supporter
KiXforms Supporter


Joined: 05 Mar 2003
Posts: 77
Location: Mouse Country

PostPosted: Wed Apr 16, 2003 8:34 am    Post subject: Reply with quote

Jochen,

I notice you have a matrix.ini file but I don't have one, and don't know what or how you want it populated.

I'm getting an error on line 40 which is:
$grpSpeed = $f.GroupBox("Speed",5,0,140,32)

ERROR : expected expression!
Script: C:\SCRIPTS\frmMatrixReloaded.kix
Line : 40

I'm using the latest beta version of KiXforms and KiXtart v4.21-RC2
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Apr 16, 2003 8:38 am    Post subject: Reply with quote

damn!

for all tryers, it requires the new beta of KF

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 8:41 am    Post subject: Reply with quote

Dang !

I forgot to mention that you would need the private build Shawn sent to some which is soon to be released Embarassed
I'll send it to you (Anyone who wants to try this before release of the next KiXforms build can send me a short email and I'll reply)

the ini file is auto-created by the way ...

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Apr 16, 2003 8:48 am    Post subject: Reply with quote

sure send it!

dang, f*ck...

pretty frustrating Crying or Very sad

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ntdoc
KiXforms Supporter
KiXforms Supporter


Joined: 05 Mar 2003
Posts: 77
Location: Mouse Country

PostPosted: Wed Apr 16, 2003 8:58 am    Post subject: Reply with quote

Got the file Jochen. Thanks. Works well on my home system.

I changed line 102 to this
$Matrix.ForeColor = 'White'

Which is more like the program looks like in the trailers.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Apr 16, 2003 9:44 am    Post subject: Reply with quote

I changed it little more to my liking...

anyway, the listview might be not the best solution.

so, here:
Code:
break on
; Matrix code emulation for KiXforms based on Shawn's console sample
; Requires:
;   KiXtart  4.10
;   KiXforms 2.3.0 (build 38)

global $greenie[15,2], $blankie[15,2], $t, $S

$v    = '0.9'
$vMin = 0.09    ;delay for slowest
$vMax = 0.04    ;delay for fastest
$ini  = @scriptdir + "\matrix.ini"

srnd(@msecs)

if not exist($ini)
    $t = $vMin
    $S = 0
else
    $S = val(readprofilestring($ini,"Speed","Value"))
    $t = (cdbl(101-$S) * $vMin - $vMax) / 100
endif

$f      = createobject("KiXtart.Form")
$f.Caption   = 'Matrix Code Emulator for KiXforms ' + $v
$f.Size      = screenres
;$f.MinSize   = 400,300
$f.BorderStyle   = 0
$f.Resizable   = 0
$f.Backcolor   = 'Black'
$f.FontName   = 'Courier New'
$f.ForeColor   = 'Lime'
$f.topmost   = 1

$tmr                  = $f.timer
$tmr.Interval         = $t * 3000
$tmr.OnTimer          = "f_timer($$tmr.Interval)"

$grpSpeed             = $f.GroupBox("Speed",5,0,140,32)
$grpSpeed.ForeColor   = 'Lime'
$grpSpeed.BorderStyle = 1

$sld                  = $grpSpeed.Slider(,10,18,120,10)
$sld.Value            = $S
$sld.Max              = 99
$sld.Tooltip          = 'Accelerate: ' + $sld.Value + '%%'
$sld.OnChange         = "sld_Change($$sld.Value)"
$sld.OnScroll         = "sld_scroll($$sld.Value)"

$lblSep               = $f.Label('',1,38,$f.ClientWidth-2,2)
$lblSep.BorderStyle   = 5

$Matrix         = $f.ListView ;Yes, it is a listview :D
$Matrix.Onclick      = '$$f.hide'
$Matrix.Location   = 0,42
$Matrix.HeaderStyle   = 0
$Matrix.BorderStyle   = 0
$Matrix.BackColor   = 'Black'
$Matrix.FontName   = 'Comic Sans MS'
$Matrix.FontSize   = 8
$Matrix.FontBold   = 1
$Matrix.ForeColor   = 'Green'
$Matrix.Size      = $f.ClientWidth, $f.ClientHeight - 42
$Matrix.Columns.Count   = $Matrix.ClientWidth / 11.5
for each $column in $Matrix.Columns
    $column.Width = $Matrix.ClientWidth / $Matrix.Columns.Count
next
$MatrixCols      = $Matrix.Columns.Count
$MatrixRows      = $Matrix.ClientHeight / 18.7
for $i = 0 to $MatrixRows
    $_ = $Matrix.Items.Add("")
next

for $i = 0 to 15
    $greenie[$i,0] = rnd($MatrixRows+1)
    $greenie[$i,1] = rnd($Matrix.Columns.Count+1)
next

for $i = 0 to 15
    $blankie[$i,0] = rnd($MatrixRows+1)
    $blankie[$i,1] = rnd($Matrix.Columns.Count+1)
next

$f.Center
$f.Show
while $f.visible
$ = execute($f.DoEvents)
loop

exit 1

function f_timer($t)
    for $i = 0 to 15
        $Matrix.ForeColor = 'Green'
        $c=rnd(100)+100
        if $c=7 or $c=149
            $c=150
        endif
        if $greenie[$i,0]
            $Matrix.Items($greenie[$i,0]).Subitems($greenie[$i,1]).Text = chr($c)
        endif
        if $greenie[$i,0] < $MatrixRows + 1
            $greenie[$i,0] = $greenie[$i,0] + 1
            $Matrix.ForeColor = 'Lime'
            $Matrix.Items($greenie[$i,0]).Subitems($greenie[$i,1]).Text = chr($c)
        else
            $greenie[$i,0] = rnd(9)
            $greenie[$i,1] = rnd($MatrixCols + 1)
        endif
        sleep $t
    next
    for $i = 0 to 15
        $Matrix.Items($blankie[$i,0]).Subitems($blankie[$i,1]).Text = ""
        $blankie[$i,0] = $blankie[$i,0] + 1
        if $blankie[$i,0] = $MatrixRows + 1
            $blankie[$i,0] = 0
            $blankie[$i,1] = rnd($MatrixCols + 1)
        endif
        sleep $t
    next
    sleep $t
endfunction

function sld_scroll($v)
    $sld.ToolTip  = 'Accelerate: ' + $v + '%%'
    $t = (cdbl(101-$v) * $vMin - $vMax) / 100
    $_ = writeprofilestring($ini,"Speed","Value",$v)
    $tmr.Interval = $t * 3000
endfunction


;Function:
;   ScreenRes()
;
;Author:
;   Lonkero
;
;Version:
;   1.0.1 (28.11.2002)
;
;Action:
;   retrieves screen resolution (pixels)
;
;Syntax:
;   ScreenRes
;
;Parameters:
;   optional destination
;
;Remarks:
;   Saw the getscreenres() function and decided to make it little bit shorter
;
;Returns:
;   2 element array with elements:
;      0 - screen width
;      1 - screen height
;
;Dependencies:
;   WMI
;
;Examples:
;1:   $Resolution=ScreenRes
;   "your Screen are is "
;    $Resolution[0] "x" $Resolution[1]
;
;2:   "your screen resolution is:"
;   join(screenres,"x")
;
;Source:
function ScreenRes(optional $)
 if not ""+$ $="." endif
 For each $ in GetObject("winmgmts:\\"+$+"\root\cimv2").ExecQuery("Select * from Win32_DesktopMonitor",,48)
  $ScreenRes=$.ScreenWidth,$.ScreenHeight
 Next
endfunction

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Apr 16, 2003 9:50 am    Post subject: Reply with quote

btw, the speed seems to have no effect in your script.

also, the lines where the text is... it's not changing but some lines are static.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 9:58 am    Post subject: Reply with quote

Thats an effect of the sld_scroll() ... If you start at 0 and scroll slooowly to the region of 30-40 you'll see that it does have an effect (depends somehow on the hardware used ) ,
BUT, if you pass the point were it gets a real hog it just sticks to that speed (doesn't even update the ini !)

Whatsoever ... This is only a 1 to 1 adaption of Shawn's console code yet, so there is plenty of room for improvement Razz

Got some things in mind right now (even FullScreen mode) but will as stated step back from excessive coding to see if there are other ideas as well Wink

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Wed Apr 16, 2003 10:03 am    Post subject: Reply with quote

if you see my script, it has fullscreen mode already Very Happy
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 10:12 am    Post subject: Reply with quote

I saw that ... but, what I have in mind was ....

oops, that's a secret for after easter holidays Cool

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Apr 16, 2003 12:00 pm    Post subject: Reply with quote

Jochen, got an issue here. Your matrix script (using the ListView) is actually exploiting a BUG in kixforms. And coincidently I just happened to be working on the problem yesterday when you gave me the script for the first time.

When the ForeColor is changed for a ListView, i had to change things so that a repaint/refresh is performed. It doesn't refresh by default, which is kinda what your script is relying on - unfortunately with the fixed version, I can't think of a way to re-break it (if you know what I mean) or emulate the mode that matrix requires. Either we think of one, or your going to have to search for a new way to code the matrix Sad

-Shawn
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 12:03 pm    Post subject: Reply with quote

I'd take then the second path, allthough it would be nice to have 'cells' in ListViews totally independant from each other ... knowhwhatimean ? Nudge Nudge Wink

Hrmmm ... PrintXY Evil or Very Mad That'd be a retrogression to the days of KiXbgi Rolling Eyes

Still valid : This code is NOT mine so please if anybody wants to, improve it !

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Wed Apr 16, 2003 12:16 pm    Post subject: Reply with quote

Sadly that aint possible with the Windows ListView ... it will be possible with the ListGrid or the DataGrid custom control but that would be much further down the road. Sad
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Wed Apr 16, 2003 12:58 pm    Post subject: Reply with quote

Oh yeah, now I see what you meant with BUG ... It was a BUG that was not fixed with that private build but WILL BE within the released Exclamation


Hehe, I was actually quite surprised (Back in rear gray matter !) when the code worked as I 'hoped' and not wasted a second thought on it, even when you showed me with the sample that this IS currently a bug Rolling Eyes

Tell you what ... Will try to get the best out of it Cool But still PrintXY on a form is a frickin PAIN !!!

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Fun & Games All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group