Skip to content

Commit

Permalink
MDN Feature pages for SVGRadialGradientElement
Browse files Browse the repository at this point in the history
  • Loading branch information
yashrajbharti committed Dec 20, 2024
1 parent 4238ce5 commit bea6a2f
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 0 deletions.
62 changes: 62 additions & 0 deletions files/en-us/web/api/svgradialgradientelement/cx/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "SVGRadialGradientElement: cx property"
short-title: cx
slug: Web/API/SVGRadialGradientElement/cx
page-type: web-api-instance-property
browser-compat: api.SVGRadialGradientElement.cx
---

{{APIRef("SVG")}}

The **`cx`** read-only property of the {{domxref("SVGRadialGradientElement")}} interface describes the x-axis coordinate of the center of the radial gradient as an {{domxref("SVGAnimatedLength")}}. It reflects the computed value of the {{SVGAttr("cx")}} attribute on the {{SVGElement("radialGradient")}} element.

The attribute value is a [`<length>`](/en-US/docs/Web/SVG/Content_type#length), [`<percentage>`](/en-US/docs/Web/SVG/Content_type#percentage), or [`<number>`](/en-US/docs/Web/SVG/Content_type#number). The numeric value of the {{domxref("SVGAnimatedLength.baseVal")}} is the x-coordinate of the radial gradient's center in the user coordinate system.

## Value

An {{domxref("SVGAnimatedLength")}}.

## Example

Given the following SVG:

```html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="gradient1" cx="50" cy="75" r="30">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient id="gradient2" cx="25%" cy="50%" r="10%">
<stop offset="0%" stop-color="red" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#gradient1)" />
<rect x="0" y="100" width="200" height="100" fill="url(#gradient2)" />
</svg>
```

We can access the computed values of the `cx` attributes:

```js
const radialGradients = document.querySelectorAll("radialGradient");
const cxGradient1 = radialGradients[0].cx;
const cxGradient2 = radialGradients[1].cx;

console.dir(cxGradient1.baseVal.value); // output: 50
console.dir(cxGradient2.baseVal.value); // output: 50 (25% of 200)
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("SVGRadialGradientElement.cy")}}
- {{domxref("SVGAnimatedLength.baseVal")}}
62 changes: 62 additions & 0 deletions files/en-us/web/api/svgradialgradientelement/cy/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "SVGRadialGradientElement: cy property"
short-title: cy
slug: Web/API/SVGRadialGradientElement/cy
page-type: web-api-instance-property
browser-compat: api.SVGRadialGradientElement.cy
---

{{APIRef("SVG")}}

The **`cy`** read-only property of the {{domxref("SVGRadialGradientElement")}} interface describes the y-axis coordinate of the center of the radial gradient as an {{domxref("SVGAnimatedLength")}}. It reflects the computed value of the {{SVGAttr("cy")}} attribute on the {{SVGElement("radialGradient")}} element.

The attribute value is a [`<length>`](/en-US/docs/Web/SVG/Content_type#length), [`<percentage>`](/en-US/docs/Web/SVG/Content_type#percentage), or [`<number>`](/en-US/docs/Web/SVG/Content_type#number). The numeric value of the {{domxref("SVGAnimatedLength.baseVal")}} is the y-coordinate of the radial gradient's center in the user coordinate system.

## Value

An {{domxref("SVGAnimatedLength")}}.

## Example

Given the following SVG:

```html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="gradient1" cx="50" cy="75" r="30">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient id="gradient2" cx="25%" cy="50%" r="10%">
<stop offset="0%" stop-color="red" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#gradient1)" />
<rect x="0" y="100" width="200" height="100" fill="url(#gradient2)" />
</svg>
```

We can access the computed values of the `cx` attributes:

```js
const radialGradients = document.querySelectorAll("radialGradient");
const cyGradient1 = radialGradients[0].cy;
const cyGradient2 = radialGradients[1].cy;

console.dir(cyGradient1.baseVal.value); // output: 75
console.dir(cyGradient2.baseVal.value); // output: 100 (50% of 200)
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("SVGRadialGradientElement.cx")}}
- {{domxref("SVGAnimatedLength.baseVal")}}
62 changes: 62 additions & 0 deletions files/en-us/web/api/svgradialgradientelement/fx/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "SVGRadialGradientElement: fx property"
short-title: fx
slug: Web/API/SVGRadialGradientElement/fx
page-type: web-api-instance-property
browser-compat: api.SVGRadialGradientElement.fx
---

{{APIRef("SVG")}}

The **`fx`** read-only property of the {{domxref("SVGRadialGradientElement")}} interface describes the x-axis coordinate of the focal point of the radial gradient as an {{domxref("SVGAnimatedLength")}}. It reflects the computed value of the {{SVGAttr("fx")}} attribute on the {{SVGElement("radialGradient")}} element.

