hvianna / audioMotion-analyzer

High-resolution real-time graphic audio spectrum analyzer JavaScript module with no dependencies.
https://audioMotion.dev
GNU Affero General Public License v3.0
643 stars 63 forks source link

Colorstop type definition changed #17

Closed Staijn1 closed 3 years ago

Staijn1 commented 3 years ago

The type definition for colorstops seemed a little strange to me. I have to admit, it worked very well and I don't fully understand how it worked, but I think it can be simplified.

A GradientColorStop object can be a string, or an object. the colorStops property in GradientOptions is always an array, filled with GradientColorStops.

So, colorStops can be filled with an array full of strings or colorStops can be filled with an array full of objects (objects have pos and color attribute)

Because I'm not entirely sure if this is correct, I'd like to ask @alex-greff, is this indeed correct?

hvianna commented 3 years ago

At least two colors are required for the gradient, that's why the original definition format.

Staijn1 commented 3 years ago

I see, now the syntax makes sense.

I added support for that back in, but using a different method. Reason for this change is that Im using TSOA, to generate swagger documentation out of typescript type definitions. It currently does not support the format in the original file, but it does support this format.

alex-greff commented 3 years ago

If that method works I don't see why it shouldn't be used. It does look more readable than the original way I defined it.

hvianna commented 3 years ago

@Staijn1 @alex-greff LGTM! Thank you guys!