Skip to content

Cannot create a LayerStyle with Fill of type Gradient #162

@itaigilo-inv

Description

@itaigilo-inv

Steps to reproduce:
Try to create a Gradient Fill using the following code -

sketch.addLayerStyle(
  SharedStyle.LayerStyle({
    id: <id>,
    name: <name>,
    fills: [
      new Fill(null, {
        fillType: 'Gradient',
        gradient: {
          gradientType: Gradient.GradientType.Linear,
          from: '{0, 0}',
          to: '{1, 1}',
          stops: [ ... ]
        }
      }) 
    ]
  })
);

Observed: The Layer Style is created with the default Gradient values (from: '{0.5, 0}', to: '{0.5, 1}', gradientType: 1, ...).
Expected: The Layer Style is created with the provided Gradient values (from: '{0, 0}', to: '{1, 1}', gradientType: 0, ...).

Version used: 1.25.0.

Technical details:
When creating a LayerStyle with Fill of type Gradient using its c'tor (SharedStyle.LayerStyle({...})),
It (internally )tries to use the Gradient c'tor using the args c'tor (and not the json c'tor).
But since args is not used in the Gradient c'tor, it is always created with the default values (instead of the values provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions