Commands/Standard/SVG.feMergeNode.ps1
function SVG.feMergeNode { <# .Synopsis Creates SVG feMergeNode elements .Description The `feMergeNode` takes the result of another filter to be processed by its parent `feMerge`. .Example svg @( svg.filter -id embossed @( svg.feConvolveMatrix -KernelMatrix ' 5 0 0 0 0 0 0 0 -5 ' svg.feMerge @( svg.feMergeNode svg.feMergeNode -In 'SourceGraphic' ) ) svg.text " Embossed " -TextAnchor middle -DominantBaseline middle -Fill '#4488ff' -FontSize 16 -X 50% -Y 50% -Filter 'url(#embossed)' ) -ViewBox 0,0,300,100 .Example svg @( svg.filter -id dropShadow @( svg.feDropShadow -dx 0.5 -dy 0.75 -StdDeviation 0 @( svg.animate -AttributeName dx -Values '.5;-.5;.5' -Dur 1s -RepeatCount 'indefinite' ) svg.feMerge @( svg.feMergeNode svg.feMergeNode -In 'SourceGraphic' ) ) svg.text " Moving Shadows " -TextAnchor middle -DominantBaseline middle -Fill '#4488ff' -FontSize 16 -X 50% -Y 50% -Filter 'url(#dropShadow)' ) -ViewBox 0,0,300,100 .Link https://pssvg.start-automating.com/SVG.feMergeNode .Link https://developer.mozilla.org/en-US/web/svg/element/femergenode/ .Link Write-SVG #> [Reflection.AssemblyMetadata('SVG.ElementName', 'feMergeNode')] [CmdletBinding(PositionalBinding=$false)] [OutputType([Xml.XmlElement])] param( # The Contents of the feMergeNode element [Parameter(Position=0,ValueFromPipeline,ValueFromPipelineByPropertyName)] [Alias('InputObject','Text', 'InnerText', 'Contents')] $Content, # A dictionary containing data. This data will be embedded in data- attributes. [Parameter(ValueFromPipelineByPropertyName)] [Alias('DataAttribute','DataAttributes')] [Collections.IDictionary] $Data, # A dictionary or object containing event handlers. # Each key or property name will be the name of the event # Each value will be the handler. [Parameter(ValueFromPipelineByPropertyName)] $On, # A dictionary of attributes. This can set any attribute not exposed in other parameters. [Parameter(ValueFromPipelineByPropertyName)] [Alias('SVGAttributes','SVGAttribute')] [Collections.IDictionary] $Attribute = [Ordered]@{}, # A comment that will appear before the element. [Parameter(ValueFromPipelineByPropertyName)] [Alias('Comments')] [String] $Comment, # One or more child elements. These will be treated as if they were content. [Parameter(ValueFromPipelineByPropertyName)] [Alias('Child')] [Management.Automation.PSObject] $Children, # [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','in')] [Reflection.AssemblyMetaData('SVG.Value', 'SourceGraphic | SourceAlpha | BackgroundImage | BackgroundAlpha | FillPaint | StrokePaint | <filter-primitive-reference>')] [ArgumentCompleter({ param ( $commandName,$parameterName,$wordToComplete,$commandAst,$fakeBoundParameters ) $validSet = 'SourceGraphic','SourceAlpha','BackgroundImage','BackgroundAlpha','FillPaint','StrokePaint','<filter-primitive-reference>' if ($wordToComplete) { $toComplete = $wordToComplete -replace "^'" -replace "'$" return @($validSet -like "$toComplete*" -replace '^', "'" -replace '$',"'") } else { return @($validSet -replace '^', "'" -replace '$',"'") } })] [Reflection.AssemblyMetaData('SVG.Default value', 'SourceGraphic for first filter primitive, otherwise result of previous filter primitive')] [Reflection.AssemblyMetaData('SVG.Animatable', 'True')] [PSObject] $In, # The **`id`** attribute assigns a unique name to an element. # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','id')] [Reflection.AssemblyMetaData('SVG.Value', '<id>')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $Id, # The **`lang`** attribute specifies the primary language used in contents and attributes containing text content of particular elements. # # There is also an xml:lang attribute (with namespace). If both of them are defined, the one with namespace is used and the one without is ignored. # # In SVG 1.1 there was a `lang` attribute defined with a different meaning and only applying to glyph elements. That attribute specified a list of languages according to {{RFC(5646, "Tags for Identifying Languages (also known as BCP 47)")}}. The glyph was meant to be used if the `xml:lang` attribute exactly matched one of the languages given in the value of this parameter, or if the `xml:lang` attribute exactly equaled a prefix of one of the languages given in the value of this parameter such that the first tag character following the prefix was "-". # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','lang')] [Reflection.AssemblyMetaData('SVG.Value', '<language-tag>')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $Lang, # The **`tabindex`** attribute allows you to control whether an element is focusable and to define the relative order of the element for the purposes of sequential focus navigation. # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','tabindex')] [Reflection.AssemblyMetaData('SVG.Value', 'valid integer')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $Tabindex, # The **`xml:base`** attribute specifies a base IRI other than the base IRI of the document or external entity. # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','xml:base')] [Reflection.AssemblyMetaData('SVG.Deprecated',$true)] [Reflection.AssemblyMetaData('SVG.Value', '<iri>')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $XmlBase, # The **`xml:lang`** attribute specifies the primary language used in contents and attributes containing text content of particular elements. # # It is a universal attribute allowed in all XML dialects to mark up the natural human language that an element contains. # # There is also a lang attribute (without namespace). If both of them are defined, the one with namespace is used and the one without is ignored. # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','xml:lang')] [Reflection.AssemblyMetaData('SVG.Deprecated',$true)] [Reflection.AssemblyMetaData('SVG.Value', '<language-tag>')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $XmlLang, # SVG supports the built-in XML **`xml:space`** attribute to handle whitespace characters inside elements. Child elements inside an element may also have an `xml:space` attribute that overrides the parent's one. # # > **Note:** Instead of using the `xml:space` attribute, use the white-space CSS property. # # This attribute influences how browsers parse text content and therefore changes the way the DOM is built. Therefore, changing this attribute's value through the DOM API may have no effect. # # You can use this attribute with any SVG element. [Parameter(ValueFromPipelineByPropertyName)] [Reflection.AssemblyMetaData('SVG.AttributeName','xml:space')] [Reflection.AssemblyMetaData('SVG.Deprecated',$true)] [Reflection.AssemblyMetaData('SVG.Value', 'default | preserve')] [ArgumentCompleter({ param ( $commandName,$parameterName,$wordToComplete,$commandAst,$fakeBoundParameters ) $validSet = 'default','preserve' if ($wordToComplete) { $toComplete = $wordToComplete -replace "^'" -replace "'$" return @($validSet -like "$toComplete*" -replace '^', "'" -replace '$',"'") } else { return @($validSet -replace '^', "'" -replace '$',"'") } })] [Reflection.AssemblyMetaData('SVG.Default value', 'default')] [Reflection.AssemblyMetaData('SVG.Animatable', 'False')] [PSObject] $XmlSpace ) process { # Copy the bound parameters $paramCopy = [Ordered]@{} + $PSBoundParameters # and get a reference to yourself. $myCmd = $MyInvocation.MyCommand # Use that self-reference to determine the element name. $elementName = foreach ($myAttr in $myCmd.ScriptBlock.Attributes) { if ($myAttr.Key -eq 'SVG.ElementName') { $myAttr.Value break } } # If we could not determine this, return. if (-not $elementName) { return } # If there were no keys found in -Attribute if (-not $attribute[$paramCopy.Keys]) { $attribute += $paramCopy # merge the values by adding hashtables. } else { # Otherwise copy into -Attribute one-by-one. foreach ($pc in $paramCopy.GetEnumerator()) { $attribute[$pc.Key] = $pc.Value } } # All commands will call Write-SVG. Prepare a splat. $writeSvgSplat = @{ ElementName = $elementName Attribute = $attribute } # If content was provided if ($null -ne $content) { # put it into the splat. $writeSvgSplat.Content = $content } # If comments were provided if ($comment) { # put it into the splat. $writeSvgSplat.Comment = $comment } # If any children were provided if ($children) { # put them in the splat. $writeSvgSplat.Children = $children } # If we provided an -OutputPath if ($paramCopy['OutputPath']) { # put it into the splat. $writeSvgSplat.OutputPath = $paramCopy['OutputPath'] } # If we provided any -Data attributes if ($data) { # put it into the splat. $writeSvgSplat.Data = $data } # If we provided any -On events if ($on) { # put it into the splat. $writeSvgSplat.On = $on } . Write-SVG @writeSvgSplat } } |