Thread: Lettering
View Single Post
 
Old 05-21-2023, 10:37 PM
Laurence Finston Laurence Finston is offline
Member
 
Join Date: Sep 2021
Location: Germany
Posts: 395
Total Downloaded: 0
Got this to work. The MetaPost macro `raindrop' takes 14 arguments, 9 of which determine the shape and position of the "raindrop" or "teardrop" shape.

The latter is derived from a circle, the center and radius of which is specified in the call to the macro. The point at the top is specified as a height value, e.g., 2cm, that determines the distance of the point R1 from the center (R0).

The raindrop consists of three paths that are joined: 1. a curve from a point on the original circle (R3) up to R1, 2. the mirror-image of this curve about a vertical line passing through the center of the circle and 3. a curve joining R3 and its reflection, R8, through the point R7. The latter determined by a parameter, which is a scalar value with units, specifying a distance below the points R3 and R8. The x-coordinate of R7 is that of the center of the original circle.

To get the combined path to curve nicely, the point R4 is found along the line R1 to R3. This is done by using the "mediation" or "of-the-way" function, i.e., R4 is 1/m "of the way" from R3 to R1, where `m' is a parameter to the macro. Then, the perpendicular to the line R3R1 passing through R4 is found, followed by the point R5, lying on the perpendicular on the opposite side of R3R1 to R4. Then, the mediation function is used again to find the point R6 along the line R4R5.

To get the combined curve to be smooth where the individual curves join at R3 and R8, "hints" are given to MetaPost to ensure that the direction of the curve is the same as that of the straight lines R3R1 and R8R1.

To get the curve to make a good point at the top (at R1), a default value of 87.5° is used to determine the direction of the curve as it travels from R6 to R1. However, this value may be modified by an additional parameter that is added or subtracted from the default value.

Another parameter determines the position of the resulting curve. If it's 0, it's not moved. If it's > 0, it's shifted upwards and if it's < 0, downwards.

There are two parameters for setting whether the help lines and curves and labels are printed, as well as the resulting curve itself.

Finally, two `path' variables are passed to the macro, which assigns the resulting curve and the original circle to them as their values.

I think the shapes I've found look pretty good. However, I'll have to try to get a series of raindrops that fit what I'm trying to achieve and, if experience is any guide, will have to make some modifications to the macro. A good way of optimizing macros is to try to "break" them by using extreme values for the parameters and trying to fix what goes wrong.

I think this is a good example of how it's possible to parameterize drawings using MetaPost, just as fonts are parameterized using METAFONT.
Attached Thumbnails
Lettering-april_showers.jpg  
Attached Files
File Type: pdf april_showers.pdf (12.4 KB, 2 views)
File Type: txt april_showers.mp.txt (16.3 KB, 1 views)
File Type: txt april_showers.txt (1.9 KB, 1 views)

Last edited by Laurence Finston; 05-21-2023 at 11:15 PM.
Reply With Quote