【问题标题】:Diagonal Cut on a text on the path of a svg linesvg 线路径上的文本上的对角线切割
【发布时间】:2016-10-21 06:33:21
【问题描述】:

我需要对文本进行斜切。每当 svg 线在文本上方移动时,文本应该被斜切。 有没有可能实现这种场景。 ? 下面是代码。 以及我要实现的目标的图像。

<!DOCTYPE html>
<html>
<head><title></title>
<style type="text/css">
h1{
	position: absolute;
	top:0;
	left: 10px;
}
</style>
</head>
<body>
	<svg height="210" width="500">
	<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
	<line x1="150" y1="150" x2="200" y2="200" style="stroke:rgb(0, 0, 153);stroke-width:2">
		<animateTransform attributeName="transform"
      type="translate"
      values="200 200;-150 -150;200 200"
      begin="0s"
      dur="5s"
      repeatCount="indefinite"
    />
	</line>
	</svg>
<h1>OUR<br>WORK</h1>

	
</body>
</html>

【问题讨论】:

    标签: html css d3.js svg svg-animate


    【解决方案1】:

    这是一个完全使用 SVG 的版本。

    <html>
    <head><title></title>
    <style type="text/css">
    h1{
    	position: absolute;
    	top:0;
    	left: 10px;
    }
    </style>
    </head>
    <body>
    	<svg height="210" width="500">
    	<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
    	<line x1="150" y1="150" x2="200" y2="200" style="stroke:rgb(0, 0, 153);stroke-width:2">
    		<animateTransform attributeName="transform"
          type="translate"
          values="200 200;-150 -150;200 200"
          begin="0s"
          dur="5s"
          repeatCount="indefinite"
        />
    	</line>
        <defs>
          <clipPath id="clip1">
             <polygon points="0, 0 200, 200, 0, 200"/>
          </clipPath>
          <clipPath id="clip2">
             <polygon points="0, 0 200, 0, 200, 200"/>
          </clipPath>
        </defs>
        <text x="0" y="42" font-size="33px" font-weight="bold" clip-path="url(#clip1)">OUR<tspan x="0" dy="36">WORK</text>
        <text x="4" y="38" font-size="33px" font-weight="bold" clip-path="url(#clip2)">OUR<tspan x="4" dy="36">WORK</text>
    	</svg>
    </body>
    </html>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-10
      • 1970-01-01
      • 2019-12-31
      • 2011-10-13
      • 2016-10-01
      相关资源
      最近更新 更多