Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.4KB

  1. --- Colour Gradient.
  2. -- Is a pointer to a [JUCE ColourGradient](http://www.juce.com/api/classColourGradient.html)
  3. -- @classmod juce.ColourGradient
  4. ffi.cdef [[
  5. pColourGradient ColourGradient_new (Colour c1, float x1, float y1, Colour c2, float x2, float y2, bool isRadial);
  6. void ColourGradient_delete (pColourGradient c);
  7. int ColourGradient_addColour (pColourGradient self, double proportionAlongGradient,
  8. Colour colour);
  9. void ColourGradient_removeColour (pColourGradient self, int index);
  10. void ColourGradient_multiplyOpacity (pColourGradient self, float multiplier);
  11. int ColourGradient_getNumColours(pColourGradient self);
  12. Colour ColourGradient_getColour (pColourGradient self, int index);
  13. void ColourGradient_setColour (pColourGradient self, int index, Colour newColour);
  14. Colour ColourGradient_getColourAtPosition (pColourGradient self, double position);
  15. ]]
  16. --- Constuctor.
  17. -- @tparam juce.Colour colour1 colour at the beginning of the gradient
  18. -- @param x1 coordinates of colour1
  19. -- @param y1 coordinates of colour1
  20. -- @tparam juce.Colour colour2 colour at the end of the gradient
  21. -- @param x2 coordinates of colour2
  22. -- @param y2 coordinates of colour2
  23. -- @tparam boolean isRadial whether the gradient should be linear or radial
  24. -- @within Constructors
  25. -- @constructor
  26. -- @function Colour
  27. local function ColourGradient(colour1, x1, y1, colour2, x2, y2, isRadial)
  28. return ffi.gc(
  29. protolib.ColourGradient_new(colour1, x1, y1, colour2, x2, y2, isRadial),
  30. protolib.ColourGradient_delete
  31. )
  32. end
  33. local ColourGradient_mt = {
  34. -- methods
  35. __index = {
  36. --- Add colour.
  37. -- Any number of colours can be added between the start and end of the gradient.
  38. -- @param proportionAlongGradient
  39. -- @tparam juce.Colour colour
  40. -- @return the new colour's index
  41. -- @function addColour
  42. addColour = function (self, proportionAlongGradient, colour)
  43. return protolib.ColourGradient_addColour (self, proportionAlongGradient, colour)
  44. end;
  45. --- Remove colour.
  46. -- @param index colour index between 0 and getNumColours() - 1
  47. -- @function removeColour
  48. removeColour = function (self, index)
  49. protolib.ColourGradient_removeColour (self, index)
  50. end;
  51. --- Multiply opacity.
  52. -- @param multiplier factor to multiply the alpha values by
  53. -- @function multiplyOpacity
  54. multiplyOpacity = function (self, multiplier)
  55. protolib.ColourGradient_multiplyOpacity (self, multiplier)
  56. end;
  57. --- Get number colour.
  58. -- @return the number of colours
  59. -- @function getNumColours
  60. getNumColours = function (self)
  61. return protolib.ColourGradient_getNumColours(self)
  62. end;
  63. --- Get colour.
  64. -- @param index colour index between 0 and getNumColours() - 1
  65. -- @treturn juce.Colour the coulour at the specified index
  66. -- @function getColour
  67. getColour = function (self, index)
  68. return protolib.ColourGradient_getColour (self, index)
  69. end;
  70. --- Get colour.
  71. -- @param index colour index between 0 and getNumColours() - 1
  72. -- @tparam juce.Colour newColour
  73. -- @function setColour
  74. setColour = function (self, index, newColour)
  75. protolib.ColourGradient_setColour (self, index, newColour)
  76. end;
  77. --- Get interpolated colour
  78. -- @param position the position between 0 and 1
  79. -- @treturn juce.Colour the interpolated colour at the specified position
  80. -- @function getColourAtPosition
  81. getColourAtPosition = function (self, position)
  82. return protolib.ColourGradient_getColourAtPosition (self, position)
  83. end;
  84. };
  85. }
  86. ffi.metatype("pColourGradient", ColourGradient_mt)
  87. return ColourGradient