> From: bill lam
> Sent: Wednesday, 30 June 2010 15:56
> 
> Срд, 30 Июн 2010, Sherlock Ric писал(а):
> > Would it be worth trying out drawing the image using native graphics
> > libraries (media/platimg) and then copying the resulting bitmap
> > buffer to gdk for display?
> 
> Do you mean draw using gdi+? I'm not familiar with it, would you do it
> by yourself? You can use the same skeleton.

The following doesn't run without callback errors from jconsole or Gtk IDE 
xxx signal: expose_event_1_
|control error: expose_event_1_
|       h~w

But once they are dismissed the image does display in a Gtk window and seems to 
be faster than the other methods.

NB. Native (platimg)
require'gui/gtk'
require 'media/platimg'  NB. not yet released for j701
coinsert 'jgtk'

L0=: 50           NB. initial length
A0=: 1r8p1        NB. initial angle: pi divided by 8
dL=: 0.9          NB. shrink factor for length
dA=: 0.75         NB. shrink factor for angle
N=: 14            NB. number of branches

L=: L0*dL^1+i.N  NB. lengths of line segments

NB. relative angles of successive line segments
A=: A0*(dA^i.N) +/\@:*("1) _1 ^ #:i.2 ^ N

NB. end points for each line segment
P=: 0 0+/\@,"2 +.*.inv (L0,0),"2 L,"0"1 A

NB. =========================================================
gtk_show=: 3 : 0
gtkinit ''
newwindow 'graph'
locGB=: 540 540 conew 'jgtkcanvas'
coinsert__locGB coname''
gtk_container_add window,gtkbox__locGB
windowfinish''
if. -.IFGTK do. gtk_main '' end.
)

NB. =========================================================
NB. this is the main drawing program
paint=: 3 : 0
wh=: glqwh''
NB. gdi stuff to generate bitmap data in glpixel format glpixels data 0
glinit_pplatimg_ wh
gllines_pplatimg_ <.(10 + ,/"2 P-"1<./,/P)
r=. getimg_pplatimg_ glput_pplatimg_ 'png'  NB. probably a more direct way to 
do this
glfree_pplatimg_''
glpixels 0 0 , wh , ,r
0
)

window_delete=: 0:

gtk_show ''

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

Reply via email to