Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

J graphics questions

8 views
Skip to first unread message

Brian

unread,
Nov 18, 2009, 10:45:35 PM11/18/09
to
I have been experimenting with graphics in J. I have a program
that I want to be able to use on my laptop at regular resolution
but also use on a projector which has a much lower resolution.
So I need to resize the program to fit the screen as well as
possible so the graphics area is large and easy to see. I don't
know how to determine the size of the parent window (e.g. if I
use sw_showmaximized instead of specifying the size), so I
determine the screen size and use, say, 90% of that as the
size of my graphics window. If I could determine the size of
the parent window, I could simply use sw_showmaximized,
which would be better, as it would take into account the
size of the operating system dock's, application bar, or
whatever. Now, some programs may take a while to draw
in the graphics window. So my second question is how to
make the program wait until the user finishes resizing the
window before starting to repaint the isigraph area, rather
that trying to continuously repaint as the user drags the edge
or corner of the window. I would also like to know how to
force the isigraph area to remain square as the window is
resized. I want to use rightmove and bottommove to let the
user resize the window, but then the isigraph can be
stretched into a rectangle, which sometimes distorts the
image. I also seem to be unable to have the window
redisplay after I draw each row of pixels. I would
appreciate any help you can give me with this.

Below is a simple toy program I am using to experiment
with J windows, as an example of what I am doing:

NB.
----------------------------------------------------------------------------
NB. Graphics test
NB.
----------------------------------------------------------------------------
require 'gl2'
coinsert 'jgl2'

WINDOW =: 0 : 0
pc Window;
menupop "File";
menu exit "&Exit";
menupopz;
menupop "Options";
menu redraw "&Redraw";
menupopz;
)

Window_close =: 3 : 0
wd 'timer 0; pclose'
)

Window_cancel_button =: 3 : 0
Window_close ''
)

Window_exit_button =: 3 : 0
Window_close ''
)

Window_redraw_button =: 3 : 0
wd 'psel Window; setinvalid display'
)

Window_display_paint =: 3 : 0
glclear ''

'rows cols' =. glqwh '' NB. size in pixels

glrgb 0 0 0
glbrush ''
glrect 0 0, cols, rows

for_row. i. rows do.
for_col. i. cols do.
c =. j./ OFFSET + SCALE * col, row
z =. 0j0
for_n. i. 256 do.
if. 2 < | z do.
glrgb ((# PALETTE) | 20 * n) { PALETTE
glpixel row,col
break.
else.
z =. c + z * z
end.
end.
end.
wd 'pshow;'
end.
)

NB.
----------------------------------------------------------------------------
NB. run - Main Program
NB.
----------------------------------------------------------------------------
run =: 3 : 0
BORDER =: 5

scrsize =. 4 8 * %/ 2 2 $ 0 ". wd 'qm;' NB. --- Screen size in xywh
units
size =. <. 0.80 * <./ scrsize

PALETTE =: |. 0 0 1 {"1 ] 0 ,. i. 256
SCALE =: 0.004
OFFSET =: -2

wd WINDOW
wd 'xywh ',(": BORDER, BORDER, size, size),';cc display isigraph
rightmove bottommove;'
wd 'pas ',(": 2 # BORDER),'; pshow;'
)

NB.
----------------------------------------------------------------------------
NB. Autostart on load

run ''

David Liebtag

unread,
Nov 19, 2009, 9:22:10 AM11/19/09
to
Brian,

I don't know whether J lets you intercept operating system messages, but if
it does, (and you're running on Windows) you could watch for the
WM_ENTERSIZEMOVE message and ignore all WM_SIZE messages until you see
WM_EXITSIZEMOVE.

David Liebtag


Björn Helgason, j-programming

unread,
Nov 30, 2009, 10:52:22 AM11/30/09
to
On Nov 19, 3:45 am, Brian <mcgui...@fdu.edu> wrote:
> run =: 3 : 0
>   BORDER =: 5
>
>   scrsize =. 4 8 * %/ 2 2 $ 0 ". wd 'qm;'  NB. --- Screen size in xywh
> units
>   size    =. <. 0.80 * <./ scrsize
>
>   PALETTE =: |. 0 0 1 {"1 ] 0 ,. i. 256
>   SCALE   =: 0.004
>   OFFSET  =: -2
>
>   wd WINDOW
>   wd 'xywh ',(": BORDER, BORDER, size, size),';cc display isigraph
> rightmove bottommove;'
>   wd 'pas ',(": 2 # BORDER),'; pshow;'
> )
>
> NB.
> ----------------------------------------------------------------------------
> NB. Autostart on load
>
> run ''

I tried your example and it was hanging forever until I changed the
size in run to

size =: <. 0.80 * <./ scrsize
size=:size%10


Ric

unread,
Nov 30, 2009, 7:42:01 PM11/30/09
to

I suspect you will get a better response to questions like this on the
J programming forum.
http://www.jsoftware.com/jwiki/System/Forums

Will wd 'qformx' be of use?
The Window_display_paint verb is very slow/processor intensive. Have
you thought about creating the pixel array first and then using
glpixels or glpixelsx to update the isigraph control?

Is the following link of interest?
http://rosettacode.org/wiki/Mandelbrot_set#J

0 new messages