Generating number circles in SVG - how to centre the text [duplicate] - bash
This question already has an answer here:
How to draw a number centered inside a circle with inline svg?
(1 answer)
Closed 7 years ago.
I have written a script to generate SVG files showing 1 numbers in circles. This is for use in a drawing app as clipart.
Here is the script:
if [ ! -d circleNums ]
then
mkdir circleNums
fi
rm circleNums/index.html
# Add this line for center guide <line x1="63" y1="0" x2="63" y2="128" style="stroke:rgb(255,127,64);stroke-width:2"/>
for I in {1..9}
do
cat <<EOF > circleNums/$I.svg
<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' >
<circle cx="64" cy="64" r="62" fill="rgb(0,100,0)" stroke="red" stroke-width="2"/>
<text x="35" y="95" font-family="sans-serif" font-size="90px" fill="white">$I</text>
</svg>
EOF
echo "<img src=\"$I.svg\" >" >> circleNums/index.html
done
for I in {10..99}
do
cat <<EOF > circleNums/$I.svg
<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' >
<circle cx="64" cy="64" r="62" fill="rgb(0,100,0)" stroke="red" stroke-width="2"/>
<text x="15" y="95" font-family="sans-serif" font-size="90px" fill="white">$I</text>
</svg>
EOF
echo "<img src=\"$I.svg\" >" >> circleNums/index.html
done
ls circleNums
Example of output, 1.svg:
<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' >
<circle cx="64" cy="64" r="62" fill="rgb(0,100,0)" stroke="red" stroke-width="2"/>
<text x="35" y="95" font-family="sans-serif" font-size="90px" fill="white">1</text>
</svg>
99.svg:
<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' >
<circle cx="64" cy="64" r="62" fill="rgb(0,100,0)" stroke="red" stroke-width="2"/>
<text x="15" y="95" font-family="sans-serif" font-size="90px" fill="white">99</text>
</svg>
As you can see the centring is guess work and experimentation based. How can I get the text to centre about a particular point, in this case x=64, y=64?
I made small changes to your script:
I merged two loops into one
I replaced x and y to 50% like you'd expect from a centered text
I used text-anchor="middle" property to make the text render centered (relative to image center)
I used dy=".35em" to correct vertical shift - it looks good enough to me. Other fonts might need other values.
if [ ! -d circleNums ]
then
mkdir circleNums
fi
rm circleNums/index.html
# Add this line for center guide <line x1="63" y1="0" x2="63" y2="128" style="stroke:rgb(255,127,64);stroke-width:2"/>
for I in {1..99}
do
cat <<EOF > circleNums/$I.svg
<svg width='128' height='128' viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg' version='1.1' >
<circle cx="64" cy="64" r="62" fill="rgb(0,100,0)" stroke="red" stroke-width="2"/>
<text text-anchor="middle" x="50%" y="50%" dy=".35em" font-family="sans-serif" font-size="90px" fill="white">$I</text>
</svg>
EOF
echo "<img src=\"$I.svg\" >" >> circleNums/index.html
done
ls circleNums
Result:
Related
Which Resharper Setting controls alignment of Lambdas
I have this code ToggleAnalyzeCmd = new DelegateCommand( () => { if (IsAnalyzing) CancelAnalysis(); else Analyze(false); }, () => IsAnalyzing) .ObservesProperty(() => IsAnalyzing); But when I type it or reformat it with Resharper (version 2022.3.1), it really wants those two lambdas to be lined up right under the DelegateCommand No matter how far to the right that is. Here is what I get if I select the block of code and use Resharper's "FormatCode" command ToggleAnalyzeCmd = new DelegateCommand( () => { if (IsAnalyzing) CancelAnalysis(); else Analyze(false); }, () => IsAnalyzing) .ObservesProperty(() => IsAnalyzing); Looking at Options >> Code Editing >> C# >> Tabs, Indents, Alignment, I am trying to find what setting controls this I tried checking/unchecking the most obvious candidate; This setting: Align multiline constructs >> Anonymous Method Body It has no effect. My code still gets indented regardless. I don't see any other setting that looks like it could. Anyone know what setting I am looking for? EDIT: By request I am sharing my resharper settings file - just the code editing and code-style properties. This is long though <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <s:String x:Key="/Default/CodeEditing/GenerateMemberBody/MethodImplementationKind/#EntryValue">ReturnDefaultValue</s:String> <s:Boolean x:Key="/Default/CodeEditing/GenerateMemberBody/WrapIntoRegions/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/AutoCompleteSmartCompletion/#EntryValue">False</s:Boolean> <s:String x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/EditorBrowsableProcessing/#EntryValue">Advanced</s:String> <s:String x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/ParenthesesInsertType/#EntryValue">Left</s:String> <s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/ReplaceKeywordsWithTemplates/#EntryValue">False</s:Boolean> <s:String x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/NonCompletingCharacters/#EntryValue">.,;</s:String> <s:String x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/NonCompletingCharacters/#EntryValue">.,;</s:String> <s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/#EntryValue">True</s:Boolean> <s:String x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowAnnotations/#EntryValue">All</s:String> <s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/UseCompletionFontForLookups/#EntryValue">False</s:Boolean> <s:String x:Key="/Default/CodeEditing/TypingAssist/BraceInsertType/#EntryValue">DISABLED</s:String> <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/InsertAsteriskInBlockComments/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/SkipClosingBracesOnTabInIndentPosition/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/SkipClosingBracesOnTabInStringLiterals/#EntryValue">True</s:Boolean> <s:String x:Key="/Default/CodeEditing/TypingAssist/SmartBackspace/#EntryValue">OFF</s:String> <s:Boolean x:Key="/Default/CodeEditing/TypingAssist/SurroundTypingEnabled/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_BINARY_PATTERNS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_CALLS_CHAIN/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_EXTENDS_LIST/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_FOR_STMT/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_PARAMETER/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_STATEMENT_CONDITIONS/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTIPLE_DECLARATION/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_CONSTRAINS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_LIST/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_TUPLE_COMPONENTS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALLOW_FAR_ALIGNMENT/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_BRACES_INSIDE_STATEMENT_CONDITIONS/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_CASE_FROM_SWITCH/#EntryValue">False</s:Boolean> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_INVOCATION_PARS/#EntryValue">OUTSIDE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_METHOD_DECL_PARS/#EntryValue">OUTSIDE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_PARS/#EntryValue">OUTSIDE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_STATEMENT_PARS/#EntryValue">OUTSIDE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_TYPEARG_ANGLES/#EntryValue">OUTSIDE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_TYPEPARAM_ANGLES/#EntryValue">OUTSIDE</s:String> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_ASSIGNMENTS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_BINARY_EXPRESSIONS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_COMMENTS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_FIELDS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_INVOCATIONS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_METHODS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_NESTED_TERNARY/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_PARAMETERS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_PROPERTIES/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_PROPERTY_PATTERNS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_SWITCH_SECTIONS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INT_ALIGN_VARIABLES/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_DECLARATION_BLOCK_ARRANGEMENT/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OUTDENT_COMMAS/#EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ABSTRACT_ACCESSORHOLDER_ON_SINGLE_LINE/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/USE_INDENT_FROM_VS/#EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_DECLARATION_LPAR/#EntryValue">True</s:Boolean> <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/#EntryValue">165</s:Int64> <s:Boolean x:Key="/Default/CodeStyle/Generate/=Implementations/#KeyIndexDefined">True</s:Boolean> <s:String x:Key="/Default/CodeStyle/Generate/=Implementations/Options/=Mutable/#EntryIndexedValue">False</s:String> <s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/IsNotificationDisabled/#EntryValue">True</s:Boolean></wpf:ResourceDictionary>
perfectly looping svg animation
I am trying to loop an audio wave svg so that it's perfectly looping but I cannot figure it out. I currently have the below, however, as you will see the loop is not perfect. Is there an easy way to do this? Or can someone point me in the right direction? <?xml version="1.0" encoding="utf-8"?> <svg version="1.1" id="waveform" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 220 100" style="enable-background:new 0 0 220 100;" xml:space="preserve"> <g id="waveform"> <path d="M186.4,0c-1.3,0.1-2.2,1.3-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6V2.6C188.6,1.1,187.7,0,186.4,0z"/> <path d="M69.4,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V22.8C71.6,21.3,70.7,20.2,69.4,20.2z"/> <path d="M58.7,0c-1.2,0.1-2.2,1.3-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6V2.6C60.9,1.1,60,0,58.7,0z"/> <path d="M101.2,11.9c-1.2,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6v-71C103.4,13,102.5,11.9,101.2,11.9z"/> <path d="M48.2,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6V22.8C50.4,21.3,49.4,20.2,48.2,20.2z"/> <path d="M90.7,35.6c-1.3,0-2.2,1.2-2.2,2.6V62c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V38.2C92.9,36.7,91.9,35.6,90.7,35.6z"/> <path d="M16.2,22.1C15,22.2,14,23.3,14,24.7v50.6c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6V24.7C18.4,23.2,17.4,22.1,16.2,22.1z"/> <path d="M5.7,35.6c-1.3,0-2.2,1.2-2.2,2.6V62c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6V38.2C7.9,36.7,6.9,35.6,5.7,35.6z"/> <path d="M37.4,11.9c-1.2,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C39.7,13,38.7,11.9,37.4,11.9z"/> <path d="M26.9,35.6c-1.3,0-2.2,1.2-2.2,2.6V62c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V38.2C29.1,36.7,28.2,35.6,26.9,35.6z"/> <path d="M80,11.9c-1.2,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C82.2,13,81.2,11.9,80,11.9z"/> <path d="M154.4,35.6c-1.3,0-2.2,1.2-2.2,2.6V62c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V38.2C156.7,36.7,155.7,35.6,154.4,35.6z"/> <path d="M165.2,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C167.4,13,166.4,11.9,165.2,11.9z"/> <path d="M197,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V22.8C199.2,21.3,198.2,20.2,197,20.2z"/> <path d="M207.7,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C209.9,13,208.9,11.9,207.7,11.9z"/> <path d="M175.7,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V22.8C177.9,21.3,177,20.2,175.7,20.2z"/> <path d="M122.7,0c-1.4,0.1-2.2,1.3-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V2.6C124.9,1.1,123.9,0,122.7,0z"/> <path d="M111.9,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V22.8 C114.2,21.3,113.2,20.2,111.9,20.2z"/> <path d="M133.2,20.2c-1.3,0-2.2,1.2-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6V22.8 C135.4,21.3,134.4,20.2,133.2,20.2z"/> <path d="M143.9,11.9c-1.4,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.1,2.2-2.6v-71C146.1,13,145.2,11.9,143.9,11.9z"/> <path d="M-121.9,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C-119.7,21.2-120.6,20.1-121.9,20.1z"/> <path d="M-89.9,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C-87.7,13-88.6,11.9-89.9,11.9z"/> <path d="M-111.4,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.4-0.1,2.2-1.3,2.2-2.6V2.6C-109.1,1.1-110.1,0-111.4,0z"/> <path d="M-100.6,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C-98.4,21.2-99.4,20.1-100.6,20.1z"/> <path d="M-79.4,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38C-77.2,36.5-78.1,35.4-79.4,35.4z"/> <path d="M-68.6,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C-66.4,13-67.4,11.9-68.6,11.9z"/> <path d="M-36.9,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7C-34.6,21.2-35.6,20.1-36.9,20.1z"/> <path d="M-47.4,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.2-0.1,2.2-1.3,2.2-2.6V2.6C-45.2,1.1-46.1,0-47.4,0z"/> <path d="M-58.1,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7C-55.9,21.2-56.9,20.1-58.1,20.1z"/> <path d="M-15.6,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38C-13.4,36.5-14.3,35.4-15.6,35.4z"/> <path d="M-4.9,22.1c-1.3,0-2.2,1.1-2.2,2.6v50.6c0,1.5,1,2.6,2.2,2.6c1.2-0.1,2.2-1.2,2.2-2.6V24.7C-2.7,23.2-3.6,22.1-4.9,22.1z"/> <path d="M-185.7,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C-183.4,21.2-184.4,20.1-185.7,20.1z"/> <path d="M-196.4,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C-194.2,13-195.1,11.9-196.4,11.9z"/> <path d="M-26.1,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C-23.9,13-24.9,11.9-26.1,11.9z"/> <path d="M-164.4,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C-162.2,21.2-163.1,20.1-164.4,20.1z"/> <path d="M-175.1,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.3-0.1,2.2-1.3,2.2-2.6V2.6C-172.9,1.1-173.9,0-175.1,0z"/> <path d="M-143.1,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38 C-140.9,36.5-141.9,35.4-143.1,35.4z"/> <path d="M-153.9,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C-151.6,13-152.6,11.9-153.9,11.9z"/> <path d="M-132.6,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.4,0,2.2-1.1,2.2-2.6v-71C-130.4,13-131.4,11.9-132.6,11.9z"/> <path d="M282.2,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C284.4,21.2,283.4,20.1,282.2,20.1z"/> <path d="M314.2,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C316.4,13,315.4,11.9,314.2,11.9z"/> <path d="M292.7,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.4-0.1,2.2-1.3,2.2-2.6V2.6C294.9,1.1,294,0,292.7,0z"/> <path d="M303.4,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C305.7,21.2,304.7,20.1,303.4,20.1z"/> <path d="M324.7,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38C326.9,36.5,325.9,35.4,324.7,35.4z"/> <path d="M335.4,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C337.6,13,336.7,11.9,335.4,11.9z"/> <path d="M367.2,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C369.4,21.2,368.5,20.1,367.2,20.1z"/> <path d="M356.7,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.2-0.1,2.2-1.3,2.2-2.6V2.6C358.9,1.1,357.9,0,356.7,0z"/> <path d="M345.9,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C348.2,21.2,347.2,20.1,345.9,20.1z"/> <path d="M388.5,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38C390.7,36.5,389.7,35.4,388.5,35.4z"/> <path d="M401.4,24.7c0-1.5-1-2.6-2.2-2.6c-1.3,0-2.2,1.1-2.2,2.6v50.6c0,1.5,1,2.6,2.2,2.6c1.2-0.1,2.2-1.2,2.2-2.6"/> <path d="M218.4,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C220.6,21.2,219.7,20.1,218.4,20.1z"/> <path d="M377.9,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.2,0,2.2-1.1,2.2-2.6v-71C380.1,13,379.2,11.9,377.9,11.9z"/> <path d="M239.7,20.1c-1.3,0-2.2,1.1-2.2,2.6v54.5c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V22.7 C241.9,21.2,240.9,20.1,239.7,20.1z"/> <path d="M228.9,0c-1.3,0-2.2,1.1-2.2,2.6v94.8c0,1.5,1,2.6,2.2,2.6c1.3-0.1,2.2-1.3,2.2-2.6V2.6C231.2,1.1,230.2,0,228.9,0z"/> <path d="M260.9,35.4c-1.3,0-2.2,1.1-2.2,2.6v23.8c0,1.5,1,2.6,2.2,2.6c1.3,0,2.2-1.2,2.2-2.6V38C263.1,36.5,262.2,35.4,260.9,35.4z"/> <path d="M250.2,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6s2.2-1.1,2.2-2.6v-71C252.4,13,251.4,11.9,250.2,11.9z"/> <path d="M271.4,11.9c-1.3,0-2.2,1.1-2.2,2.6v71c0,1.5,1,2.6,2.2,2.6c1.4,0,2.2-1.1,2.2-2.6v-71C273.7,13,272.7,11.9,271.4,11.9z"/> <animateTransform attributeName="transform" type="translate" from="0 0" to="-160 0" repeatCount="indefinite" dur="2.5s"/></g> </svg> I also want this to be pure SVG - no JS solutions please
You can use <use/> to make a copy of the wave and render it on the right of the wave. You would have to however, adjust the <animateTransform/> element appropriately: <animateTransform attributeName="transform" type="translate" from="0 0" to="-604.4 0" repeatCount="indefinite" dur="9.375s"/></g> <use href="#waveform" x="604.4"/>
How to get the RGB values of a 256-color palette terminal color
Thanks to ANSI escape codes, when you run: echo -e "\e[38;5;74mHi" This will display "Hi", colored with the palette color 74 (commonly a blue/cyan, but it may be another color, depending on the defined palette): But how can I retrieve the red/green/blue components of the given color (74 in this example) actually shown by the terminal emulator? Expected result Run this imaginary command in bash: $ palette-to-rgb 74 Expected output: #5fafd7 # Or any other parsable output like rgb(95,175,215) What did I try The only (ugly) way I found to get the RGB components is to make a screenshot and use some graphical program like gimp to retrieve the RGB values.
I think it's not possible to retrieve the color codes programmatically. A possible way would be a kind of ANSI sequence, but it doesn't seem to exist. So as a workaround, it is possible to get the standard values; I made this bash script for this aim (for int calculations, I got help from the source of st): #!/bin/bash usage() { echo "palette-to-rgb [COL] [-rgb] [-raw] [-C] [-h]" echo "Show RGB values of the standard terminal 256-color palette." echo "If COL is given (number 0-255), show only the given color." echo "Options:" echo " -rgb Format as \"rgb(R, G, B)\" instead of \"#RRGGBB\"" echo " -raw Show the value only" echo " -C Force coloring even when piped" } std_colors=( 0 0 0 # 0 black 128 0 0 # 1 red 0 128 0 # 2 green 128 128 0 # 3 yellow 0 0 128 # 4 blue 128 0 128 # 5 magenta 0 128 128 # 6 cyan 192 192 192 # 7 white (light grey) 128 128 128 # 8 grey 255 0 0 # 9 bright red 255 255 0 # 10 bright green 0 255 0 # 11 bright yellow 0 0 255 # 12 bright blue 255 0 255 # 13 bright magenta 0 255 255 # 14 bright cyan 255 255 255 # 15 bright white ) # 6x6x6 cube color component cube_component() { local i=$(( (($1 - 16) / $2) % 6 )) (( $i == 0 )) && echo 0 || echo $(( ( 14135 + 10280 * $i ) / 256 )) } get_color() { local r g b fmt if (( $1 < 16 )); then r=${std_colors[$(( $1 * 3 + 0 ))]} g=${std_colors[$(( $1 * 3 + 1 ))]} b=${std_colors[$(( $1 * 3 + 2 ))]} elif (( $1 < 232 )); then # < 6*6*6+16 ? # colors 16-231 (6x6x6 cube): r=$(cube_component $1 36) g=$(cube_component $1 6) b=$(cube_component $1 1) else # colors 232-255 (grayscale): r=$(( ( 2056 + 2570 * ($1 - 232) ) / 256 )) g=$r b=$r fi [[ -n $rgb ]] && fmt='rgb(%i, %i, %i)' || fmt='#%02x%02x%02x' printf "$fmt\n" $r $g $b } print_color() { if [[ -n $raw ]]; then get_color $1 else # Show a colored box if not piped (or with option -C) [[ -t 1 || -n $colored ]] && echo -en "\e[48;5;${1}m \e[0m " printf '%03i: %s\n' $1 "$(get_color $1)" fi } color= colored= rgb= raw= for arg in "$#"; do if [[ $arg == -h ]]; then usage; exit elif [[ $arg =~ ^[0-9]+$ ]]; then (( $arg > 255 )) && { echo "Wrong color code" >&2; exit 1; } color=$arg elif [[ $arg == -C ]]; then colored=1 elif [[ $arg == -rgb ]]; then rgb=1 elif [[ $arg == -raw ]]; then raw=1 else echo "Wrong arg: $arg" >&2; exit 1 fi done if [[ -n $color ]]; then print_color $color else for n in {0..255}; do print_color $n done fi Output: 000: #000000 001: #800000 002: #008000 003: #808000 004: #000080 005: #800080 006: #008080 007: #c0c0c0 008: #808080 009: #ff0000 010: #ffff00 011: #00ff00 012: #0000ff 013: #ff00ff 014: #00ffff 015: #ffffff 016: #000000 017: #00005f 018: #000087 019: #0000af 020: #0000d7 021: #0000ff 022: #005f00 023: #005f5f 024: #005f87 025: #005faf 026: #005fd7 027: #005fff 028: #008700 029: #00875f 030: #008787 031: #0087af 032: #0087d7 033: #0087ff 034: #00af00 035: #00af5f 036: #00af87 037: #00afaf 038: #00afd7 039: #00afff 040: #00d700 041: #00d75f 042: #00d787 043: #00d7af 044: #00d7d7 045: #00d7ff 046: #00ff00 047: #00ff5f 048: #00ff87 049: #00ffaf 050: #00ffd7 051: #00ffff 052: #5f0000 053: #5f005f 054: #5f0087 055: #5f00af 056: #5f00d7 057: #5f00ff 058: #5f5f00 059: #5f5f5f 060: #5f5f87 061: #5f5faf 062: #5f5fd7 063: #5f5fff 064: #5f8700 065: #5f875f 066: #5f8787 067: #5f87af 068: #5f87d7 069: #5f87ff 070: #5faf00 071: #5faf5f 072: #5faf87 073: #5fafaf 074: #5fafd7 075: #5fafff 076: #5fd700 077: #5fd75f 078: #5fd787 079: #5fd7af 080: #5fd7d7 081: #5fd7ff 082: #5fff00 083: #5fff5f 084: #5fff87 085: #5fffaf 086: #5fffd7 087: #5fffff 088: #870000 089: #87005f 090: #870087 091: #8700af 092: #8700d7 093: #8700ff 094: #875f00 095: #875f5f 096: #875f87 097: #875faf 098: #875fd7 099: #875fff 100: #878700 101: #87875f 102: #878787 103: #8787af 104: #8787d7 105: #8787ff 106: #87af00 107: #87af5f 108: #87af87 109: #87afaf 110: #87afd7 111: #87afff 112: #87d700 113: #87d75f 114: #87d787 115: #87d7af 116: #87d7d7 117: #87d7ff 118: #87ff00 119: #87ff5f 120: #87ff87 121: #87ffaf 122: #87ffd7 123: #87ffff 124: #af0000 125: #af005f 126: #af0087 127: #af00af 128: #af00d7 129: #af00ff 130: #af5f00 131: #af5f5f 132: #af5f87 133: #af5faf 134: #af5fd7 135: #af5fff 136: #af8700 137: #af875f 138: #af8787 139: #af87af 140: #af87d7 141: #af87ff 142: #afaf00 143: #afaf5f 144: #afaf87 145: #afafaf 146: #afafd7 147: #afafff 148: #afd700 149: #afd75f 150: #afd787 151: #afd7af 152: #afd7d7 153: #afd7ff 154: #afff00 155: #afff5f 156: #afff87 157: #afffaf 158: #afffd7 159: #afffff 160: #d70000 161: #d7005f 162: #d70087 163: #d700af 164: #d700d7 165: #d700ff 166: #d75f00 167: #d75f5f 168: #d75f87 169: #d75faf 170: #d75fd7 171: #d75fff 172: #d78700 173: #d7875f 174: #d78787 175: #d787af 176: #d787d7 177: #d787ff 178: #d7af00 179: #d7af5f 180: #d7af87 181: #d7afaf 182: #d7afd7 183: #d7afff 184: #d7d700 185: #d7d75f 186: #d7d787 187: #d7d7af 188: #d7d7d7 189: #d7d7ff 190: #d7ff00 191: #d7ff5f 192: #d7ff87 193: #d7ffaf 194: #d7ffd7 195: #d7ffff 196: #ff0000 197: #ff005f 198: #ff0087 199: #ff00af 200: #ff00d7 201: #ff00ff 202: #ff5f00 203: #ff5f5f 204: #ff5f87 205: #ff5faf 206: #ff5fd7 207: #ff5fff 208: #ff8700 209: #ff875f 210: #ff8787 211: #ff87af 212: #ff87d7 213: #ff87ff 214: #ffaf00 215: #ffaf5f 216: #ffaf87 217: #ffafaf 218: #ffafd7 219: #ffafff 220: #ffd700 221: #ffd75f 222: #ffd787 223: #ffd7af 224: #ffd7d7 225: #ffd7ff 226: #ffff00 227: #ffff5f 228: #ffff87 229: #ffffaf 230: #ffffd7 231: #ffffff 232: #080808 233: #121212 234: #1c1c1c 235: #262626 236: #303030 237: #3a3a3a 238: #444444 239: #4e4e4e 240: #585858 241: #626262 242: #6c6c6c 243: #767676 244: #808080 245: #8a8a8a 246: #949494 247: #9e9e9e 248: #a8a8a8 249: #b2b2b2 250: #bcbcbc 251: #c6c6c6 252: #d0d0d0 253: #dadada 254: #e4e4e4 255: #eeeeee A related question: How to generate 256 color palette for Linux terminal in HTML/jquery
Try this for hex codes: xdef="$HOME/.Xresources" colors=( $( sed -re '/^!/d; /^$/d; /^#/d; s/(\*color)([0-9]):/\10\2:/g;' $xdef | grep 'color[01][0-9]:' | sort | sed 's/^.*: *//g' ) ) echo for i in {0..7}; do echo -en "\e[$((30+$i))m ${colors[i]} \u2588\u2588 \e[0m"; done echo for i in {8..15}; do echo -en "\e[1;$((22+$i))m ${colors[i]} \u2588\u2588 \e[0m"; done echo -e "\n" All credits to https://github.com/stark/color-scripts/blob/master/color-scripts/hex-block . Note that this script won't work on macOS. And this for color with escape codes: T='•••' # The text for the color test echo -e "\n def 40m 41m 42m 43m 44m 45m 46m 47m"; for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \ '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \ ' 36m' '1;36m' ' 37m' '1;37m'; do FG=${FGs// /} echo -en " $FGs \033[$FG $T " for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; done echo; done echo Source: https://github.com/stark/color-scripts/blob/master/color-scripts/colortest .
Why Upgrading to Alpinejs 3.2 menu does noes not work?
In Laravel 8 / Alpinejs 2.8 app I had toggle menu like <!--Toggle button (hidden on large screens)--> <button #click="isOpen = !isOpen" type="button" class="block lg:hidden px-2 text-gray-500 hover:text-white focus:outline-none focus:text-white" :class="{ 'transition transform-180': isOpen }" > <svg class="h-6 w-6 fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path x-show="isOpen" fill-rule="evenodd" clip-rule="evenodd" d="M18.278 16.864a1 1 0 0 1-1.414 1.414l-4.829-4.828-4.828 4.828a1 1 0 0 1-1.414-1.414l4.828-4.829-4.828-4.828a1 1 0 0 1 1.414-1.414l4.829 4.828 4.828-4.828a1 1 0 1 1 1.414 1.414l-4.828 4.829 4.828 4.828z" /> <path x-show="!isOpen" fill-rule="evenodd" d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z" /> </svg> </button> <!--Menu--> <div class="w-full flex-grow lg:flex lg:items-center lg:w-auto" :class="{ 'block shadow-3xl': isOpen, 'hidden': !isOpen }" #click.away="isOpen = false" x-show.transition="true" > <ul class="pt-6 lg:pt-0 list-reset lg:flex justify-end flex-1 items-center" > <li class="mr-3"> and it worked ok. Upgrading to Alpinejs 3.2 modified #click.away="isOpen = false" with #click.away="isOpen = false" with #click.outside="isOpen = false" and x-show.transition="true" into x-show="true" x-transition but after that drop down menu is not visible at all. Why so and how it can be fixed? MODIFIED # 1: If to change x-show="isOpen" for menu then yes, on small devices menu works as expected, but on big devices it is not visible at all I need somehow to set init value to true on big devices. Condition : x-show="isOpen" md:x-show="true" x-transition does not work I think I can use package https://github.com/jenssegers/agent to get this value depending on current device. Are there better decision? Could you please explain how devtools were usefull in this debugging? Thanks!
If you check it in devtools it is actually works as expected when you toggle isOpen state. The problem is when you click button it is also considered as click.away out of menu. I'll suggest to set this click on a parent element. Also I change menu settings - x-show set to isOpen like x-show="isOpen" and toggle statement will handle visibility of element with Tailwind's visible class <div x-data="{ isOpen: false }" #click.outside="isOpen = false" > <button #click="isOpen = !isOpen" type="button" class="block lg:hidden px-2 text-gray-500 focus:outline-none" :class="{ 'transition transform-180': isOpen }" > <svg class="w-6 h-6 fill-current" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" > <path x-show="isOpen" fill-rule="evenodd" clip-rule="evenodd" d="M18.278 16.864a1 1 0 0 1-1.414 1.414l-4.829-4.828-4.828 4.828a1 1 0 0 1-1.414-1.414l4.828-4.829-4.828-4.828a1 1 0 0 1 1.414-1.414l4.829 4.828 4.828-4.828a1 1 0 1 1 1.414 1.414l-4.828 4.829 4.828 4.828z" /> <path x-show="!isOpen" fill-rule="evenodd" d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z" /> </svg> </button> <!--Menu--> <div class="flex-grow w-full lg:flex shadow-3xl lg:items-center lg:w-auto" :class="[ isOpen ? 'visible' : 'unvisible' ]" x-show="isOpen" x-transition > <ul class="items-center justify-end flex-1 pt-6 lg:pt-0 list-reset lg:flex" > <li class="mr-3">Link 1</li> <li class="mr-3">Link 2</li> </ul> </div> </div>
Xdotool offset/mismatch when using windowmove
i am trying to place a window with xdotool. Its not going where i want it to. I tried the following code: terminal=`xdotool getactivewindow` xdotool getwindowgeometry $terminal xdotool windowmove $terminal 0 0 xdotool getwindowgeometry $terminal xdotool windowmove --relative $terminal -10 -10 xdotool getwindowgeometry $terminal and got the following output: Window 62914571 Position: 10,80 (screen: 0) Geometry: 1694x1046 Window 62914571 Position: 10,62 (screen: 0) Geometry: 1694x1046 Window 62914571 Position: 10,62 (screen: 0) Geometry: 1694x1046 side notes: i am using a laptop + one monitor connected via hdmi1 and i modified my /etc/lightdm/lightdm.conf to [SeatDefaults] greeter-session=unity-greeter user-session=ubuntu session-setup-script=/home/user/.monitor.sh the .monitor.sh looks like that: cvt 2560 1440 30 xrandr --newmode "2560x1440_30.00" 146.25 2560 2680 2944 3328 1440 1443 1448 1468 - hsync +vsync xrandr --addmode HDMI1 "2560x1440_30.00" any tipps or hints what could cause the problem?