Another updated version gl tot98.ijs attached. This seem work
better. The boat is upside down because gl2 in J6/J7 only support raw
mapping mode where the origin is at the top left corner and the
y-axis points downwards. You may have to fix your drawing routines.

Note also that tot98 will not run under J6 because it lacks the
glpaintx command which is only introduced in J7.

Please email me if you cannot see the script attached with this
message.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
NB. WhimsyCalculus(WhimsyTOT98)     2/20/2001
require 'gui/gtkwd'
require 'gl2 trig'

coclass 'tot98'

coinsert 'jgl2'

NB.bind=: [. @ ("_)
each=: (&.>)

range=: 3 : '(>./y)-<./y'
lint=: 13 : '(range y) % x'
ap=: 13 :'(<./y)+0,+/\x#x lint y'
rot=: 2 2"_ $ 1 _1 1 1"_ * 2 1 1 2"_ o. ]

boat=: _2+0.5*4 2 3 5 6 4 4 6 4,:3 3 2 2 3 3 7 4 4
Fred=: _1.6+0.4*(18 9 9 6 0 3 0 6 12 18,:12 18 15 12 18 12 6 9 6 12)%3
ladybug=: 0.2*0 _6 _5 _4 _2 0 2 3 3 2 6 2 2 6 2 3 3 2 0 _2 _4 _5 _6 0,:0 _1 _2 
_3 _4 _4 _3 _2 _1 0 _1 0 0 1 0 1 2 3 4 4 3 2 1 0
dragonfly=: 0.1* 0 6 10 6 0 2 6 0 _6 _6 0 _24 0 _6 _6 0 6 2 0 6 10 6 0,:0 0 4 0 
0 8 12 0 12 6 0 0 0 _6 _12 0 _12 _8 0 0 _4 0 0
turtle=: 0.3*6 5 4 2 3 2 3 2 0 _2 _3 _5 _3 _2 _3 _5 _5 _3 _2 _3 _5 _3 _2 0 2 3 
2 3 2 4 5 6,:0 1 0 2 4 6 4 2 3 2 4 3 4 2 1 0 0 _1 _2 _4 _3 _4 _2 _3 _2 _4 _6 _4 
_2 0 _1 0

sline=: 3 : 0"1 2
0 0 0 sline y
:
glrgb x
glpen 1 0
gllines ,y
)

sfill=: 3 : 0
if. _1 e. y do. glbrushnull ''
else. glrgb y
  glbrush ''
end.
)

spoly=: 3 : 0"1 2
glpolygon ,y
:
sfill x
spoly y
)

spixel=: 3 : 0"1
glpixel y
:
:
glrgb x
spixel y
)

NB. 500 seems too large
NB. size=: 3 : '500+50*|: y'
size=: 3 : '100+50*|: y'

see=: 3 : 0
0 0 0 see y
:
xx=: 0
yy=: 0
d=: 0
)

swim=: 3 : 0
0 0 0 swim y
:
t=: 24 ap _2p1 2p1
xx=: t
yy=: 1 o. t
d=: 2 o. t
p=: xx,:y
)

dance=: 3 : 0
0 0 0 dance y
:
t=: 24 ap _3p1 3p1
xx=: t - 2 * 1 o. t
yy=: 1 - 2 * 2 o. t
d=: (2 * 1 o. t) % 1 - 2 * 2 o. t
)

x3=: 3 : '8 * (r=. 1 o. 2 * y) * 2 o. y'
y3=: 3 : '8 * (r=. 1 o. 2 * y) * 1 o.y'

loop=: 3 : 0
0 0 0 loop y
:
t=: 48 ap 0 2p1
xx=: x3 t
yy=: y3 t
dy=: ((1 o. 2*t)*2 o.t)+(1 o.t)*2*2 o. 2*t
dx=: (-(1 o. 2*t)*1 o.t)+(2 o.t)*2*2 o. 2*t
1E_5(<1)}dx
d=: dy%dx
)