The attribute value is a [`<length>`](/en-US/docs/Web/SVG/Content_type#length), [`<percentage>`](/en-US/docs/Web/SVG/Content_type#percentage), or [`<number>`](/en-US/docs/Web/SVG/Content_type#number). The numeric value of the {{domxref("SVGAnimatedLength.baseVal")}} is the x-coordinate of the focal point of the radial gradient in the user coordinate system.

## Value

An {{domxref("SVGAnimatedLength")}}.

## Example

Given the following SVG:

```html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="gradient1" cx="50" cy="75" fx="30" fy="60" r="30">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient id="gradient2" cx="25%" cy="50%" fx="10%" fy="40%" r="10%">
<stop offset="0%" stop-color="red" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#gradient1)" />
<rect x="0" y="100" width="200" height="100" fill="url(#gradient2)" />
</svg>
```

We can access the computed values of the `fx` attributes:

```js
const radialGradients = document.querySelectorAll("radialGradient");
const fxGradient1 = radialGradients[0].fx;
const fxGradient2 = radialGradients[1].fx;

console.dir(fxGradient1.baseVal.value); // output: 30
console.dir(fxGradient2.baseVal.value); // output: 20 (10% of 200)
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("SVGRadialGradientElement.fy")}}
- {{domxref("SVGAnimatedLength.baseVal")}}
62 changes: 62 additions & 0 deletions files/en-us/web/api/svgradialgradientelement/fy/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "SVGRadialGradientElement: fy property"
short-title: fy
slug: Web/API/SVGRadialGradientElement/fy
page-type: web-api-instance-property
browser-compat: api.SVGRadialGradientElement.fy
---

{{APIRef("SVG")}}

The **`fy`** read-only property of the {{domxref("SVGRadialGradientElement")}} interface describes the y-axis coordinate of the focal point of the radial gradient as an {{domxref("SVGAnimatedLength")}}. It reflects the computed value of the {{SVGAttr("fy")}} attribute on the {{SVGElement("radialGradient")}} element.

The attribute value is a [`<length>`](/en-US/docs/Web/SVG/Content_type#length), [`<percentage>`](/en-US/docs/Web/SVG/Content_type#percentage), or [`<number>`](/en-US/docs/Web/SVG/Content_type#number). The numeric value of the {{domxref("SVGAnimatedLength.baseVal")}} is the y-coordinate of the focal point of the radial gradient in the user coordinate system.

## Value

An {{domxref("SVGAnimatedLength")}}.

## Example

Given the following SVG:

```html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="gradient1" cx="50" cy="75" fx="30" fy="60" r="30">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient id="gradient2" cx="25%" cy="50%" fx="10%" fy="40%" r="10%">
<stop offset="0%" stop-color="red" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#gradient1)" />
<rect x="0" y="100" width="200" height="100" fill="url(#gradient2)" />
</svg>
```

We can access the computed values of the `fy` attributes:

```js
const radialGradients = document.querySelectorAll("radialGradient");
const fyGradient1 = radialGradients[0].fy;
const fyGradient2 = radialGradients[1].fy;

console.dir(fyGradient1.baseVal.value); // output: 60
console.dir(fyGradient2.baseVal.value); // output: 80 (40% of 200)
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("SVGRadialGradientElement.fx")}}
- {{domxref("SVGAnimatedLength.baseVal")}}
62 changes: 62 additions & 0 deletions files/en-us/web/api/svgradialgradientelement/r/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "SVGRadialGradientElement: r property"
short-title: r
slug: Web/API/SVGRadialGradientElement/r
page-type: web-api-instance-property
browser-compat: api.SVGRadialGradientElement.r
---

{{APIRef("SVG")}}

The **`r`** read-only property of the {{domxref("SVGRadialGradientElement")}} interface describes the radius of the radial gradient as an {{domxref("SVGAnimatedLength")}}. It reflects the computed value of the {{SVGAttr("r")}} attribute on the {{SVGElement("radialGradient")}} element.

The attribute value is a [`<length>`](/en-US/docs/Web/SVG/Content_type#length), [`<percentage>`](/en-US/docs/Web/SVG/Content_type#percentage), or [`<number>`](/en-US/docs/Web/SVG/Content_type#number). The numeric value of the {{domxref("SVGAnimatedLength.baseVal")}} is the radius of the radial gradient in the user coordinate system.

## Value

An {{domxref("SVGAnimatedLength")}}.

## Example

Given the following SVG:

```html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="gradient1" cx="50" cy="75" fx="30" fy="60" r="30">
<stop offset="0%" stop-color="blue" />
<stop offset="100%" stop-color="white" />
</radialGradient>
<radialGradient id="gradient2" cx="25%" cy="50%" fx="10%" fy="40%" r="10%">
<stop offset="0%" stop-color="red" />
<stop offset="100%" stop-color="yellow" />
</radialGradient>
</defs>
<rect x="0" y="0" width="200" height="100" fill="url(#gradient1)" />
<rect x="0" y="100" width="200" height="100" fill="url(#gradient2)" />
</svg>
```

We can access the computed values of the `r` attributes:

```js
const radialGradients = document.querySelectorAll("radialGradient");
const rGradient1 = radialGradients[0].r;
const rGradient2 = radialGradients[1].r;

console.dir(rGradient1.baseVal.value); // output: 30
console.dir(rGradient2.baseVal.value); // output: 20 (10% of 200)
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{SVGAttr("r")}}
- {{domxref("SVGAnimatedLength.baseVal")}}

0 comments on commit bea6a2f

Please sign in to comment.