Learning APL or new to Dyalog? Ask "silly" questions here, without fear...


Postby Stu on Wed Mar 16, 2016 9:10 pm

I'd like to draw arbitrary shapes with "polyline" (Rainpro). I have the n×2 arrays of x-y coordinates that specify the vertices of the figures, but I can't figure out from the Rainpro documentation for polylines exactly how to use these points to draw figures ("ch.Draw - add arbitrary polylines" and "ch.MapCoords - map from chart space to frame" appear to describe what I want, but there's not enough information to solve my problem).
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Re: polyline

Postby Stu on Sat Mar 19, 2016 4:46 pm

I solved my own problem, sort of. For anyone who's interested, here's the solution:

polyline T;rt;x;y;data;PG;⎕IO
T←T+16 ⍝ offset from picture frame
x←(rt⍴1 0)/T
y←(rt⍴0 1)/T
:If ((1↑x)≠¯1↑x)∧(1↑y)≠¯1↑y
ch.Draw ch.MapCoords data
PostScrp.Clip PG ⍝ puts the shape on the clipboard
PostScrp.View PG ⍝ displays the shape on the screen
⍝ 'C:\Users\Stuart Smith\Desktop\shape' ToPNG PG

Argument T is a vector of coordinates that the calling program scales to the range 0-255. The X values are those in the even-numbered locations of T; the Y values are those in the odd-numbered locations. The final line of the definition is commented out because it gives VALUE ERROR. The rainpro doc says this is how you save an image file, but it doesn't work.
Posts: 97
Joined: Thu Dec 31, 2015 1:30 am

Return to New to Dyalog?

Who is online

Users browsing this forum: No registered users and 1 guest