Annotation of 43BSD/contrib/icon/src/cmd/worm.icn, revision 1.1

1.1     ! root        1: #      WORM(6)
        !             2: #
        !             3: #      Random worm
        !             4: #
        !             5: #      Stephen B. Wampler
        !             6: #
        !             7: #      Last modified 8/14/84
        !             8: #
        !             9: 
        !            10: #      NOTE:  This program requires the procedures in gpack.2.  It
        !            11: #      should be translated as follows:
        !            12: #
        !            13: #      icont worm.icn /usr/icon/ilib/gpack.u1
        !            14: #
        !            15: global BLUE, WHITE
        !            16: global VECTOR
        !            17: 
        !            18: procedure main(args)
        !            19:    local colpt, bkcolr, count, length, r, arg, a, pt1, pt2
        !            20:    ginit()
        !            21:    colpt := WHITE
        !            22:    bkcolr := BLUE
        !            23:    count := 1000
        !            24:    length := 10
        !            25:    r := 0
        !            26:    every arg := !args do case arg[1+:2] of {
        !            27:       "-f" : colpt := integer(arg[3])           # foreground color
        !            28:       "-b" : bkcolr := integer(arg[3])          # background color
        !            29:       "-c" : count := integer(arg[3:0])         # duration of worm
        !            30:       "-l" : length := integer(arg[3:0])        # length of worm
        !            31:       "-r" : r := integer(arg[3:0])             # random number seed
        !            32:       "-h" : stop("usage: worm [-fn] [-bn] [-cn] [-ln] [-rn]")
        !            33:       }
        !            34: 
        !            35:    if colpt == bkcolr then {
        !            36:       colpt := WHITE
        !            37:       bkcolr := BLUE
        !            38:       }
        !            39: 
        !            40:    a := point(XMAX/2,YMAX/2)                # start in screen center
        !            41: 
        !            42:    every (pt1|pt2) := create                # two sequences of the same lines
        !            43:       2(&random :=: r,|draw(line(.a,a := nextpt(a))),&random <-> r)
        !            44: 
        !            45:    bckgrnd(bkcolr)
        !            46:    erase()
        !            47: 
        !            48:    every _noroll() & _plot() do {
        !            49:       mode(VECTOR)
        !            50:       color(colpt)
        !            51:       every 1 to length do @pt1
        !            52:       every 1 to count do {color(colpt);@pt1;color(bkcolr);@pt2}
        !            53:       color(bkcolr)
        !            54:       every 1 to length do @pt2
        !            55:       movcur(20,20)
        !            56:       color(colpt)
        !            57:       }
        !            58: 
        !            59: end
        !            60: 
        !            61: procedure nextpt(pt)
        !            62: local x,y
        !            63: 
        !            64:    repeat {
        !            65:       x := pt.x + (?32767\1)%21 - 10
        !            66:       if 0 < x < XMAX then break
        !            67:       }
        !            68: 
        !            69:    repeat {
        !            70:       y := pt.y + (?32767\1)%21 - 10
        !            71:       if 0 < y < YMAX then break
        !            72:       }
        !            73: 
        !            74:    return point(x,y)
        !            75: end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.