-
Hi @pgundlach I already shown this code here: #542 (comment) Actually that code was made to discuss here… 😅 I haven't found in the documentation a method to control the opacity of any object in any given moment. However, as GUI-guy 🤦♂️, opacity is a parameter that I expect to have control anytime down the pipe line. Actually with Nevertheless working with the opensource taught me to adapt to the circumstances and I developed a workaround: <Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<DefineColor name="testA" model="RGB" r="255" g="178" b="32" alpha="100" />
<DefineColor name="testAA" model="RGB" r="255" g="178" b="32" alpha="80" />
<DefineColor name="testAAA" model="RGB" r="255" g="178" b="32" alpha="60" />
<DefineColor name="testAAAA" model="RGB" r="255" g="178" b="32" alpha="40" />
<!-- SPColor -->
<DefineGraphic name="s"> fill box withcolor spcolor(special); </DefineGraphic>
<Record element="data">
<SetVariable variable="op" select="'A'" />
<SetVariable variable="special" select="concat('test',$op)" type="mp:string"/>
<Loop select="4">
<PlaceObject>
<Box height="4" width="4" graphic="s" />
</PlaceObject>
<NextRow rows="2"/>
<SetVariable variable="op" select="concat($op,'A')" />
<SetVariable variable="special" select="concat('test',$op)" type="mp:string"/>
<Message select="$op" />
<Message select="$special" />
</Loop>
</Record>
</Layout> I believe this code can be further optimized but it is not the point. By any chance there is a method to control the opacity that is lesser cumbersome than the one here proposed? Thanks! 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
I see what you need. But there is currently no way to pass parameters to the metapost instance. I will think of it.
edit: your code is correct, except for the message at the end, there is no variable |
Beta Was this translation helpful? Give feedback.
-
I assume that you want something like this: <Box height="4" width="4" graphic="s">
<With-Param name="special" select="'testA'" as="mp:string" />
</Box> (I am not sure about the syntax, this should work with Td for example as well) |
Beta Was this translation helpful? Give feedback.
-
Perhaps the code is not the best but It worked. In my case I have often highlights info, no more than three by the way, that code will change color to each highlight box creating a nice effect. |
Beta Was this translation helpful? Give feedback.
-
Hi @pgundlach I resolved my issue with the "metapost colors" but it looks like my idea to switch color dynamically is not working out as I expected. The concept is this: I hope you are able to spot out the As on the open threads I have my color variations: <DefineColor name="npyellow" model="RGB" r="255" g="178" b="25" alpha="100"/>
<DefineColor name="npyellowA" model="RGB" r="255" g="178" b="25" alpha="80"/>
<DefineColor name="npyellowAA" model="RGB" r="255" g="178" b="25" alpha="60"/>
<DefineColor name="npyellowAAA" model="RGB" r="255" g="178" b="25" alpha="40" />
<DefineColor name="npyellowAAAA" model="RGB" r="255" g="178" b="25" alpha="20" /> The variables that control the <SetVariable variable="accentcolor" select="@accent" />
<SetVariable variable="accent" select="$accentcolor" type="mp:string" /> And this is the snippet that should change the color through a <!-- The variable that control accent color -->
<SetVariable variable="extracolor" select="$accentcolor"/>
<ForAll select="extra">
<!-- The variable that control opacity -->
<SetVariable variable="op" select=""/>
<Message select="concat('Start cycle: ',$extracolor)"/>
<PlaceObject column="1.3">
<Frame backgroundcolor="{$extracolor}"
framecolor="{$extracolor}"
border-bottom-left-radius="2mm"
border-bottom-right-radius="2mm"
border-top-left-radius="2mm"
border-top-right-radius="2mm">
<Table width="{$noc * 0.7}" padding="2mm">
<Tr>
<Td valign="middle" align="center">
<Paragraph fontfamily="pagenum">
<Value select="."/>
</Paragraph>
</Td>
</Tr>
</Table>
</Frame>
</PlaceObject>
<Message select="concat('Mid cycle: ',$extracolor)"/>
<SetVariable variable="op" select="concat($op,'A')"/>
<Message select="concat('OP Value: ', $op"/>
<SetVariable variable="extracolor" select="concat($extracolor,$op)"/>
<Message select="concat('end cycle: ',$extracolor)"/>
</ForAll> However instead to get same effect as the PDF above I get the same color for each frame: If I look at the
PlaceObject: Textblock at (1,19) wd/ht: 8/3 in "unit" (p. 7)
Call "NextRow" from layout
Call "SetVariable" from layout
Call "ForAll" from layout
Call "SetVariable" from layout
Call "Message" from layout
Message: "Start cycle: npyellow"
Call "PlaceObject" from layout
Call "Frame" from layout
Call "Table" from layout
Call "Tr" from layout
Call "Td" from layout
Call "Paragraph" from layout
Call "Value" from layout
PlaceObject: Table at (1,23) wd/ht: 8/4 in "unit" (p. 7)
Call "Message" from layout
Message: "Mid cycle: npyellow"
Call "SetVariable" from layout
Call "Message" from layout
Message: "OP Value: A"
Call "SetVariable" from layout
Call "Message" from layout
Message: "end cycle: npyellowA"
Call "SetVariable" from layout
Call "Message" from layout
Message: "Start cycle: npyellowA"
Call "PlaceObject" from layout
Call "Frame" from layout
Call "Table" from layout
Call "Tr" from layout
Call "Td" from layout
Call "Paragraph" from layout
Call "Value" from layout
PlaceObject: Table at (1,27) wd/ht: 8/4 in "unit" (p. 7)
Call "Message" from layout
Message: "Mid cycle: npyellowA"
Call "SetVariable" from layout
Call "Message" from layout
Message: "OP Value: A"
Call "SetVariable" from layout
Call "Message" from layout
Message: "end cycle: npyellowAA"
Call "SetVariable" from layout
Call "Message" from layout
Message: "Start cycle: npyellowAA"
Call "PlaceObject" from layout
Call "Frame" from layout
Call "Table" from layout
Call "Tr" from layout
Call "Td" from layout
Call "Paragraph" from layout
Call "Value" from layout
PlaceObject: Table at (1,31) wd/ht: 8/4 in "unit" (p. 7)
Call "Message" from layout
Message: "Mid cycle: npyellowAA"
Call "SetVariable" from layout
Call "Message" from layout
Message: "OP Value: A"
Call "SetVariable" from layout
Call "Message" from layout
Message: "end cycle: npyellowAAA"
Call "PlaceObject" from layout
PlaceObject: Group (unit) at (2,1) wd/ht: 1/1 in "_page" (p. 7) It looks to me that |
Beta Was this translation helpful? Give feedback.
-
Version 4.15.18 will be online in a few minutes and fix this error. Sorry... should have seen that. |
Beta Was this translation helpful? Give feedback.
Version 4.15.18 will be online in a few minutes and fix this error. Sorry... should have seen that.