Hello Cliff,

I can't answer most of your questions.  I struggled to get  both axes to
agree and did succeed in an odd way.  Here are some of the fragments I've
worked on.

load 'plot'
NB. Homemade graph paper with equal scales on both axes. 
do=: 13 :'({.y) +(i.>:{:y)*(--/ 2{.y)%{:y'
A=:do _2 2 8 
V=:j./~ A
H=:|:|. V
'pensize 2;color 50 255 255' plot C=:H,V

NB. An example of a nice feature of viewmat.
NB.Graphs are not erased.

load 'viewmat'
*/~ i:18
viewmat */~ i:18   
viewmat (i.8)+/i.8

load 'plot'
x=:i:3j60
plot x^2
plot x^3

NB. With several examples, you must run and advance 
NB.and then close before continuing

A=:do _2 2 800 
plot A^2
'radar' plot V=:j./~A
'radar' plot A^2

I'm looking forward to following your progress as I have a number of things
I've been unable to do.  Nice to know you've moved to j8.  This script works
in both jhs and jqt.
However the difference are noticeable!

Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Cliff Reiter
Sent: Monday, May 05, 2014 11:40 AM
To: Programming forum
Subject: [Jprogramming] graph addon

Hi,
I have started puttering with J8.01 and in particular have been looking 
to create an analog of the graphics/fvj3/dwin.ijs addon that allows 
users to declare a range for x and y coordinates and open a window for 
plotting polygons and doing simple animations.
I have essentially duplicated that script using the graphics/graph/graph 
addon which seemed to be very nice starting place.
But I wonder
(1) is there an easy way in the graphics addon to control or hint about 
the desired window size or aspect ratio?
(2) is there an easy way to label the window with something other than 
the parent name?
(3) should I really be using wd gl2 commands instead?
(4) I wonder if there isn't a bug in gdarc01? Below is a fairly short 
example illustrating the point.
Best, Cliff

require '~addons/graphics/graph/graph.ijs'

NB. ------------------------------------------------

NB.* dwin v Opens a drawing window

NB. Example:

NB. _2 _3 2 3 dwin 'example'

NB. opens a drawing window where coordinates range

NB. from _2 to 2 in x and _3 to 3 in y and

NB. window name "example"

dwin=: 3 : 0 NB. pixel sized window drawing

0 0 1 1 dwin y

:

'a b c d'=.x

SC=:((-&(a,b)) %((c-a),d-b)"1)"1

gdopen y

gdshow''

)


NB. (0 0 255;3 0) darc x y w h x0 y0 x1 y1

NB. where x,y is a corner of the circumscribing box;

NB. w h is the extent;

NB. x0 y0 is on a ray from the center to the start point;

NB. x1 y1 is on a ray from the center to the end point;

darc=:3 : 0"1

(0 0 0;1 0) darc y

:

if. 32=3!:0 x do.

gdpencolor >{.x

gdpen >{:x

else. gdcolor x end.

'a b c d'=.4 2$y

'A B C D'=.SC a,(a+b),c,:d

gdarc01 x:^:_1 A,(B-A),C,D

gdshow''

)


_2 _2 2 2 dwin 'si'

(0 255 255;3 0) darc 0 0 2 2 2 0 0 2


draws the arc as though the circle's center is _1 1 instead of 1 1


-- 
Clifford A. Reiter
Lafayette College, Easton, PA 18042
http://webbox.lafayette.edu/~reiterc/

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

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

Reply via email to