Chris.Forker@newcastle.ac.uk (Chris Forker - Nav Arch-) (06/12/91)
From chris@uk.ac.ncl.wagner Tue Jun 4 15:02:47 1991 Received: from ncl.wagner (wagner.ncl) by uk.ac.newcastle.gershwin; Tue, 4 Jun 91 15:02:46 BST From: Chris Forker - Nav Arch- <chris@uk.ac.ncl.wagner> Date: Tue, 4 Jun 91 15:08:14 BST Message-Id: <AA00873.9106041408.wagner@uk.ac.newcastle> To: chris Subject: post failed Status: RO /usr/local/lib/nn6.4/aux: /usr/local/lib/news/inews: not found /usr/local/lib/news/inews failed Your response has been saved in ~/dead.letter Your article/letter follows: Newsgroups: comp.sys.atari.st Distribution: comp.sys.atari.st Subject: Rubber Bands Summary: 'C' code to draw rubber bands Keywords: Rubber Bands A short while ago someone asked about drawing rubber bands. I did reply to one person but perhaps not the original poster. The following code may be of use to those who want to draw rubber bands . The code lacks eloquence but works for me. ---------------------- Cut Here ------------------------------ void drag_line(short mx[], short my[], short no_pts, int k_line, float scale) { short i,oldx,oldy,xloc,yloc1,yloc2,neg,xorg,yorg ; short xw,yw,ww,hw ; short mbx,mby ; short mb1, mb, /* mouse button state */ ks ; /* keyboard state */ short pts[4] ; char message[5] ; /* v_pline x,y's */ int drop = FALSE ; oldx = 0 ; oldy = 0 ; vsl_type(screen_vhandle, SOLID) ; vsl_color(screen_vhandle, BLACK) ; vsl_width(screen_vhandle, 1) ; vsm_type(screen_vhandle, 4) ; vst_point(screen_vhandle, 6, &i, &i, &i, &i) ; vst_effects(screen_vhandle, 1) ; wind_get(windows[cur_win].handle, WF_CXYWH, &xw, &yw, &ww, &hw) ; wind_calc(WC_WORK, (NAME|CLOSE|MOVE), xw, yw, ww, hw, &xw, &yw, &ww, &hw) ; xorg = xw + 20 ; yorg = yw + 30 + (20 * scale) ; neg= -1 ; hide_mouse() ; /* Function which hides mouse */ for (i = 0; i <= no_pts; i++) { do { graf_mkstate(&mx[i], &my[i], &mb1, &ks) ; /* x,y mouse co-ords */ if (oldx != mx[i] || oldy != my[i]) /* update screen if changed */ { sprintf(message,"X : %6.2f", ((mx[i]-xorg)/scale)) ; v_gtext(screen_vhandle, 500, 40, message) ; sprintf(message,"Y : %6.2f", ((my[i]-yorg)/scale)*neg) ; v_gtext(screen_vhandle, 500, 70, message) ; vswr_mode(screen_vhandle, MD_XOR) ; /* set up mouse form */ pts[0] = oldx ; pts[1] = oldy-5 ; pts[2] = oldx ; pts[3] = oldy+5 ; v_pline(screen_vhandle, 2, pts) ; pts[0] = oldx-5 ; pts[1] = oldy ; pts[2] = oldx+5 ; pts[3] = oldy ; v_pline(screen_vhandle, 2, pts) ; pts[0] = mx[i] ; pts[1] = my[i] - 5 ; pts[2] = mx[i] ; pts[3] = my[i] + 5 ; v_pline(screen_vhandle, 2, pts) ; pts[0] = mx[i] - 5 ; pts[1] = my[i] ; pts[2] = mx[i] + 5 ; pts[3] = my[i] ; v_pline(screen_vhandle, 2, pts) ; if (k_line && drop) { pts[0] = mx[i-1] ; pts[1] = my[i-1] ; pts[2] = oldx ; pts[3] = oldy ; v_pline(screen_vhandle, 2, pts) ; pts[0] = mx[i-1] ; pts[1] = my[i-1] ; pts[2] = mx[i] ; pts[3] = my[i] ; v_pline(screen_vhandle, 2, pts) ; } /* if */ vswr_mode(screen_vhandle, MD_REPLACE) ; } /* if */ oldx = mx[i] ; oldy = my[i] ; } while( mb1 <= 0 ) ; do { graf_mkstate(&mbx, &mby, &mb, &ks) ; } while( mb != 0 ) ; drop = TRUE ; } /* for */ vswr_mode(screen_vhandle, 3) ; pts[0] = oldx ; pts[1] = oldy-5 ; pts[2] = oldx ; pts[3] = oldy+5 ; v_pline(screen_vhandle, 2, pts) ; pts[0] = oldx-5 ; pts[1] = oldy ; pts[2] = oldx+5 ; pts[3] = oldy ; v_pline(screen_vhandle, 2, pts) ; show_mouse() ; /* Function to show mouse */ } /* drag_line */ --------------- Cut Here --------------- Hope this is of some help..... +-=--=--=--=--=--=--=--=--=--=--=--=--=--+--=--=--=--=--=--=--=--=--=--=--=-+ | mail: Chris.Forker@newcastle.ac.uk | Dept. Marine Technology | | voice: +44 91 2226000 X 6218 | Newcastle University | | fax: +44 91 2611182 | Newcastle upon Tyne | | | NE1 7RU ENGLAND | +-=--=--=--=--=--=--=--=--=--=--=--=--=--+--=--=--=--=--=--=--=--=--=--=--=-+