Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
metapost [2020/03/01 22:57]
tarquinwj grammar
metapost [2020/03/01 22:58] (current)
tarquinwj [Adding custom styled labels at any point/linepoint]
Line 271: Line 271:
 For an example of code making use of this function, see [[#Rope lengths]] below. For an example of code making use of this function, see [[#Rope lengths]] below.
  
-If you want to add custom label styles, you need to call "​thelabel.suffix(thetext,​position)"​ with the right alignment suffix, save the return value in a variable called "​lab",​ then call "​process_label(position,​rotation)"​. After that, you can check "bbox lab" to get the bounding box of the text label as a path which can be used to draw the decoration. You can temporarily ("​interim"​) set the internal "​bboxmargin"​ variable to make the bounding box larger than the text. You should use "​begingroup+endroup"​ within a "​def"​ when using the "​interim"​ operator to make sure it gets reset correctly afterwards, or use a vardef instead of a def.+If you want to add custom label styles, you need to call "​thelabel.suffix(thetext,​position)"​ with the right alignment suffix, save the return value in a variable called "​lab",​ then call "​process_label(position,​rotation)"​. After that, you can check "bbox lab" to get the bounding box of the text label as a path which can be used to draw the decoration. You can temporarily ("​interim"​) set the internal "​bboxmargin"​ variable to make the bounding box larger than the text, to create some padding between the text and your ornamentation. You should use "​begingroup+endroup"​ within a "​def"​ when using the "​interim"​ operator to make sure it gets reset correctly afterwards, or use a vardef instead of a def.
  
 Use "​rotatedaround (position,​rotation)"​ when drawing the ornamentation to make sure it gets rotated and aligned the same as the label. Note that this applies the rotation around the point position, so alignment and rotation at the same time is weird. This is the same with regular labels though - known Therion bug - so at least this is consistent with Therion itself. Use "​rotatedaround (position,​rotation)"​ when drawing the ornamentation to make sure it gets rotated and aligned the same as the label. Note that this applies the rotation around the point position, so alignment and rotation at the same time is weird. This is the same with regular labels though - known Therion bug - so at least this is consistent with Therion itself.
  • metapost.txt
  • Last modified: 5 weeks ago
  • by tarquinwj