#!/usr/dt/bin/dtksh # # xlinesdemo - a demo of the X11 capabilities Desktop Korn Shell, dtksh. # Written on Solaris. # # 01-Apr-2004, ver 0.70 # # Written for a 24-bit colour display. On non-Solaris, check the path of your # dtksh (may not be "/usr/dt/bin/dtksh"). # # USAGE: xlinesdemo # # See the code for customisation such as size of the window. # # COPYRIGHT: Copyright (c) 2004 Brendan Gregg. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # (http://www.gnu.org/copyleft/gpl.html) # # 01-Apr-2004 Brendan Gregg Created this delay=100 # frame delay (ms) max_x=500 # window size x max_y=500 # window size y # # --- Create X11 window --- # XtInitialize TOP linesdemo Linesdemo $0 XtCreateManagedWidget FORM form XmForm $TOP \ resizePolicy:RESIZE_NONE \ height:$max_y width:$max_x x:0 y:0 XtCreateManagedWidget DRAW draw XmDrawingArea $FORM \ height:$max_y width:$max_x x:0 y:0 \ background:16777215 foreground:16777215 XtDisplay DISPLAY $FORM XSync $DISPLAY true XtRealizeWidget $TOP XtWindow WINDOW $DRAW old_x=1 # Initial x coordinate old_y=1 # Initial y coordinate # # --- Draw line function --- # function drawline { ### Pick random coordinates and colour (( x = $RANDOM % $max_x )) (( y = $RANDOM % $max_y )) (( colour = $RANDOM * 500 )) ### Draw new line XDrawLine $DISPLAY $WINDOW \ -foreground $colour \ -line_width 2 \ -line_style LineSolid \ $old_x $old_y $x $y ### Save old coordinates old_x=$x old_y=$y XtAddTimeOut ID $delay drawline # pause, then draw next } # # --- Main --- # XtAddTimeOut ID $delay drawline # pause, then draw line XtMainLoop