groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drawing an arbitrary shaded shape with pic


From: Philippe PITTOLI
Subject: Drawing an arbitrary shaded shape with pic
Date: Thu, 12 Sep 2024 22:01:21 +0200

Hello,

I've been trying to do something as simple as drawing a triangle
filled with some color with gpic and so far I spectacularly failed.

I don't see any way to draw an arbitrary (shaded) polygon with gpic,
but it's do-able with groff directly: \D'P x1 y1 x2 y2'. So, I did
a groff macro… that I called from a pic macro.

.de triangle
\D'P \\$1 \\$2 \\$3 \\$4'
..

.PS 7 9
define triangle {
.gcolor $1
.fcolor $1
command ".triangle " $2 " " $3 " " $4 " " $5
.gcolor
.fcolor
}

x1 = 3
y1 = 3
x2 = -6
y2 = 0

triangle(green, x1, y1, x2, y2)
triangle(red,   x1, y1, x2, y2)
triangle(pink,  x1, y1, x2, y2)
.PE

It works great, but now I don't know how to position my triangles.
Is there a simple way to do it?

My next attempt will be to pass the position of where I want to
start drawing from pic to groff, passing the values to the "command"
instruction… but it's already overly convoluted for something as
simple as drawing a triangle, tbf. There has to be a simpler solution,
right?

Thanks a lot,
Have a great day,
-- 
Philippe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]