% from Lucasfilm Ltd. linesdemo = proc () slack = 150 bwidth: int := int$parse(xdemo_default("lines", "BorderWidth")) except when not_found, overflow, bad_format: bwidth := 2 end back: x_pixmap := x_display$white() bdr: x_pixmap := x_display$black() plane: int := 1 backpix: int := WhitePixel linepix: int := BlackPixel if x_display$cells() > 2 then begin r, g, b: int := x_parse_color(xdemo_default("lines", "Border")) bdr := x_pixmap$tile(x_display$alloc_color(r, g, b)) end except when not_found: end pixs: pixellist pixs, plane := x_display$alloc_cells(1, 1, false) backpix := pixs[1] back := x_pixmap$tile(backpix) r, g, b: int := x_parse_color(xdemo_default("lines", "Background")) except when not_found: r, g, b := x_display$query_color(WhitePixel) end x_display$store_color(backpix, r, g, b) linepix := pixs[1] + plane random_color(linepix) end w: x_window, wid0, hgt0: int := x_cons("lines", back, bdr, xdemo_geometry(), "=400x400+1+1", 40, 40, bwidth) w.name := "lines" w.input := UnmapWindow x_window$map(w) w.input := ExposeWindow + UnmapWindow ev: event := x_input$empty_event() while true do x_window$clear(w) sx, sy, width, height, bw, ms, wk: int, iw: x_window := x_window$query(w) if width <= slack cor height <= slack then x_window$destroy(w) return end x: int := random$next(width) y: int := height - random$next(slack) - 1 x1: int := random$next(width) y1: int := height - random$next(slack) - 1 dx: int := random$next(3) + 1 dy: int := random$next(3) + 1 dx1: int := -1 - random$next(3) dy1: int := -1 - random$next(3) while ~x_input$pending() do x := x + dx if x < 0 cor x >= width then x := x - 2 * dx dx := -dx if linepix ~= BlackPixel then random_color(linepix) end end y := y + dy if y < height - slack cor y >= height then y := y - 2 * dy dy := -dy end x1 := x1 + dx1 if x1 < 0 cor x1 >= width then x1 := x1 - 2 * dx1 dx1 := -dx1 end y1 := y1 + dy1 if y1 < height - slack cor y1 >= height then y1 := y1 - 2 * dy1 dy1 := -dy1 if linepix ~= BlackPixel then random_color(linepix) end end x_window$line(w, 0, 1, 1, x, y, x1, y1, GXinvert, plane) x_window$move_area(w, 0, 1, width, height, 0, 0) x_window$pix_set(w, backpix, 0, height - 1, width, 1) end x_input$deq(ev) if ev.kind = UnmapWindow then x_input$deq(ev) end end end linesdemo