Hi Gregg,

I think the modified script below will improve the first time performance by
quite a bit
for you. Pre allocating the space needed makes a big diff. (1/3 the time on
my machine)

Cheers,

Allen K


REBOL [
    Comment: {
        Converted to REBOL by Gregg Irwin for testing purposes.
  Some speed mods. Pre-allocated block size, REBOLised the maths Allen K
    }
]

pyth-tree: func [
    a[pair!] b[pair!]
    depth[integer!] face
    /local c d e color
][
    c: d: e: 0x0
    color: depth * -10 + 0.255.0
    c/x: a/x - a/y + b/y
    c/y: a/x + a/y - b/x
    d/x: b/x + b/y - a/y
    d/y: a/x - b/x + b/y
    e/x: c/x - c/y + d/x + d/y * 0.5
    e/y: c/x + c/y - d/x + d/y * 0.5
    append draw-cmds compose [pen (color) line (c) (a) (b) (d) (c) (e) (d)]
    ;append draw-cmds reduce [c a b d c e d]
    ;print [c a b d c e d]
    ;show face
    if depth < 12 [
        pyth-tree c e depth + 1 face
        pyth-tree e d depth + 1 face
    ]
    ;wait .05
]

world-size: 640x520
start-pt-1: 266x450
start-pt-2: 374x450

lay: layout [
    size world-size
    backdrop black
    origin 0x0
    canvas: image 640x480
    across
    button "go" [
        clear draw-cmds
        ;show canvas
        print now/precise
        pyth-tree start-pt-1 start-pt-2 0 canvas
        print now/precise
  ;print length? draw-cmds
        show canvas
    ]
    button "quit" [quit]
]
; preallocate the space needed
canvas/effect: reduce ['draw draw-cmds: make block! 90000]

print ""
view lay





-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to