# What namespace is LinearGradientFill?

**URL:** <https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942>\
**Category:** UXP Plugin API\
**Tags:** javascript\
**Created:** [June 26, 2019, 1:08am UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942 "2019-06-26T01:08:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdreyv](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/gdreyv/32/358_2.png) [@gdreyv](https://forums.creativeclouddeveloper.com/u/gdreyv)\
**Post date:** [June 26, 2019, 1:08am UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/1 "2019-06-26T01:08:36Z")

</div>

As I understand fill can be either _`Color` or `LinearGradientFill` or `RadialGradientFill` or `ImageFill`_. What is the proper way to understand what fill was applied. I checked typeof but it doesn’t work. I believe LinearGradientFill is not scenegraph module but which one instead?

```auto
console.log("scenegraph.Color", typeof(scenegraph.Color));
console.log("scenegraph.LinearGradientFill", typeof(scenegraph.LinearGradientFill));
console.log("scenegraph.RadialGradientFill", typeof(scenegraph.RadialGradientFill));

```

has following output:

```auto
scenegraph.Color function
scenegraph.LinearGradientFill undefined
scenegraph.RadialGradientFill undefined

```

---

<div class="post-metadata">

**Author:** ![jasim](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jasim](https://forums.creativeclouddeveloper.com/u/jasim)\
**Post date:** [June 26, 2019, 6:15am UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/2 "2019-06-26T06:15:49Z")

</div>

@gdreyv Hope this helps:

```auto
const fs = require("uxp").storage.localFileSystem;

export function className(o) {
  return o.constructor.name;
}

export function computeFill(sceneNode) {
  let fill = sceneNode.fill
  if (sceneNode.fillEnabled && fill) {
    let kind = className(fill);
    if (kind == "Color") {
      return {color: computeColorFillCss(fill)}
    } else if (kind == "ImageFill") {
      return {bitmap: true};
    } else if (kind == "LinearGradientFill" || kind == "RadialGradientFill") {
      return {svg: true};
    }
  }
  return;
}

function computeColorFillCss(f) {
  // https://adobexdplatform.com/plugin-docs/reference/Color.html#Color-toHex
  if (f.a == 255) {
    return f.toHex(true)
  } else {
    return "rgba(" + f.r + ", " + f.g + ", " + f.b + ", " + f.a + ")"
  }
}

```

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [June 26, 2019, 7:09am UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/3 "2019-06-26T07:09:49Z")

</div>

Hi @gdreyv,

the thing is that – despite what the docs say (@ashryan any update about this 😉 ?) , `LinearGradientFill` is actually called `LinearGradient` and `RadialGradientFill` (which, of course, doesn’t have a doc page, yet) is actually called `RadialGradient`.

You’ll find that `typof LinearGradient` and `typeof RadialGradient` will produce evaluate to functions jjust like `Color`.

Therefore, the answer to your question is that it is in the `scenegraph` module, but wrongly documented (see [this issue](https://github.com/AdobeXD/plugin-docs/issues/179) for further reference)…

Hope this helps,  
Happy Coding,  
Pablo

---

<div class="post-metadata">

**Author:** ![gdreyv](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/gdreyv/32/358_2.png) [@gdreyv](https://forums.creativeclouddeveloper.com/u/gdreyv)\
**Post date:** [June 26, 2019, 12:56pm UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/4 "2019-06-26T12:56:14Z")

</div>

Just curious how it can be that class name is LinearGradient but prototype/constructor name is LinearGradientFill?

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [June 26, 2019, 1:22pm UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/5 "2019-06-26T13:22:09Z")

</div>

Probably, `LinearGradient` is the name with which it gets exported from the module (removing the fill part to ensure consistency with things like `Color`) and `LinearGradientFill` is the “implementation” name…

```auto
class LinearGradientFill {} 

module.exports = {
  LinearGradient: LinearGradientFill 
} 

```

---

<div class="post-metadata">

**Author:** ![ashryan](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/ashryan/32/1177_2.png) [@ashryan](https://forums.creativeclouddeveloper.com/u/ashryan)\
**Post date:** [June 26, 2019, 1:33pm UTC](https://forums.creativeclouddeveloper.com/t/what-namespace-is-lineargradientfill/942/6 "2019-06-26T13:33:54Z")

</div>

@peterflynn, is this something we’re planning on updating in the references?
