Thursday, 12 July 2012

All VID Styles

Here is a script that shows all VID styles, first of all a mega screenshot of it, than the real screenshot, then the source.
Here the a big screen shot of all VID styles, this is a collage, the real window si smaller with a scroller (go to the picasa link to see it full size):
Da Rebol

Then the real screenshot:

Da Rebol


Then the source:

Rebol[]
view/title layout/size [
    style draw-button box 12x12 effect [draw [pen black fill-pen red circle 6x6 5]]
    a: panel [
        across
        tabs 14
        text italic bold "You 'll find in this window all standard VID style sorte alphabetically."
        return
        text italic bold "The red circle indicate a style."
        return
        draw-button  
        panel     [
           
            backdrop http://www.rebol.com/view/nyc.jpg
            vtext "This is the backdrop effect."
            vtext "Image is scaled to fit the current window or panel"  
            ]
        return  
        tab
        text   "This is the (backdrop). Image is scaled to fit the current window or panel."
        return
        tab
        text "It's better to use as first object of a pane, since all previous objects are covered"
        return draw-button      
        panel   [
            backtile logo.gif
            vtext red "This is the backtile effect"
            vtext red "Image is repeated to fit the current window or panel"        
            ]
        return  
        tab
        text "This is the backtile effect. Image is repeated to fit the current window or panel"
        return
        tab
        text "It's better to use as first object of a pane, since all previous objects are covered"
        return draw-button      
        anim rate 1 frames   [http://www.rebol.com/view/nyc.jpg   http://www.rebol.com/view/bay.jpg]
        text "This is an animation (anim)"
        return draw-button
        area "This is area text (area)"
        return draw-button
        arrow
        arrow right
        arrow left
        arrow down
        text "These are arrows (arrow)"
        return draw-button
        banner "This is the banner text (banner)"
        return draw-button
        bar
        text "This is a bar (bar)"
        return draw-button
        base-text "This is a base-text (base-text)"
        return draw-button
        body "This is a body text (body)"
        return draw-button  
        box "This is a box (box), you can specify size and color"
        box red "Box red"
        return draw-button  
        btn "This a button (btn), it automatically fits the text"
        return draw-button  
        btn-cancel   text "This is a button for cancel, you can change text and color (btn-cancel)"
        return draw-button  
        btn-enter text "This is a button for enter, you can change text and color (btn-enter)"
        return draw-button  
        btn-help text "This is a button for help, you can change text and color (btn-help)"
        return draw-button  
        button text "This is a button that doesn't resize automatically (button)"
        return draw-button  
        check text "This is a check (check)"
        return draw-button  
        TAB
        check-line   "This is a check (check-line). You can add directly text"
        return
        tab TAB check-line "It's useful to align many checks"
        return draw-button  
        check-mark text "This is a check (check-mark)"      
        return draw-button  
        choice data   ["a" "b" "c"]
        text "This is a coiche button (choice)"
        return draw-button  
        code "This is code text (code)"
        return draw-button  
        drop-down data   ["a" "b" "c"]
        text "This is a drop-down button (drop-down)"
        return draw-button      
        field "This is a field (field)"
        return draw-button  
        h1 "This is (h1) text"
        return draw-button  
        h2 "This is (h2) text"
        return draw-button  
        h3 "This is (h3) text"
        return draw-button  
        h4 "This is (h4) text"
        return draw-button  
        h5 "This is (h5) text"
        return draw-button  
        tab icon
        text "This is an icon (icon), you can choose image and add a caption anc click it"
        return
        tab tab
        icon logo.gif "Click here"
        return draw-button  
        image logo.gif
        text "This is an (image)"
        return draw-button  
        info "This is an info field (info), not editable, but it's easy for copy and paste"
        return draw-button  
        text "Press e key (key)"
        key #"e" [alert "You pressed the e key, you can assign any action to the keys with the (key) function"]
        return draw-button  
        lab "123456789012345678"
        text "It's the label text (lab), fixed size. Useful for field label"
        return text "it contains approximately 18 characters"
        return draw-button  
        label "This is the label text (label). Useful for field label"      
        return draw-button  
        lbl "This is the labet text (lbl). Useful for field label"
        return draw-button  
        led
        text "This is a (led), you can light it"
        led true
        return draw-button  
        list 100x60   [across check text "Example" ]
        text "This is a (list), it repeats the layout in order to fill the size indicated"
        return draw-button          
        logo-bar
        text "This is a logo bar (logo-bar)"
        return draw-button
        panel yellow   [
            button "Example"
           
            text "This is a (panel). Very useful to arrange and modify layouts"
            ]
        return draw-button  
        progress 0.3
        text "This is a (progress) bar"
        return draw-button  
        radio radio radio text "This are radio check button (radio). You can chaek only one per panel"
        return draw-button  
        radio-line   radio-line "This are radio check button (radio-line). "
        return
        draw-button        
        tab
        radio-line "You can directly add text, useful to align text and check."
        return
        tab tab
        radio-line "You can check only one per panel. Do you see it?"
        return draw-button  
        rotary data [$1 $2 $3 ] Text "This is a rotary button (rotary), click to see the effect"
        return draw-button  
        scroller
        text "This is a scroller (scroller)"
        return draw-button  
        slider text "This is a slider (slider)"
        return draw-button  
        text "this is normal text"
        return draw-button  
        text-list data ["One" "Two" "Three" ]
        text "This is a (text-list)."
        return draw-button  
        title "This is a title text (title)"
        return draw-button  
        tog "This is a toggle button (tog), it has auto resize. If pressed, it remains pressed"
        return draw-button  
        toggle
        text "This is a toggle button (toggle). If pressed, it remains pressed"
        return draw-button  
        tt "This is typewriter text (tt)"
        return draw-button  
        txt "This is (txt) text"
        return draw-button  
        vh1 "This is (vh1) text"
        return draw-button  
        vh2 "This is (vh2) text"
        return draw-button  
        vh3 "This is (vh3) text"
        return draw-button  
        vh4 "This is (vh4) text"
        return draw-button  
        vlab "Vlab"
        text "This is the (vlab) text"
        return draw-button  
        vtext "This is the (vtext)"    
        ]
        return  
        scroller 20X450 [
            a/offset/y:   to-integer ( 20 - (face/data * (a/size/y   - 460) ))  
            show a
            ]
]   600x500 "VID styles"

Wednesday, 11 July 2012

One thousand cows happily dying

Here a script that shows 1000 of animation on the same window with Rebol!!!!
Here the source:

rebol [
    Title: "1000 Cows"
    Date: 4-Jan-2008
    Purpose: "To measure update speed when 1000 Gobs are animated in a window."
]
cowcount: 1000
krava: context [
imags: reduce load decompress #{
789CED9DCD8EDB461084EF7C8A0DF202426204B907D897307CF0C13082C0F700
41DE3DF0925ED5B0A79ADDE4903352AA1710762915A7BFF91335534B7DFCF6F9
AF2F2F7F7EFBFCF5CB4F2F1F3FFCF2F7AFBFBDFCFCCFF47A2024965862892596
B8B9F8F7DBF79F390AF10DE294927B8B919C8A23B5F040CC8578A69AAB81BDC8
768F16258F218EF4EDA293F8559528B9B798B56A458C0320CB3F143306F2DB98
D81311FE6199E7483363F44BFB909832CF6DF9C76DFD331FC747CBFF70CC33C8
843C73C4F927BF1B3448FB9078839951612DD8D74C33F1FD716B30A4D3DE2966
B433C8E4B7A7AD85FBEFEFCC78687DE4BAC9A03672D7CC453B47FA33EDDB96D6
EF36AD99239C156646EEF33B6F745E8515E206CC48EE27BCF46DFFE90D667F5A
6775511955B61BA4996D99741ACAF66ACAECF3DBBC264C6CFEF92EFFB03CFAA7
48CC61166DA36F87987D194BBEFA31E1CE8CE4F61489C9C092B7EBDB59FEE047
E03AF9CE09B0E86138DC1AF4ED087F620E5B4F0BCE9A41248A4516FC3D947683
81C17A6F28ED43CC1871FE89F5DE087FA593C4C9CFB988B3F56FFB3F9DF46D67
B443A8D2CE71FE6B2FD6F148E5FD995F7BE194FC56320A58C5D892AF62C6C02C
8AC920C28FE4135680E5F48F775F7DF493648D37954D1FE52F66921ECCF84784
1F8F4FAC0344F88B8B38DBF513696763E7D5101D1825FF1C6BFEA59D590788F0
F718180BB34D32CE4FDB99758C0669B713EF4BBE32AAE2A7E8CE8C7133C18E87
2E2BD829865DC6F393AFBC63C44F5159EA689676423CFDFBE945062189259658
6289251E401CB9281830ED06629F7CE3E3EAA192C7105B9CF485F5CE92C7102F
17D659417161BDAFE441C4D94F02C5279143258F218E8FEAE77485DA518D2123
5820AE4DFB90B8D6906F62FC23B2B786E4C33233DA6215DC3EEDF32F9DE4C4B4
D362BF7B524FC07A9FA1E6FAC1E393BF789A4E7BA738C219DA2B8EF04FF68938
FF39EDEC6F71874C146C3F316428F0F9CFFF8042B7B8B33E808A0F621FF95573
98456BE183F0AD0476EA3B9FD9F2173E8888D325C41CDB56BFFB7D7A5CF51625
473A698299F770B3B9BE8FFCE10C4295DA2E3BC635CC18717E1984AA6FEBB528
98D9D8F2F965103A831903B390418824C91A4F062119846410AAF0CB20943C45
77668C9B09765C06A1E4296410925862892596586289255E47E59AE9A2927B8B
1317D68D4B1E443CB3FD1FEF14855411D7C7462749943C86D8DE2969431CAFAA
8D92C710EB4E51616616D7A67D485C6BC83731FE11D95B43F26199196DB10A6E
9FF6F9974E7262DA69B1DF3D2BDB80967C6ECDF991D5C220AB6611CED05EF11C
F7DFAD0FA83008DDABE97A6624F7B7B843260ABFDA26AC802CFF431884E8C0D8
328E5CC93C872547B4B40F024F57A9B0FAC4D073ABC4921F3308FDE0B9EF1B32
F231DEE896A6F247ACFF583114D85A401F50B5C22E642EC4583EA6E7F7F68D81
616BA11818F1A17F0E33469C3F6D102A986DD3C7C965106AC58CC1F865100AF0
CB202483900C42EF083208C920F4BAEF14DD99316E26D871198492A790414862
892596586289256E208E5F510C95F621718DB9E93DE507145B665CA32C9662F6
5D5E9E93762466A3C3F2CD68D6F560992B9B71B61AE2FC832C3F6D47B97B5AF9
760A360C5AA77D481CE75D2F39BE96DF2AC4566419F920E399A5C76A21743389
C199595066BF1B602FB0E40FC74CB74AEA7B2E35C7C0B0CC8CB698B7D9AE92BF
F334D40A12EBC9B60B6F7CAB10E32F98F7910F6810623BC678BA4198E7C086F1
5D122113058B8DAF184BA7DD406C3B66A59D7DCB40C24491E57F208350623218
63ABC4920FF815638D993196211999E8D27D3BC2DFFD8D0ECB47FE8DB41B0C8C
7D53FF031984363A499C5C06A156CC188C5F06A100BF0C423208C920F48E2083
900C42AFFB4ED19D19E366821D974128790A1984249658628925965862892596
58628925DE12B39B67F91F26BBA7DD40CCC83142CB12E9924F11DB35808D9585
F9887FBFA829524987D2DE29B69C1B0621B6F2BE5172F62E6CC31A84CAC775A3
8696DC18FFE00621C69FBE9D18F20F6E10A2159665C678068390A50AB911E697
366366E458FE9906219F9F1A0A22B5F07006A1A56FB373CFC4F7C75A2D3CB641
084B465AEF489BC9006B12B3080DC94303C34E03D8B248BB214E3363C4F9CF37
08B15E788EBDD25661A5E4C8EC6583365524F9F9786560D85C582F781E8310BE
14C9B1E425ED08333BF5E006A15A6D1FFF8739D601228D77AD4168D554D17F15
AB30B3B34692EF6E10B24D9266F6C3E62883103C11E1974128798AEECC186C84
D9E33208254F218390C4124B2CB1C4124B2CB1C4124B2CB1C4124BFC8462BBE2
515904DAB7143414B3CF39C7C63660A4160661F609D3FBE37E5D145F3E6A2BC9
AFBC010D4221434159AB233824B104BAC5EDEF80270C05B57DE35E0E494B8EC9
270C7F1543417C486CA47DA243D292A73D3EC5C0B04F73D9080EC965549525AC
D9427E977CB50DE190C40640FEC478662F65C7877248C6F9D306213AAACAF60C
D736A67A88196919FF5506215685E75F4A31FE6B0D4218D421997EC7C8F27737
08AD9FE60EC18A785F0C65105A9765FDA03F1EDB6DAE47F8F1F8F906215BDBF0
8E61ABE4490D42456DB3375AFF148F6D10C253B01F7B8AE73108DD206AE3EC80
2B94A66D4BB6C9639C6F1062FC8543B201733CF96B0D42950ACB9EA2C22C8390
C4124B2CB1C4124B2CB1C4178BED556CB10D7862C9FDC494795F3C0473426C09
37F659E2557566DACDC4B49D232BA2B82CD2EEDF27B382B49832DB6EE0F35736
20F7FD13650F66BA55C2F70DD78FC37EDF20A32D9A8AED2AD597FCDE57C15907
B06B64E733B39E8CCCB4A970A5D06FFFCA2A385B17B62D3F8841C8AF2A1B1BF7
4660B4AD9991DC1F9274F732D2540B73A46212691F6246729FBFF51D84E2FB3C
57CD619521C9DA76E7BC6D658CFFDA0B57CC4E5F3116EED59439CEDFFD7FA9B1
7CE4DF48BBC1C0884C77E73063C4F9F51563C0C6DEB7F014FA8A315231B6E4AB
9831308BEE06A17DF13C06A1AB98F18F083F1EEF7E07A17DF17006A174DACDC4
0BB34D32CEAF3B08254FD19D19E366821D3FDF209448BB99D84FFE49EE20F4E9
3F8F0ADC94E8FC0000
}

explosion: reduce load decompress #{
789CED9D418EE4B81145F73A451BBE40C21E18B31FA02F3198C52C068661CCDE
80E1BB1B5D52B5828CF8C1088A12A5ECCF02B2AA94F9C578C1205329FEAEFEF5
CFDFFFFDC7977FFDF9FB3FFFF8CB975F7FFADB7FFEFE8F2F7FFDEFF2F540A398
628A29A698E2E1E29F5FDFBED656885FA29DD2F36CB12487E248161EC45C8857
AA350DE845BA3C46F47C0F71A4B68B22F15395E879B6188DAA21961320CB7F2B
66D924BF6E0B7A22C27F5BE6B5A599659B17F62131645EC7F29757FDB51E978F
9AFF71CC2BC82279D6E6F3AFDCEBE3E215C190B00F891BCC6854657DCBC74DAC
9FF027433AEC4E31A25D8770F1EBD9CE4235CEBA0022FCA39935A7662EC63932
9F35BF31CE91B219CD1CE1349811B9CFEFBCD179092BC4039825B91FF056DBFE
D30D667F5947B93066952E8334B3EE1305BFC447B5C1ECF3EBB81619D8FAF54D
FED3F6E89F22B18669B4466D8798DB6F6E56F0E6C7849D5992EB532416034D3E
AEB6B3FCC18FC03679E7025854989C6E036A3BC29F58C3EA65C1B9671069C54D
16F97328EC011303556F28EC43CCB2C5F91754BD117EA348E2E4E75CC4E9FCEB
FA878BBE2E463D858C718EF35F7BB12E8F18EFCFF8DA4B2EC91F3D4B014A8CEE
F92A66D96414C56210E197E48B4C80E6F48F4FBFFBE80789066F29873ECA5FAC
243398E52F117E797C410510E12F2EE274E927C2CEB6CEAB2138314AFEB5D5FC
DB38A30288F0CF98181BB30E32CE0FC71915C680B0C789FB82376655FC14D399
657BA9868E872E2BD029467F721F26F68337DE31E2A7306E750C0B3B215EFEF7
DB171A8428A698628A297E809806A1F005D7B09E6F225EA96810F21A0D42A2D1
204483D09CB00F8921737C8765A5978F8F6386DB069A0D9117268A53C23E246E
30A34D22CD2FB3000C4203C3EE1423DAE22E7864C7D0A86D99009B9F06219905
1A848E304B723FE0D1260A8D807261CC2A5D066966DD27DCE2CE5675637F3CB2
4B2C26060D423408ED59D0E43408251B0D425FF728E4CF088A0621C1A68B514F
211A84406274CF5731CB26A3A041080489068F06211A84681032F869104A9E62
3AB36C2FD5D0711A8492A7A04188628A29A698628A69108A341A843E1A0D425E
A34148341A847E4C831072095C17F621B1CB8CD9F6BB098E89E2C4B00F89ADE2
FD10D7F75F33FC46C206877D48DC60B637895AFC9529AA4EDB80B03BC588B6B8
0BEEEF1822B4804108F33FC820D4A8ED36FF3B188470E937369A65020E314B72
3FE0D1260A8D80326FCC2AD93A99759F708B3BEB03089928FCE0D76769107A7D
4E0A1A846810DA1B0D427DCCB2C5F96910126CBA18F514A241082446F77C15B3
6C320A1A84409068F06810A241880621839F06A1E429A633CBF6520D1DA74128
790A1A8428A698628A29A69806A148A341E8A3D120E4351A84D465B57EBC2AEC
61E2DA20647E808A90EBC7DB32AF0D865D1FCA903FE62FCB343D01F271BF9B10
4A58867F9629AAC9ECF32FFA6571FEE906212B540F47EC21C6049AFF5606A138
3F340845F86F6B10F2F9BB0C42D562308039C299D82BF6F91306A186F810B324
F7B7B847982822E3A9330F12F6D93A9925B9CF4F83509F0FC297A1E069105241
CA2C68721A84928D06A1AF7B14F26704458350F5568E1B1CE7383F0D426730CB
26A3A041080489068F06211A84681032F869104A9E623AB36C2FD5D0711A8492
A7A04188628A29A698628AD1C587F5D2B44168FD5D3F9E13B6EE33244641CAC7
B04128B83D140932C11C8928B1DDABE30A19844A715124F5D9E35938A7B623FD
A70D42F2840633EAD5C87694AF19B61762B0E7844128535DF5E9AE652E26465C
58FEF431CE2FD550857F12EFCFCEBAB310D8A5F65276CC20D417F6DA8EDF666C
4F7D7B08471B84AE62964C355FC91A18E70CFFE24F033F0BD72F06DFB74A5001
F83886A1C07FBBD3FC57DE4DF9ECBFBA0BAE93D2E66F1884FCF19F61102AC296
69D05940C3F90E06211D98CF3FC22094590200B324F7B7B81B260A2B92FDB7C6
7CB6A74A5561B172B0B370BE41480E9E04ECB888DB232AF61C5AB435F90C8350
519E9171D6208E41C84E92A44F38E734F908831026FBF6FDE797EC3BB086C941
B2DE7644C25059F8FCA30D42F1B14EB9BC6BFED075186A57198412CC91E043E2
06739DD318FF5506217D14D636629647DECD20142A12248EF03FC820141AE708
3F0D42204834783408D120448390C14F8350F214D399657BA9868ED320943C05
0D426F235EC7CEF8B8BA1E890C6DE276725A7CA8E7901885372C6C7DA2E9CCBA
45F83B1316AA30BFCECEDCE2F683376E3FC5F9E1BDABC89119DBBD45D83A307F
C08A71F64FA165A1B0FDD63925B7B0F5133ABC44C2E2FC13FF364296B348180E
F8B5354B5684EDF703C3EEA32DC246FDF8B134EE5DC9DFE411D8B39FE101CC46
D8FECF067326493596B955E2711A15768859B750B6E3636B30FB4F5BCFEEBF87
7C10E878C3B3E767C131397A08DFC5D1F4C022F10706E184DEE850DA42EB36C2
31EC1BFA883E6E32DB19468FE7981C719EE15045032E7A4669F34F37623140A7
C01911CC7E7A1ACCFE238A639C292A124523EC5616F6E38D37BA60B6DB25D160
D60D894343D528CFC8D46F643B97AC20B39F0B58249151487B028C84C505927B
ECC7FE329FFE683BAB671BA453BC85ED1541905973A22DDEC632846291380DE6
B4D81AA43033EAB9DE06FEFC9EF066EAE3E97F476088FD6980F8C377843B96A1
50D89147636264173DF97BE79698D8D5FA3C1F9A00A1354CB2F9E4E3B29D6DEB
69C5CD7BCB02E48F42E30AD0CF48E39FB93416C09A24435E6C89F9B99579D998
E38511AAED08F3268E84DA60AED3F67AC99FA541489EB428CF72A36F7F942E46
F9FA746D83A18A8FAFC32C69117FC12C9351DB2770A9C08F8391E5A1F146971E
E7387FC3B4EC93038350EC14F08206F5265F33CE2054878ACD8F9B41A80E49B2
B5F88F6DB3455EE48AF740F6C0EC412A7FFEDEF3E7DFB3D359C53F2F7A71D10D
3D7BA541A88C65299FD8C923FC4BFD446C9C857808B3DFD6F8E4E81857436DFE
6A31B08B6160D8C3C46B7C60BFAA2C8CF235954108AD612DFEE9BBC075F0E5C4
40A31DBACB8C4E319D59B6BA54117FC39C5EB6FA14EF6410F2C6B97C250D4214
536C363D89AEEAF95AF1E0592FD3A64F7CAD59C611CF5AE99E205E73D321DE73
BFC4E68FDDA67BF6FA2E03CEB921D26ADF2F017A4F303A6C3D0D672C0669B1C5
6FE7E4E6FF3150425C5F2196CF48CC113775FBE4131386028D00383DB7E5CE76
6FBB8DBD3268DD0AEAE8B9AEAD94D86E236E33DA2F6A1DAB8AA47EDA4F5EA741
68EB39F2526B0805330A5ECB60CF3EBF6EE7DF354BBCDDA0971A627F243194CA
F6A1D5D31F183DE69D3EC546792241552476689188126E41236CDD43D99B3D49
0BE6C8681BCC96AC154D90193563A82CDAFAD108BB0CC81BE32A611E6123617D
CC8558F6A5C38561C7CAC3C6491884F449CD0DC824B3E6A441880621A7E74814
69666362A07E10AFFCFD1D0C4228318D6C671782F5B43408B90323F3B2319F68
1042E49BD81B8A56161E6510DA7F4B5C4A8598252DE22F98671B84241BEA53BE
8606A124FF3B1884E23221DE03D9037BA8412894B05AE0F397A75ECAE57E9E41
C896A013BD9341282284E2765BE3BBA541A89DB8F73608D9FC0F3108D5477E34
83901267F9C76D2DD2204431C51453FC18B17E8FB9AAE7FB89D72C3CC238A263
7C5CB63BC50D6699187F086FCEFCE34EC9AB6AFBAE45B22D43FA504CF8F179C0
3EDCBACD7728EC71621D5284BFF3F3FDAD16FD18F97EACFB7EDD562435753CF3
674E497C44D576E414B0E708EDB56FB168B4D3AB67D1735F556FE25E6197F89C
6CEB1AEA16277BCEB6E65079CB54E88DAE633EB797C6EB8AA48EE2DA6B92193D
EB3846F69C7BDBBBC1556FCF5A36FD8286628A1F29BEC7A2DF253EEBC2B5FF62
EA2A66FD38FAAFDDDDE91D636D90193DDD7D353434EC43E2D038C71F9FFA3161
00B35F2AC3C21E204E845DBE667FEDB26F23B768F5F18913A335305E068A5B1D
F1F2287AEE0CBB57287AF6C32B4758305B056067A13C11E87906B36C910A87E3
8CD2277FBF21332237C6198D303AB231E31EF6E3E730FB847E44C638474E6588
75607E154CDF04C1F5ECD6369AF491FEC72D803408514C31C514534C31C51453
4C31C514534C31C514534C31C514534C31C51453DC238E6C5819E2F83ED7AD98
F5FE2802696C715FB5DD3B409C66F61B14A3DE22EDCCDA0EED52A32459E2FDB5
30DB9DB32ADE426254B68BFFA2844128DBFFF489E197041AEDE6FF38BD1F357A
EE9B1245D87DADF147BDFC0A5FB40FC29F0CF2F8C471F6338C10B6B0D108EBE3
FA44C64AE2475184DD476B886323BCBF72B138DBA732C488D3E97910B3DF74FF
D550B593558D735D0088D62892487984986910A298628A29A698628A29A69862
8A29A698628A29A698628A29A698628A29A698628A29A6F86C71FF26F7CD995F
A015FFC558CB72767DD86971CB11F1C19C35089D1FF6003142A8EC1BF5CBF471
C3FB7162D803C4C8D0B2589C5A626764B1CE3B34EC616219E1521E6AD578B741
6840D8504C8310C514534C31C514534C31C514534C31C514534C31C514534C31
C514534C31C5141F13BF445B5EAA9DD8F36C71C1FC0BF8F2B3F038E64DEC33FB
FC4F6596BF207E7D7C2B92373308494ED496FDE94F090D423408D120B458E71D
1AF630B18C70290FB56A9C06218A29A698628A29A698628A29A698628A29A698
628A29A698628ADF5FBCDEFA2EF6C72FEA799ED860D63BA37E2E1EC7BC891133
DA319659782AF3FA2DC2ACBF96BE29312EEC61E238FF12B7899C1FF630B1CFBF
F8297983C540F2170BA03688E84542F33F8259B68DD9B7C3F8FC8F632EC468B4
11FF3631A4916E46D8C3C4E905F09378FD2E1FAF0C7B80580394305B6DEFA3EC
BFF4AAB0078811C2FA330D42C5687A636F884F097B985846B894875A354E8310
C514534C31C514534C31C514534C31C514534CF19B8B5FAA19FF7EBCBE7B36A4
E7D9E28239B22586B2F020E642BCF2C4F686EB2C3C9579FD2649E2FCC57EDA8C
B08789E3E4C6C47883C5C0E76F2C067E166ECB2C9BE42F167D79484F7AC4FF08
66D98A451FB1F9FCCF36CBA0D146FCC6C4C8F24F675E9B1E4F9FDF789794EDAA
B08789354E7A01F4C96FC82C1BE20F2DFA88FFE6CCB2C1F99CE57F1073218E4C
003831DEC02094E5A741C87DE955610F102384F5671A848AD1F4C6DE109F12F6
30B18C70290FB56AFCAE06A1DFFE0F5C48D263AED50100
}

