Setting scale on custom symbol
Hello everyone - I have defined a custom symbol for electric light fixtures. The MetaPost code is below. Now that I have used it, I find that it draws the symbol too large. I tried using "-scale small" and "-scale tiny", and that helps. Rather than go through and add that to every point, I would like to change the MetaPost so it draws the symbol a bit smaller. And I am lazy! I could replot all the points for each of the lines. It seems to me there should be a simpler way. I tried messing with the U:= parameters, but they seem to make no difference whatever. Is there a way I can declare a multiplier in the MetaPost code? Perhaps declaring u = 0.6u? Thanks! -- Bill Gee # This code defines an artificial electric light. Used in tourist sections of a cave. def p_u_electriclight (expr pos,theta,sc,al) = U:=(0.3u, 0.3u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); thdraw (0.5u,0.0u) -- (0.5u, -0.6u); thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); enddef;
Hi Bill I think that merging what you have with an interim defaultscale:=0.6; variable as demonstrated by Thomas Holder here https://therion.speleo.sk/wiki/metapost#special_symbol_examples will do the trick. You probably want to keep the sc in def p_u_electriclight (expr pos,theta,sc,al), and multiply it by defaultscale before calling T:=identity... Probably some trial and error involved. Bruce -----Original Message----- From: Therion <therion-bounces@speleo.sk> On Behalf Of Bill Gee Sent: Monday, 13 May 2019 06:14 To: Therion Mail List <therion@speleo.sk> Subject: [Therion] Setting scale on custom symbol Hello everyone - I have defined a custom symbol for electric light fixtures. The MetaPost code is below. Now that I have used it, I find that it draws the symbol too large. I tried using "-scale small" and "-scale tiny", and that helps. Rather than go through and add that to every point, I would like to change the MetaPost so it draws the symbol a bit smaller. And I am lazy! I could replot all the points for each of the lines. It seems to me there should be a simpler way. I tried messing with the U:= parameters, but they seem to make no difference whatever. Is there a way I can declare a multiplier in the MetaPost code? Perhaps declaring u = 0.6u? Thanks! -- Bill Gee # This code defines an artificial electric light. Used in tourist sections of a cave. def p_u_electriclight (expr pos,theta,sc,al) = U:=(0.3u, 0.3u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC; thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); thdraw (0.5u,0.0u) -- (0.5u, -0.6u); thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); enddef; _______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion
From: https://www.researchgate.net/publication/265062623_Tutorial_in_MetaPost interim - Make a local change to an internal variable Martin Sluka
15. 5. 2019 v 9:23, Bruce Mutton <bruce@tomo.co.nz>:
Hi Bill I think that merging what you have with an interim defaultscale:=0.6; variable as demonstrated by Thomas Holder here https://therion.speleo.sk/wiki/metapost#special_symbol_examples will do the trick. You probably want to keep the sc in def p_u_electriclight (expr pos,theta,sc,al), and multiply it by defaultscale before calling T:=identity... Probably some trial and error involved. Bruce
-----Original Message----- From: Therion <therion-bounces@speleo.sk> On Behalf Of Bill Gee Sent: Monday, 13 May 2019 06:14 To: Therion Mail List <therion@speleo.sk> Subject: [Therion] Setting scale on custom symbol
Hello everyone -
I have defined a custom symbol for electric light fixtures. The MetaPost code is below. Now that I have used it, I find that it draws the symbol too large. I tried using "-scale small" and "-scale tiny", and that helps. Rather than go through and add that to every point, I would like to change the MetaPost so it draws the symbol a bit smaller.
And I am lazy! I could replot all the points for each of the lines. It seems to me there should be a simpler way. I tried messing with the U:= parameters, but they seem to make no difference whatever.
Is there a way I can declare a multiplier in the MetaPost code? Perhaps declaring u = 0.6u?
Thanks! -- Bill Gee
# This code defines an artificial electric light. Used in tourist sections of a cave. def p_u_electriclight (expr pos,theta,sc,al) = U:=(0.3u, 0.3u); T:=identity aligned al rotated theta scaled sc shifted pos; pickup PenC;
thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); thdraw (0.5u,0.0u) -- (0.5u, -0.6u); thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u);
enddef;
_______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion
_______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion
Hi Bruce and Martin - Thanks for the tips. I have figured out how to make it work. The new code looks like this: # This code defines an artificial electric light. Used in tourist sections of a cave. def p_u_electriclight (expr pos,theta,sc,al) = U:=(0.3u, 0.3u); % Reduce size of the symbol. The default size is too big. interim defaultscale:=0.4sc; T:=identity aligned al rotated theta scaled defaultscale shifted pos; pickup PenC; thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); thdraw (0.5u,0.0u) -- (0.5u, -0.6u); thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); enddef; I fiddled with the constant 0.4 to find a value that produces symbols about the size I wanted. A nice thing about this code is that it still respects the "-size xxx" parameters. What does the line "U:=(0.3u, 0.3u);" do? As far as I can tell, it has no effect at all. MetaPost is rather puzzling by having no explicit multiplication operator. The expression "0.4sc" does multiplication, but without any visible operator. The same happens for all the expressions involving "u". Back when I was studying computer science, that would have produced much vituperation from the professors! I think this code is now suitable for posting on the Wiki. I have several other custom symbols that might be useful to others: Pavement Boardwalk Tiled floor (all as area fills) Display case Boxwork Bear bed Pendant Stromatolite (These are points) Who should I send the code to for review and posting? -- Bill Gee On Wednesday, May 15, 2019 2:47:09 AM CDT Martin Sluka via Therion wrote:
From: https://www.researchgate.net/publication/265062623_Tutorial_in_MetaPost
interim - Make a local change to an internal variable
Martin Sluka
15. 5. 2019 v 9:23, Bruce Mutton <bruce@tomo.co.nz>:
Hi Bill I think that merging what you have with an interim defaultscale:=0.6; variable as demonstrated by Thomas Holder here https://therion.speleo.sk/wiki/metapost#special_symbol_examples will do the trick. You probably want to keep the sc in def p_u_electriclight (expr pos,theta,sc,al), and multiply it by defaultscale before calling T:=identity... Probably some trial and error involved. Bruce
-----Original Message----- From: Therion <therion-bounces@speleo.sk> On Behalf Of Bill Gee Sent: Monday, 13 May 2019 06:14 To: Therion Mail List <therion@speleo.sk> Subject: [Therion] Setting scale on custom symbol
Hello everyone -
I have defined a custom symbol for electric light fixtures. The MetaPost code is below. Now that I have used it, I find that it draws the symbol too large. I tried using "-scale small" and "-scale tiny", and that helps. Rather than go through and add that to every point, I would like to change the MetaPost so it draws the symbol a bit smaller.
And I am lazy! I could replot all the points for each of the lines. It seems to me there should be a simpler way. I tried messing with the U:= parameters, but they seem to make no difference whatever.
Is there a way I can declare a multiplier in the MetaPost code? Perhaps declaring u = 0.6u?
Thanks!
Hi Bill Thanks for sharing that code. I've added it to the wiki here https://therion.speleo.sk/wiki/metapost#point_-_artificial_electric_light Can you supply a screen grab of the symbol (with a white background), that I can include in the wiki page? (I should try it out myself, but I am taking a very minimal input approach here). There is a partial explanation of u: here https://therion.speleo.sk/wiki/metapost#symbol_sizing but I will admit to not knowing if it relates directly to U: Are u: and U: the same? I suspect not. Feel free any metapost knowledgeables who knows better... If you supply your symbols, either direct to me, or via the forum, I'll add them in due course. The https://therion.speleo.sk/wiki/metapos page really needs some rational structure imposed on it and its table of contents, so I might work on that as well. Posting direct to the forum will ensure people get the benefit of your work sooner! Bruce -----Original Message----- From: Therion <therion-bounces@speleo.sk> On Behalf Of Bill Gee Sent: Friday, 17 May 2019 06:51 To: therion@speleo.sk Subject: Re: [Therion] Setting scale on custom symbol Hi Bruce and Martin - Thanks for the tips. I have figured out how to make it work. The new code looks like this: # This code defines an artificial electric light. Used in tourist sections of a cave. def p_u_electriclight (expr pos,theta,sc,al) = U:=(0.3u, 0.3u); % Reduce size of the symbol. The default size is too big. interim defaultscale:=0.4sc; T:=identity aligned al rotated theta scaled defaultscale shifted pos; pickup PenC; thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); thdraw (0.5u,0.0u) -- (0.5u, -0.6u); thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); enddef; I fiddled with the constant 0.4 to find a value that produces symbols about the size I wanted. A nice thing about this code is that it still respects the "-size xxx" parameters. What does the line "U:=(0.3u, 0.3u);" do? As far as I can tell, it has no effect at all. MetaPost is rather puzzling by having no explicit multiplication operator. The expression "0.4sc" does multiplication, but without any visible operator. The same happens for all the expressions involving "u". Back when I was studying computer science, that would have produced much vituperation from the professors! I think this code is now suitable for posting on the Wiki. I have several other custom symbols that might be useful to others: Pavement Boardwalk Tiled floor (all as area fills) Display case Boxwork Bear bed Pendant Stromatolite (These are points) Who should I send the code to for review and posting? -- Bill Gee
There is a partial explanation of u: here https://therion.speleo.sk/wiki/metapost#symbol_sizing but I will admit to not knowing if it relates directly to U: Are u: and U: the same? I suspect not.
Hi, check also the chapter New map symbols / Point symbols in the Therion book (page 73) for an explanation of "u" and "U" variables. M.
Ok Master, I look for this. ThanksSent from my MetroPCS 4G LTE Android Device -------- Mensaje original --------De: Martin Budaj <m.budaj@gmail.com> Fecha: 22/5/19 12:46 PM (GMT-05:00) A: List for Therion users <therion@speleo.sk> Asunto: Re: [Therion] Setting scale on custom symbol There is a partial explanation of u: here https://therion.speleo.sk/wiki/metapost#symbol_sizing but I will admit to not knowing if it relates directly to U: Are u: and U: the same? I suspect not.Hi, check also the chapter New map symbols / Point symbols in the Therion book (page 73) for an explanation of "u" and "U" variables.M.
participants (5)
-
Bill Gee -
Bruce Mutton -
Martin Budaj -
Martin Sluka -
vlado6208