Hello Duncan,
Le 2024-09-30 à 09:03, Duncan Losin via a écrit :
Hi folks, I have written a patch to add support for drawing arbitrary polygons in pic using the existing syntax for multi-segment lines. They can be shaded and filled as expected of other closed objects. Examples attached in polygon.pdf.
Tried the patch, it's terrific! I will include it in my tools :) Easily beats what I could do with my shallow knowledge of postscript.
There is also new syntax for referencing the positions of the vertices and edge midpoints: - .v[er[tex]] expr - .v[er[tex]] `expr' - .p[oint] expr - .p[oint] `expr'
Being able to work with points relative to the vertices or midpoints with .v `expr' + (1,2) is really a nice touch. I struggled a bit at first because I didn't read the documentation correctly :)
I must admit I have a very limited computer science education, so I expect my implementation could use some improvements; feedback would be appreciated. I'm not entirely pleased with how vertex_number is set, but I struggled with polygon_object not being instanced until the end of object_spec::make_line. That seems to be the general structure of the program so I didn't want to change it, but perhaps there's a better way to set the value, among other things.
I cannot help here in any way but I had no issues with for me it's good enough.
I've also included the following small documentation update. Where referring to ordinals the documentation included the characters " ` " and " ' " i.e. the grave accent and apostrophe. These are the correct characters, but groff draws these as the left and right quotation marks, which confused me when I tried to use this feature. I've updated those characters to the appropriate escape sequences "\[ga]" and "\[aq]" so that they appear properly. Future Work: If I understand it correctly (big if), PostScript interprets all polygons as a path, much like how pic draws multi-line segments. PostScript however can include arcs and splines as segments and fill the resulting shape. It doesn't look like it would be terribly difficult to implement this in pic, but it would be a lot of work. I believe pic, groff, and grops would all need to updated to accommodate the new drawing command.
That would be very nice, I wanted to draw the contour of a rail and having spline would make this feasible.
Thank you so much for this patch. -- Best, Thomas