anims: [[1 2 3 3 3 3 2 1] [1 5 6 5 6 5 6 5 6 5 6 1] [1 7 4 4 4 4 4 4 4 4 7 7 7 1] [1 2 2 2 2 2 2 2 2 2 2 3 1 3 1 2 2 2 1] [1 5 6 5 6 6 6 6 6 5 6 5 2 2 2 1]]
]
fps-meter: func[/local] [
    if not value? 'tim [tim: 0:0:0 st: 0]
    if (now/time/precise + negate tim) > 00:00:01 [
        tim: now/time/precise
        fps-text: reform [st " fps"]
        st: 0
    ]
    st: st + 1
]
;make the background transparent
foreach i krava/imags [
    repeat n length? i [p: pick i n if p = 255.255.255 [poke i n 0.0.0.255]]
]
foreach i krava/explosion [
    repeat n length? i [p: pick i n if p = 255.255.255 [poke i n 0.0.0.255]]
]
either system/version/2 = 99 [
    win: make gob! [text: "One thousand of innocent cows dying." size: 1000x700 offset: 10x10]
gobb: make gob! [
    size: 1000x700
    color: 200.200.200
]
gobfps: make gob! [size: 100x20]
append win [gobb gobfps]
gobk: make gob! [offset: 10x10 ]
gobk/image: krava/imags/1
kravas: copy []
alive?: copy []
loop cowcount [
    append gobb make gobk compose [offset: (random 1000x700)]
    append/only kravas first random krava/anims
    append alive? yes
]
advance: func [block][
    block: next block
    if tail? block [block: first random krava/anims]
    block
]
view/no-wait win
forever [
    kravas: head kravas
    repeat i length? gobb [
        either alive?/:i [
            kravas/1: next kravas/1
            if tail? kravas/1 [kravas/1: first random krava/anims]
            gobb/:i/image: krava/imags/(kravas/1/1)
            gobb/:i/offset: gobb/:i/offset + 2x2 - random 3x3
            if (random 1000) < 2 [;cow dies
                change at alive? i no
                kravas/1: [1 2 3 4 5 6 7 8 9 10 11 12 13]
            ]
        ][
            if not none? kravas/1 [
                gobb/:i/image: krava/explosion/(kravas/1/1)
                kravas/1: next kravas/1
                if tail? kravas/1 [kravas/1: none]              
            ]
        ]
        kravas: next kravas
    ]
    wait 0.001
    fps-meter
    gobfps/text: fps-text
    show win
]
][
win: make face [pane: copy [] text: "One thousand cows happily dying." size: 1000x700 offset: 10x10]
kravas: copy []
alive?: copy []
loop cowcount [
    append win/pane make face compose [
        offset: (random 1000x700)
        image: krava/imags/1
        size: image/size
        color: none
        effect: none
        edge: none
    ]
    append/only kravas first random krava/anims
    append alive? yes
]
view/new win
gobb: win/pane
svsp: system/view/screen-face/pane
while [not empty? svsp][
    kravas: head kravas
    repeat i length? win/pane [
        either alive?/:i [
            kravas/1: next kravas/1
            if tail? kravas/1 [kravas/1: first random krava/anims]
            gobb/:i/image: krava/imags/(kravas/1/1)
            gobb/:i/offset: gobb/:i/offset + 2x2 - random 3x3
            if (random 1000) < 2 [;cow dies
                change at alive? i no
                kravas/1: [1 2 3 4 5 6 7 8 9 10 11 12 13]
            ]
        ][
            if not none? kravas/1 [
                gobb/:i/image: krava/explosion/(kravas/1/1)
                kravas/1: next kravas/1
                if tail? kravas/1 [kravas/1: none]              
            ]
        ]
        kravas: next kravas
    ]
    wait 0.001
    show win
    fps-meter
    print fps-text
]
]

