SVG Radial

SVG Radial (SVG径向)

Description of the <radialGradient> element

Description of the <radialGradient> element

The <radialGradient> element specifies an SVG radial gradient that can be applied to fill and stroke graphical elements.

The <radialGradient> element must be nested inside a <defs> element which is a short for definitions. The <defs> element contains definition of specific elements (e.g., gradients).

Do not confuse an SVG radial gradient with the CSS radial-gradient property. CSS gradients only apply to HTML elements, whereas the SVG gradient only applies to SVG elements. (>请勿将SVG径向渐变与CSS径向渐变属性混淆。CSS渐变仅适用于HTML元素,而SVG渐变仅适用于SVG元素。)

Example of the SVG <radialGradient> element:

<!DOCTYPE html>
<html>
 <head>
   <title>Title of the document</title>
 </head>
 <body>
   <svg width="400" height="300">
     <defs>
       <radialGradient id="example" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
         <stop offset="0%" style="stop-color:rgb(245,245,245);stop-opacity:0" />
         <stop offset="100%" style="stop-color:rgb(144, 238, 144);stop-opacity:1" />
       </radialGradient>
     </defs>
     <ellipse cx="250" cy="100" rx="95" ry="65" fill="url(#example)" /> Sorry, your browser doesn't support inline SVG.
   </svg>
 </body>
</html>

Attributes

Attributes (属性)

AttributeDescription
cxSpecifies the x coordinate of the end circle for the gradient.
cySpecifies the y coordinate of the end circle for the gradient.
rSpecifies the radius of the end circle for the gradient.
frSpecifies the radius of the start circle for the gradient.
fxSpecifies the x coordinate of the start circle for the gradient.
fySpecifies the y coordinate of the start circle for the gradient.
gradientUnitsSpecifies the coordinate system for the following attributes: cx, cy, r, fx,fy, and fr.
gradientTransformGives additional transformation to the coordinate system of the gradient.
hrefA URL reference to a different “radialGradient” or a “linearGradient” element.
spreadMethodSpecifies how the gradient behaves when it starts or ends within the bounds of the objects containing the gradient.

The SVG <radialGradient> element also supports the Global Attributes and Event Attributes.



请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部