Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinearGradient example code for creation #180

Open
1 of 3 tasks
pklaschka opened this issue Feb 25, 2019 · 0 comments
Open
1 of 3 tasks

LinearGradient example code for creation #180

pklaschka opened this issue Feb 25, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@pklaschka
Copy link
Contributor

Submit an issue

Topic

This is an issue regarding:

  • The tutorials contained within this repo.
  • The samples contained within this repo.

Versions

  • Supported XD version(s):

Description of the issue

To create a new LinearGradient, one has to use something like

const { LinearGradient, Color } = require('scenegraph'); // Import classes
let gradient = new LinearGradient(); // Create "empty" gradient"
gradient.colorStops = [
    {stop: 0.0, color: new Color('#ff0000')},
    {stop: 1.0, color: new Color('#ff00ff')},
]; // Assign colors to gradient
node.fill = gradient; // Assign gradient as fill

node.fill = new LinearGradient() would throw an error about a gradient having to have at least two color stops. This, however, is neither obvious from the docs nor intuitive (since there's also no constructor providing the ability to add those two color stops quickly), which is why I'd argue that it might be wise to add a note about this (or better: example code) to the section in the docs (https://adobexdplatform.com/plugin-docs/reference/LinearGradientFill.html#new-lineargradientfill) to avoid (unnecessary) confusion.

Proposed solution or attempted solutions that failed

Add a note or some example code demonstrating this behavior to the section in the docs to make it clear how to assign a new LinearGradient as fill

@pklaschka pklaschka added the enhancement New feature or request label Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant