Thanks to Evan and Brian 
Author Message
 Thanks to Evan and Brian

Well it is not much but it seems to work
thanks to you both for the pointers.

This is simply a 4-way recursion which,
with the settings bellow, draws a square
grid. Playing with the 'depth' and the
'fac' variable can come up with some
interesting paterns. What it does not
do is exhibit any of the self-similar
patterns (a hint for more pointers ?)
that I was looking for when I started this.

Anyway, thanks again,


;;; ucblogo

to aaa
        local "x1
        local "y1
        local "x2
        local "y2               ; the two oposite corners
        local "depth            ; depth of recursion
        local "random_seed      ;
        local "fac              ; float degree of random
devation from center
                                ; 0.0, with these corners,
makes squares

        make "x1        -100
        make "y1        -100
        make "x2        100
        make "y2        100
        make "depth 5
        make "random_seed 3789125
        make "fac .1

        ht
        cs
        split :x1 :y1 :x2 :y2 :depth :random_seed :fac
        st
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; What really does the work
;; Given two oposit corners, find the middle
;; and draw each of the for sub polygons made
;; with the new middle point as common

to split :x1 :y1 :x2 :y2 :count :seed :fac

        local "tx
        local "ty

        make "tx  (sqrt((:x1 - :x2) * (:x1 - :x2))) * .5
        make "ty  (sqrt((:y1 - :y2) * (:y1 - :y2))) * .5

        (rerandom :seed)

        ifelse :rx < 0 [
                make "tx :tx + ((random int :tx) * :fac)
                ][
                make "tx :tx - ((random int :tx) * :fac)
        ]
        ifelse :ry < 0 [
                make "ty :ty + ((random int :ty) * :fac)
                ][
                make "ty :ty - ((random int :ty) * :fac)
        ]

        ; (pr :tx :ty )

        ifelse ( :x1 > :x2 ) [ make "tx :x1 - :tx ] [ make
"tx :x2 - :tx]
        ifelse ( :y1 > :y2 ) [ make "ty :y1 - :ty ] [ make
"ty :y2 - :ty]

        box :x1 :y1 :tx :ty
        box :x1 :y2 :tx :ty
        box :x2 :y2 :tx :ty
        box :x2 :y1 :tx :ty

        if :count > 1 [

                setpencolor 1
                split :x2 :y2 :tx :ty (:count - 1) 9164 :fac
                setpencolor 2          
                split :x1 :y2 :tx :ty (:count - 1) 1278 :fac
                setpencolor 7          
                split :x1 :y1 :tx :ty (:count - 1) 8914 :fac
                setpencolor 4          
                split :x2 :y1 :tx :ty (:count - 1) 3915 :fac

        ]
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Just draw a box
to box :x1 :y1 :x2 :y2

        ;; Cheap/expensive fat lines, repeat more than once
        repeat 1 [      
                pu
                setxy :x1 :y1
                pd
                setxy :x1 :y2
                setxy :x2 :y2
                setxy :x2 :y1
                setxy :x1 :y1

                make "x1 (:x1 *.99)
                make "x2 (:x2 *.99)
                make "y1 (:y1 *.99)
                make "y2 (:y2 *.99)

        ]
end



Wed, 24 May 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Evan's puzzle

2. Brian F. Jones Web Site

3. Brian's Socket Site

4. For Brian Staff and XPlore users

5. Calling Brian Aldwinckle

6. Contact for Brian Marasca?

7. Window not on top -- when using the Brian Staff Explore templates

8. About multiple VIs(for Brian)

9. Dynamic Forth-like from Brian D. Knowlton

10. Brian Knowlton's Forth-like Compiler

11. Brian Mikiten (B.MIKITEN1) asks for help:

12. Looking for Brian Fox

 

 
Powered by phpBB® Forum Software