Tuesday, 10 July 2012

Guide to rebol programming in Chinese

Here a guide to programming and programming in Rebol written in Chinese:
http://product.dangdang.com/product.aspx?product_id=22807051
 The title is:

编程ING:人人都能学会程序设计(全彩)

3D printer software

Here another great example of Rebol, a 3D printer software:
You can find more details from creator site: http://rebrep.blogfree.net/

Friday, 6 July 2012

Vertical text in VID

I'm preparing a big post on VID, so I'm discovering many functions new to me. One very interesting is to obtain vertical text. VID is capable to rotate images of 90° at time, so it's just to convert the text in an image. So I created this function:
vert-text: func [
    {Rotate text, default vertically. Usage: view layout [image (vert-text "Hello!")]}
    the-text [string!]   "Your text"
    /local a
    ] [
        a: to-image layout/origin [ text the-text]   0x0
        a: to-image layout/origin [image   (as-pair   a/size/y a/size/x)   a effect   [rotate 270]] 0x0
        a
        ]


Look at this example:

view layout [image red (vert-text "Hello world!" )]


I added the color in order to show you the small size of the image, just exactly the text size.
You can change the text style with any VID style.

Wednesday, 4 July 2012

Preventing automatic wrap in VID

I just discovered that Rebol VID has a keyword to prevent automatic wrap of the text :
  • AS-IS
