【问题标题】:IDML Polygon to SVGIDML 多边形到 SVG
【发布时间】:2019-04-08 18:21:28
【问题描述】:

我在 idml 文件中有这个 Polygon

<Polygon Self="ue7" ContentType="Unassigned" StoryTitle="$ID/" ParentInterfaceChangeCount="" TargetInterfaceChangeCount="" LastUpdatedInterfaceChangeCount="" OverriddenPageItemProps="" HorizontalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" VerticalLayoutConstraints="FlexibleDimension FixedDimension FlexibleDimension" GradientFillStart="0 0" GradientFillLength="0" GradientFillAngle="0" GradientStrokeStart="0 0" GradientStrokeLength="0" GradientStrokeAngle="0" ItemLayer="uc5" Locked="false" LocalDisplaySetting="Default" GradientFillHiliteLength="0" GradientFillHiliteAngle="0" GradientStrokeHiliteLength="0" GradientStrokeHiliteAngle="0" AppliedObjectStyle="ObjectStyle/$ID/[Normal Graphics Frame]" Visible="true" Name="$ID/" ItemTransform="1 0 0 1 41.5 -14.555409553836853">
        <Properties>
            <PathGeometry>
                <GeometryPathType PathOpen="true">
                    <PathPointArray>
                        <PathPointType Anchor="105 -258.94488188905" LeftDirection="105 -258.94488188905" RightDirection="105 -171" />
                        <PathPointType Anchor="105 -168" LeftDirection="105 -257.05511811095" RightDirection="105 -78.94488188905001" />
                        <PathPointType Anchor="201 -72" LeftDirection="120 -72" RightDirection="282 -72" />
                        <PathPointType Anchor="338 -209" LeftDirection="338 -167" RightDirection="338 -251" />
                        <PathPointType Anchor="105 -258.94488188905" LeftDirection="105 -258.94488188905" RightDirection="105 -258.94488188905" />
                    </PathPointArray>
                </GeometryPathType>
            </PathGeometry>
        </Properties>
        <TextWrapPreference Inverse="false" ApplyToMasterPageOnly="false" TextWrapSide="BothSides" TextWrapMode="None">
            <Properties>
                <TextWrapOffset Top="0" Left="0" Bottom="0" Right="0" />
            </Properties>
        </TextWrapPreference>
        <InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false" />
        <FrameFittingOption AutoFit="false" LeftCrop="0" TopCrop="0" RightCrop="0" BottomCrop="0" FittingOnEmptyFrame="None" FittingAlignment="CenterAnchor" />
        <ObjectExportOption EpubType="$ID/" SizeType="DefaultSize" CustomSize="$ID/" PreserveAppearanceFromLayout="PreserveAppearanceDefault" AltTextSourceType="SourceXMLStructure" ActualTextSourceType="SourceXMLStructure" CustomAltText="$ID/" CustomActualText="$ID/" ApplyTagType="TagFromStructure" ImageConversionType="JPEG" ImageExportResolution="Ppi300" GIFOptionsPalette="AdaptivePalette" GIFOptionsInterlaced="true" JPEGOptionsQuality="High" JPEGOptionsFormat="BaselineEncoding" ImageAlignment="AlignLeft" ImageSpaceBefore="0" ImageSpaceAfter="0" UseImagePageBreak="false" ImagePageBreak="PageBreakBefore" CustomImageAlignment="false" SpaceUnit="CssPixel" CustomLayout="false" CustomLayoutType="AlignmentAndSpacing">
            <Properties>
                <AltMetadataProperty NamespacePrefix="$ID/" PropertyPath="$ID/" />
                <ActualMetadataProperty NamespacePrefix="$ID/" PropertyPath="$ID/" />
            </Properties>
        </ObjectExportOption>
    </Polygon>

现在我想将这些点转换为 svg 路径 我使用了svg中的curveto点,但似乎不太好。这是我的结果

 <!DOCTYPE html>
<html>
<body>

<svg height="10000" width="10000">

 
  
  <g transform="translate(300 400)">
   <path d="M105 -258.94488188905
   C105 -258.94488188905,105 -258.94488188905, 105 -171
   
    
   C105 -168, 105 -257.05511811095, 105 -78.94488188905001
   
   C201 -72, 120 -72, 282 -72
   
   C338 -209, 338 -167, 338 -251
   
   C105 -258.94488188905, 105 -258.94488188905, 105 -258.94488188905
    
    
     
   
   " stroke="black" fill="transparent"/>
  </g>
  
</svg>

</body>
</html>

indesign 的原始路径如下所示:

有人知道从PathPointArray解析这些点的正确方法

【问题讨论】:

    标签: svg bezier adobe-indesign idml


    【解决方案1】:

    看起来 InDesign 使用的模型更接近于您在应用程序中操纵路径的方式(即一系列带手柄的点),并且不同于 SVG 模型(即一系列路径段)。

    但它们可以通过不同的对齐方式进行转换:

    InDesign                                    SVG
    
    LeftDirection="105 -258.94488188905"        -- ignored as before the first point
    Anchor="105 -258.94488188905"               M 105 -258.94488188905
    RightDirection="105 -171"                   C 105 -171
    
    LeftDirection="105 -257.05511811095"        105 -257.05511811095
    Anchor="105 -168"                           105 -168
    RightDirection="105 -78.94488188905001"     C 105 -78.94488188905001
    
    LeftDirection="120 -72"                     120 -72
    Anchor="201 -72"                            201 -72
    RightDirection="282 -72"                    C 282 -72
    
    LeftDirection="338 -167"                    338 -167
    Anchor="338 -209"                           338 -209
    RightDirection="338 -251"                   C 338 -251
    
    LeftDirection="105 -258.94488188905"        105 -258.94488188905
    Anchor="105 -258.94488188905"               105 -258.94488188905
    RightDirection="105 -258.94488188905"       -- ignored as beyond the last point
    

    如您所见,LeftDirection 坐标出现在Anchor 坐标之前。一条曲线段从RightDirection 和LeftDirection 跨越到Anchor 坐标。

    <svg viewBox="100 -260 300 200">
        <path fill="none" stroke="black" d="M 105 -258.94488188905
    C 105 -171 105 -257.05511811095 105 -168 C 105 -78.94488188905001 120 -72 201 -72 C 282 -72 338 -167 338 -209 C 338 -251 105 -258.94488188905 105 -258.94488188905"
    </svg>

    【讨论】:

    • 太棒了!谢谢
    猜你喜欢
    • 2015-07-23
    • 2016-05-18
    • 2023-04-06
    • 2020-09-19
    • 2015-04-04
    • 1970-01-01
    • 1970-01-01
    • 2016-10-23
    • 2015-11-29
    相关资源
    最近更新 更多