File: get_rectangle.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (31 lines) | stat: -rw-r--r-- 594 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [ox,oy,w,h,ok]=get_rectangle(xc,yc)
// Copyright INRIA
pat=xget('pattern')
xset('pattern',default_color(0))
dr=driver()
if dr=='Rec' then driver('X11'),end
//
rep(3)=-1
ox=xc
oy=yc
w=0;h=0
ok=%t
first=%t
pixmap=xget('pixmap')==1

while rep(3)==-1 do
  xrect(ox,oy,w,h)
  if pixmap then xset('wshow'),end  
  if first then rep=xgetmouse();else rep=xgetmouse(0),end
  xrect(ox,oy,w,h)
  if pixmap then xset('wshow'),end  
  xc1=rep(1);yc1=rep(2)
  ox=mini(xc,xc1)
  oy=maxi(yc,yc1)
  w=abs(xc-xc1);h=abs(yc-yc1)
  first=%f
end
if rep(3)==2 then ok=%f,end

driver(dr)
xset('pattern',pat)