metapost

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
metapost [2019/06/02 22:55] – [Symbol Sizing and Positioning] add u box to symbol parameter indicator code brucemuttonmetapost [2019/06/02 23:11] – [Symbol Sizing and Positioning] clarify symbol parameter indicator brucemutton
Line 101: Line 101:
   * Your symbols should generally be defined so that they fit within the size range -0.5u to +0.5u in both x and y axes, although you can use larger or smaller values in either dimension.  This is because we generally want the map symbols to be about ‘u’ in size.     * Your symbols should generally be defined so that they fit within the size range -0.5u to +0.5u in both x and y axes, although you can use larger or smaller values in either dimension.  This is because we generally want the map symbols to be about ‘u’ in size.  
  
-This image is a symbol that has been defined with maximum x and y coordinates of 0.7u, both positive and negative.  The insertion point is at the intersection of the cross hairs, and the pdf has been exported with a rotate value of 15 degrees.  It has been overlaid with some code that highlights the origin and alignment loci, as described below.+This image is a symbol that has been defined with maximum x and y coordinates, supposedly, of 0.7u, both positive and negative.  The insertion point is at the intersection of the cross hairs, and the pdf has been exported with a rotate value of 15 degrees.  It has been overlaid with some code that highlights the origin and alignment loci, and unit symbol size, u, as described below.
  
 {{:metapost:symbol0.7x0.7notaligned.png?200 |Symbol 0.7u x 0.7u.  (0,0) at the intersection of the cross hairs,  pdf exported with rotate value of 15 degrees}} {{:metapost:symbol0.7x0.7notaligned.png?200 |Symbol 0.7u x 0.7u.  (0,0) at the intersection of the cross hairs,  pdf exported with rotate value of 15 degrees}}
Line 107: Line 107:
  
  
-In addition, the symbol alignment option relies on the definition of a U: variable, otherwise your symbol will cause an error and stop Therion if a user sets an alignment option other than ''centre''.  +The symbol alignment option relies on the definition of a U: variable, otherwise your symbol will cause an error and stop Therion if a user sets an alignment option other than ''centre''.  The U: variable is depicted by the light blue box.
   * U: is a scaling factor for alignment parameters, such as right, top or top-right.   * U: is a scaling factor for alignment parameters, such as right, top or top-right.
 U: defines the size of the x horizontal (left-right) and y vertical (up-down) offset when a symbol is aligned, so the x and y components of U: should be set to be around the maximum absolute value of x and y symbol coordinates, respectively.  ie for a symmetrically placed symbol who’s perimeter will just touch the insertion point, set U:=(0.5x symbol width, 0.5x symbol height). U: defines the size of the x horizontal (left-right) and y vertical (up-down) offset when a symbol is aligned, so the x and y components of U: should be set to be around the maximum absolute value of x and y symbol coordinates, respectively.  ie for a symmetrically placed symbol who’s perimeter will just touch the insertion point, set U:=(0.5x symbol width, 0.5x symbol height).
Line 115: Line 115:
   * If your symbol has its greatest dimension on a diagonal, then you should increase the U: components accordingly, to avoid unintentional drawing overlaps for aligned symbols.   * If your symbol has its greatest dimension on a diagonal, then you should increase the U: components accordingly, to avoid unintentional drawing overlaps for aligned symbols.
  
-As one 'use case' for aligning symbols is to enable them to be placed ‘near’ to another symbol, and be always positioned appropriately at a variety of output scales, I am going to suggest that U: components for user friendly point symbols should always be just a little greater than half the symbol dimension.  That way, an aligned symbol can always leave a pleasing small gap from its insertion point.+As one 'use case' for aligning symbols is to enable them to be placed ‘near’ to another symbol, and be always positioned appropriately at a variety of output scales, I am going to suggest that U: components for user friendly point symbols should always be just a little greater than half the symbol dimension.  ie the light blue box should enclose the symbol.  That way, an aligned symbol can always leave a pleasing small gap from its insertion point.
  
-When writing a new point symbol and testing that it aligns and rotates nicely, it can be a bit tricky to figure out where the origin, insertion point, and alignment loci are located.  So have written some code that you can temporarily place inside a symbol, to get a visual representation of how well placed its origin and alignment loci are with respect to its insertion point.+When writing a new point symbol and testing that it aligns and rotates nicely, it can be a bit tricky to figure out where the origin, insertion point, and alignment loci are located.  So have written some code that you can temporarily place inside a symbol, to get a visual representation of how well placed its origin and alignment loci are with respect to its insertion point, and of its size compared to the nominal default size of u.
  
-Here it is inserted into an electric light symbol.  The code is between the lines with % % %.  It creates a green insertion point, a red origin point that represents the (0u, 0u) origin of the symbol, and a light blue rectangle that represents the loci of the alignment options (left, top-left etc). Note that this code requires that T:= ... rotated BEFORE aligned.  If your symbol uses T:= ... aligned BEFORE rotated, then the code needs to be modified slightly.  After writing the code, I realised that the symbol was in fact larger than 0.7u in the y direction!+Here it is inserted into an electric light symbol definition.  The code is between the lines with % % %.  It creates a green insertion point, a red origin point that represents the (0u, 0u) origin of the symbol, a light blue rectangle that represents the loci of the alignment options (left, top-left etc), and a grey unit symbol size. Note that this code requires that T:= ... rotated BEFORE aligned.  If your symbol uses T:= ... aligned BEFORE rotated, then the code needs to be modified slightly.   
 + 
 +After writing the code, I realised that this symbol was in fact larger than 0.7u in the y direction, the symbol is not centered around around its (0u,0u) coordinates and it is just a bit (but probably acceptably) larger than u in size!
  
 <code> <code>
  • metapost.txt
  • Last modified: 2 years ago
  • by tarquinwj