Let's look at the differences:


view layout [text "Hello ^/ world!"]



Now look at this:


view layout [text as-is "Hello ^/ world!"]



Monday, 2 July 2012

Mirror game

Here a new simple game in Rebol, your task is to place 7 mirrors or less in order to connect all light sources with the same number:

The suource is: http://arnoldvanhofwegen.com/stuff/mirror.rebol
Here the source:
REBOL [Title:   "Mirrorgame"
            File:     "mirror.r"
            Auteur:   "Arnold van Hofwegen"
            Version: "1.04"
]
History: [1.00 Initial released version
          1.01 Fixed bug init aantal-spiegels
          1.02 01-07-2012 Added coloring of the labels on the side
          1.03 02-07-2012 Improved on coloring and turn it on from start
          1.04 02-07-2012 labelfont
]
;**********************************************************
; Hulpvelden
;**********************************************************
;***********
; Constanten
;***********
grootte: 30
;***********
; Variabelen
;***********
;*******************************************************************************
; Functies
;*******************************************************************************
;***********************
; Initialiseren schermen
;***********************
init-draw-grid-box: func [/local n] [
    draw-grid-box: copy []
    draw-grid-box: append draw-grid-box [pen black]
    for n 0 8 1 [
        ; Horizontale gridlijnen
        draw-grid-box: append draw-grid-box compose [line (to-pair reduce [0 n * grootte]) (to-pair reduce [8 * grootte n * grootte])]
        ; Verticale gridlijnen
        draw-grid-box: append draw-grid-box compose [line (to-pair reduce [n * grootte 0]) (to-pair reduce [n * grootte 8 * grootte])]
    ]
]
make-draw-mirror-box: func [/local n m] [
    draw-mirror-box: copy []
    draw-mirror-box: append draw-mirror-box [pen black]
    for n 1 8 1 [
        for m 1 8 1 [
            switch lees-veld m n [
                4   [draw-mirror-box: append draw-mirror-box compose [line (to-pair reduce [(n - 1) * grootte m * grootte]) (to-pair reduce [n * grootte (m - 1) * grootte])]
                    ]
                5   [draw-mirror-box: append draw-mirror-box compose [line (to-pair reduce [(n - 1) * grootte (m - 1) * grootte]) (to-pair reduce [n * grootte m * grootte])]
                    ]
]   ]   ]   ]
init-draw-free-mirror-box: func [/local n m] [
    ; schonen van de opgave
    for n 1 8 1 [
        for m 1 8 1 [
            switch lees-veld m n [
                1 2 [bewaar-veld m n 0]
            ]
        ]
    ]
    make-draw-free-mirror-box
]
make-draw-free-mirror-box: func [/local n m] [
    draw-free-mirror-box: copy []
    draw-free-mirror-box: append draw-free-mirror-box [pen blue]
    for n 1 8 1 [
        for m 1 8 1 [
            switch lees-veld m n [
                2   [draw-free-mirror-box: append draw-free-mirror-box compose [line (to-pair reduce [(n - 1) * grootte m * grootte])
                      (to-pair reduce [n * grootte (m - 1) * grootte])]
                    ]
                1   [draw-free-mirror-box: append draw-free-mirror-box compose [line (to-pair reduce [(n - 1) * grootte (m - 1) * grootte])
                      (to-pair reduce [n * grootte m * grootte])]
                    ]
]   ]   ]   ]
;*******************
; Initialiseren veld
;*******************
bepaal-random-veld: func [/local spel flip randspel tussenblok n m] [
    veld: copy []
    randspel: spel: copy ""
    aantal-spiegels: 0
    lbl-spiegelinfo/text: aantal-spiegels
    show lbl-spiegelinfo
    random/seed
    loop 10 [flip: random true
            either flip [spel: append spel "5"][spel: append spel "4"]
            ]
    loop 7   [flip: random true
            either flip [spel: append spel "1"][spel: append spel "2"]
            ]
    loop 47 [spel: append spel "0"]
    randspel: random spel
    for n 0 7 1 [tussenblok: copy []
        for m 1 8 1 [append tussenblok to-block substr randspel (n * 8 + m) 1]
        veld: append/only veld tussenblok
    ]
]
doorloop-doolhof: func [n /local stapr stapk richting m op-bord] [
    switch n [
        1 2 3 4 5 6 7 8         [stapr: 1
                                stapk: n
                                richting: 2]
        9 10 11 12 13 14 15 16   [stapr: n - 8
                                stapk: 8
                                richting: 3]
        17 18 19 20 21 22 23 24 [stapr: 8
                                stapk: 25 - n
                                richting: 0]
        25 26 27 28 29 30 31 32 [stapr: 33 - n
                                stapk: 1
                                richting: 1]
    ]
    op-bord: true
    while [op-bord] [
        if   found? find [2 4] lees-veld stapr stapk [;slash-spiegel
            richting: richting xor 1
        ]
        if   found? find [1 5] lees-veld stapr stapk [;backslash-spiegel
            richting: richting xor 3
        ]
        switch richting [
            2 [stapr: stapr + 1]
            3 [stapk: stapk - 1]
            0 [stapr: stapr - 1]
            1 [stapk: stapk + 1]
        ]
        if any [stapr < 1
            stapr > 8
            stapk < 1
            stapk > 8][op-bord: false]
    ]
    either stapr = 0 [m: stapk ][
        either stapr = 9 [
            m: 25 - stapk
        ][
            either stapk = 0 [
                m: 33 - stapr
            ][; stapk is nu 9
                m: 8 + stapr
            ]
        ]
    ]
    return m
]
bepaal-labels: func [/local idx volgorde] [
    randwaarden: copy [0 0 0 0 0   0 0 0 0 0   0 0 0 0 0   0 0 0 0 0   0 0 0 0 0   0 0 0 0 0   0 0]
    volgorde: random [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]
    idx: 1
    for n 1 32 1 [
        if   0 = pick randwaarden n [
            poke randwaarden n pick volgorde idx
            m: doorloop-doolhof n
            poke randwaarden m pick volgorde idx
            idx: idx + 1
        ]
    ]
]
vul-labels: func [/local n waarde] [
    for n 1 8 1 [
      waarde: to-string pick randwaarden n
      panel-boven/pane/:n/text: waarde
      waarde: to-string pick randwaarden 8 + n
      panel-rechts/pane/:n/text: waarde
      waarde: to-string pick randwaarden 25 - n
      panel-onder/pane/:n/text: waarde
      waarde: to-string pick randwaarden 33 - n
      panel-links/pane/:n/text: waarde
    ]
]
zet-label-kleur: func [n onoff /local p] [
    either n < 9 [
        either onoff [panel-boven/pane/:n/font: lbl-bo/font]
                    [panel-boven/pane/:n/font: txt-bo/font]
        show panel-boven/pane/:n
    ][either n < 17 [
            p: n - 8
            either onoff [panel-rechts/pane/:p/font: lbl-r/font]
                        [panel-rechts/pane/:p/font: txt-r/font]
            show panel-rechts/pane/:p
        ][either n < 25 [
                p: 25 - n
                either onoff [panel-onder/pane/:p/font: lbl-bo/font]
                            [panel-onder/pane/:p/font: txt-bo/font]
                show panel-onder/pane/:p
            ][
                p: 33 - n
                either onoff [panel-links/pane/:p/font: lbl-l/font]
                            [panel-links/pane/:p/font: txt-l/font]
                show panel-links/pane/:p
]   ]   ]   ]
;*************
; Hulpfuncties
;*************
substr: func [string start length] [copy/part at string start length ]
lees-veld: func [x y /local temparr] [
    temparr: pick veld x
    return pick temparr y
]
bewaar-veld: func [x y waarde /local temparr] [
    temparr: pick veld x
    poke temparr y waarde
]
bereken-veld: func [xypair] [
    rij: 1 + to-integer xypair/2 / grootte
    kolom: 1 + to-integer xypair/1 / grootte
]
;******************************************
; Belangrijkste functies voor de verwerking
;******************************************
check-oplossing: func [/local m n opgelost] [
    opgelost: true
    for n 1 32 1 [
        m: doorloop-doolhof n
        either equal? pick randwaarden n pick randwaarden m [
            zet-label-kleur n on
        ][
            zet-label-kleur n off
            opgelost: false
    ]   ]
    return opgelost
]
zet-spiegel: func [rij kolom
                  /local veld-waarde
                  nieuwe-waarde
                  teveel-spiegels
                  is-opgelost] [
    veld-waarde: lees-veld rij kolom
    nieuwe-waarde: 99
    teveel-spiegels: false
    lbl-spelbericht/text: ""
    lbl-spelbericht/color: none
    switch veld-waarde [
        0   [ nieuwe-waarde: 2
                    either aantal-spiegels < 7 [
                        aantal-spiegels: aantal-spiegels + 1
                    ][
                        nieuwe-waarde: 99
                        teveel-spiegels: true
            ] ]
        1   [nieuwe-waarde: 0
              aantal-spiegels: aantal-spiegels - 1]
        2   [nieuwe-waarde: 1]
        4 5 [lbl-spelbericht/text: "Solid mirrors cannot be changed or removed."
              lbl-spelbericht/color: red
            ]
    ]
    if   all [nieuwe-waarde < 3
            not teveel-spiegels][bewaar-veld rij kolom nieuwe-waarde ]
    lbl-spiegelinfo/text: aantal-spiegels
    show lbl-spiegelinfo
    if   teveel-spiegels [
        lbl-spelbericht/text: "Already 7 mirrors are placed."
        lbl-spelbericht/color: red
    ]
    ; check-opgelost
    is-opgelost: check-oplossing
    if   is-opgelost [
        either aantal-spiegels = 7 [
            lbl-spelbericht/text: "Solution found! Congratulations!!!"
            lbl-spelbericht/color: green
        ][
            lbl-spelbericht/text: "Almost, but there have to be exactly 7 mirrors!"
            lbl-spelbericht/color: yellow
        ]
    ]
    show lbl-spelbericht
    make-draw-free-mirror-box
    show free-mirror-box
]
;**************
; Button acties
;**************
action-nieuw-spel: func [] [
    bepaal-random-veld
    bepaal-labels
    vul-labels
    make-draw-mirror-box
    mirror-box/effect: reduce ['draw draw-mirror-box]
    init-draw-free-mirror-box
    free-mirror-box/effect:   reduce ['draw draw-free-mirror-box]
    show mirror-box
    show free-mirror-box
    check-oplossing
]
action-help-spel: func [] [
    inform layout [backdrop ivory
        text bold "Mirrorgame."
        text " "
        text "Try to connect the same values along the borders "
        text "of the diagram by placing exactly 7 extra mirrors in the field. "
        text "Imagine that you send beams of light into the grid and "
        text "your beams should go from one value to the corresponding "
        text "value. Values that are matching are shown in white, others "
        text "will appear in black. "
        text " "
        text "Have fun, good luck!"]
]
;*******************
; Stijlen voor faces
;*******************
spiegel-styles: stylize [
    horleftlab: text to-pair reduce [40 grootte]
    horrightlab: text right to-pair reduce [40 grootte]
    vertlab: text center to-pair reduce [grootte 40]
]
;**********************************************************
; Layout applicatiescherm
;**********************************************************
main: layout [
    size 400x400
        styles spiegel-styles
        across
        panel-links: panel [below
            space 0x0
        horrightlab "_" horrightlab "_" horrightlab "_" horrightlab "_"
        horrightlab "_" horrightlab "_" horrightlab "_" horrightlab "_"
    ]
    hier: at
    at hier + 0x-22
        panel-boven: panel [across
            space 0x0
            vertlab "_" vertlab "_" vertlab "_" vertlab "_"
            vertlab "_" vertlab "_" vertlab "_" vertlab "_"
        ]
    at hier
    grid-box: box " " 1x1 white
    at hier
    mirror-box: box " " 1x1 white
    at hier
    free-mirror-box: box " " 1x1 white feel [
        engage: func [face action event] [
            if   action = 'down [
                bereken-veld event/offset
                wat: lees-veld rij kolom
                zet-spiegel rij kolom
                free-mirror-box/effect:   reduce ['draw draw-free-mirror-box]
                show free-mirror-box
    ]   ]   ]
    at hier + 240x0
        panel-rechts: panel [below
            space 0x0
            horleftlab "_" horleftlab "_" horleftlab "_" horleftlab "_"
            horleftlab "_" horleftlab "_" horleftlab "_" horleftlab "_"
    ]
    return
    across
    at hier + 0x240
        panel-onder: panel [across
            space 0x0
            vertlab "_" vertlab "_" vertlab "_" vertlab "_"
            vertlab "_" vertlab "_" vertlab "_" vertlab "_"
        ]
    at hier + 0x260
    text "Number of placed mirrors: "
    lbl-spiegelinfo: text "" 30
        return
    lbl-spelbericht: text "" 300
    return
    btn-help: button "Rules" [action-help-spel]
    btn-nieuw: button "New game" [action-nieuw-spel]
    btn-stoppen: button "Stop" [unview/all]
    lbl-bo: label top     center 0 ""
    txt-bo: text   top     center 0 ""
    lbl-l:   label middle right   0 ""
    txt-l:   text   middle right   0 ""
    lbl-r:   label middle left   0 ""
    txt-r:   text   middle left   0 ""
]
;**********************************************************
; Uiteindelijke programma
;**********************************************************
box-size: to-pair reduce [8 * grootte + 1 8 * grootte + 1]
grid-box/size: box-size
mirror-box/size: box-size
free-mirror-box/size: box-size
mirror-box/color: none
free-mirror-box/color: none
init-draw-grid-box
grid-box/effect: reduce ['draw draw-grid-box]
action-nieuw-spel
view main