% from Symbolics? rec = record[x1, y1, x2, y2: int] ar = array[rec] qixdemo = proc () vsize = 100 * 2 bwidth: int := int$parse(xdemo_default("qix", "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 if x_display$cells() > 2 then begin r, g, b: int := x_parse_color(xdemo_default("qix", "Border")) bdr := x_pixmap$tile(x_display$alloc_color(r, g, b)) end except when not_found: end cback: string := xdemo_default("qix", "Background") except when not_found: cback := "" end cfore: string := xdemo_default("qix", "Foreground") except when not_found: cfore := "" end if string$empty(cback) cand string$empty(cfore) then exit done end pixs: pixellist pixs, plane := x_display$alloc_cells(1, 1, false) back := x_pixmap$tile(pixs[1]) r, g, b: int if string$empty(cback) then r, g, b := x_display$query_color(WhitePixel) else r, g, b := x_parse_color(cback) end x_display$store_color(pixs[1], r, g, b) if string$empty(cfore) then r, g, b := x_display$query_color(BlackPixel) else r, g, b := x_parse_color(cfore) end x_display$store_color(pixs[1] + plane, r, g, b) end except when done: end w: x_window, wid0, hgt0: int := x_cons("qix", back, bdr, xdemo_geometry(), "=400x400+1+1", 40, 40, bwidth) w.name := "qix" w.input := UnmapWindow x_window$map(w) w.input := ExposeWindow + UnmapWindow vlist: x_vlist := x_vlist$create(vsize) 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 <= 30 cor height <= 30 then x_window$destroy(w) return end hsize: int := 100 + random$next(int$min(width, height) / 8) h: ar := ar$fill_copy(0, hsize, rec${x1, y1, x2, y2: 0}) i: int := 0 idx: int := 1 x1: int := 0 y1: int := height - 1 x2: int := 0 y2: int := height - 1 dx1: int := 5 dy1: int := 12 dx2: int := 12 dy2: int := 5 first: bool := true while ~x_input$pending() do r: rec := h[i] if ~first then x_vlist$store(vlist, idx, r.x1, r.y1, VertexDontDraw) idx := idx + 1 x_vlist$store(vlist, idx, r.x2, r.y2, VertexDrawLastPoint) if idx = vsize then x_window$draw(w, vlist, vsize, 0, 1, 1, GXinvert, plane) idx := 1 else idx := idx + 1 end end r.x1 := x1 r.y1 := y1 r.x2 := x2 r.y2 := y2 x_vlist$store(vlist, idx, x1, y1, VertexDontDraw) idx := idx + 1 x_vlist$store(vlist, idx, x2, y2, VertexDrawLastPoint) if idx = vsize then x_window$draw(w, vlist, vsize, 0, 1, 1, GXinvert, plane) idx := 1 else idx := idx + 1 end i := i + 1 if i = hsize then i := 0 first := false end dx1 := int$max(-12, int$min(dx1 + random$next(3) - 1, 12)) x1 := x1 + dx1 if x1 >= width cor x1 < 0 then x1 := x1 - 2 * dx1 dx1 := -dx1 end dy1 := int$max(-12, int$min(dy1 + random$next(3) - 1, 12)) y1 := y1 + dy1 if y1 >= height cor y1 < 0 then y1 := y1 - 2 * dy1 dy1 := -dy1 end dx2 := int$max(-12, int$min(dx2 + random$next(3) - 1, 12)) x2 := x2 + dx2 if x2 >= width cor x2 < 0 then x2 := x2 - 2 * dx2 dx2 := -dx2 end dy2 := int$max(-12, int$min(dy2 + random$next(3) - 1, 12)) y2 := y2 + dy2 if y2 >= height cor y2 < 0 then y2 := y2 - 2 * dy2 dy2 := -dy2 end end x_input$deq(ev) if ev.kind = UnmapWindow then x_input$deq(ev) end end end qixdemo