fade=: 3 : 0
200 330 100 fade y
:
t=: 120 ap _2p1 2p1
xx=: 4 * 2 o. t
yy=: t + 1 o. 3 * t
d=: (-1+3 * 2 o.3* t,0)%4* 1 o. 0,t
kk=: 1.5
)

TOT98=: 0 : 0
pc tot98;picon fred\fred.ico 0;pn "Tool of Thought X, A Whimsyware Product from 
Stochastic Services";
xywh 245 10 65 40;cc lis0 listbox ws_vscroll;
xywh 245 55 65 40;cc lis1 listbox ws_vscroll;
xywh 245 100 65 40;cc lis2 listbox ws_vscroll;
xywh 245 150 30 30;cc show button bs_ownerdraw;cn "fred\ss.ico";
xywh 280 150 30 30;cc pain button bs_ownerdraw;cn "fred\ssg.ico";
xywh 245 185 65 15;cc clear button;cn "Clear";
xywh 245 205 65 15;cc cancel button;cn "Close";
xywh 3 3 220 220;cc g isigraph;
pas 6 6;pcenter;
)

tot98_run=: 3 : 0
forms=: ;:'boat Fred ladybug dragonfly turtle '
paths=: ;:'see swim dance loop fade '
colors=: ;:'red green blue yellow orange '
red=: 255 0 0
green=: 0 255 0
blue=: 0 0 255
yellow=: 255 255 0
orange=: 255 126 0
wd TOT98
wd 'set lis0 ',;forms, each LF
wd 'setfont lis0 "MS Sans Serif" 11 bold'
wd 'set lis1 ',;paths, each LF
wd 'setfont lis1 "MS Sans Serif" 11 bold'
wd 'set lis2 ',;colors, each LF
wd 'setfont lis2 "MS Sans Serif" 11 bold'
wd 'setfont clear "MS Sans Serif" 11'
wd 'setfont cancel "MS Sans Serif" 11'
wd 'pshow'
)

NB. y: 1=pain
showpain=: 3 : 0
if. y do.
  glrgb ?3#255
  glbrush ''
NB. what is glflood ?
NB.   glflood 100 120 0 127 255
end.
if. lis1 -: 'see' do.
  xx=: 0
  yy=: 0
  d=: 0
  s=: 2*".lis0
  0 0 0 sline size s
  (".uuu=: lis2) spoly size s
  glpaint''
  return.
end.
xx=: 0
".(col=: lis2),' ',(path=: lis1),' ',who=: lis0
p=: xx,:yy
cc=: 0
while. cc<$,yy do. r=: rot _3 o. cc{d
  xx=: 0
  if. 'loop'-:iii=: lis1 do.
    s=: ((r +/ . *".lis0)*cc{*dx)+ (_1 {.$".lis0)#"1,.cc{"1 p
  end.
  if. ('swim'-:lis1) +. ('dance'-:lis1) do.
    s=: (r +/ . *".lis0)+(_1 {.$".lis0)#"1,.cc{"1 p
  end.
  if. 'fade'-:lis1 do.
    s=: (r +/ .* kk * (".lis0)*(_1{.$".lis0)#"1,.*2#cc{(-*t)*_1+2*(|t)<1p1)+ 
(_1 {.$".lis0)#"1,.cc{"1 p
    kk=: 0.97*kk
  end.
  0 0 0 sline size s
  (".col) spoly size s
  glpaintx''
  usleep 2e5  NB. delay 2e5 us
  glclear''
NB.   255 255 255 sline size s
NB.   255 255 255 spoly size s
  cc=: cc+1
end.
kk=: 1.5
)

tot98_show_button=: showpain bind 0
tot98_pain_button=: showpain bind 1

tot98_clear_button=: glpaint@glclear

tot98_cancel_button=: tot98_close

tot98_close=: wd bind 'pclose'

tot98_run''

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to