@shopify/react-native-skia 0.1.124 → 0.1.125

Sign up to get free protection for your applications and to get access to all the features.
Files changed (388) hide show
  1. package/android/CMakeLists.txt +3 -0
  2. package/android/build.gradle +1 -1
  3. package/cpp/api/JsiSkApi.h +3 -1
  4. package/cpp/api/JsiSkCanvas.h +1 -1
  5. package/cpp/api/JsiSkColor.h +41 -7
  6. package/cpp/api/JsiSkColorFilterFactory.h +2 -1
  7. package/cpp/api/JsiSkImageFilter.h +0 -2
  8. package/cpp/api/JsiSkImageFilterFactory.h +37 -17
  9. package/cpp/api/JsiSkMatrix.h +44 -2
  10. package/cpp/api/JsiSkPaint.h +4 -7
  11. package/cpp/api/JsiSkRuntimeEffect.h +7 -0
  12. package/cpp/api/JsiSkRuntimeEffectFactory.h +3 -2
  13. package/cpp/api/JsiSkRuntimeShaderBuilder.h +70 -0
  14. package/cpp/api/JsiSkShaderFactory.h +2 -2
  15. package/cpp/api/JsiSkVertices.h +1 -1
  16. package/cpp/api/third_party/CSSColorParser.cpp +194 -0
  17. package/cpp/api/third_party/CSSColorParser.h +1 -191
  18. package/cpp/jsi/JsiSimpleValueWrapper.h +98 -0
  19. package/cpp/rnskia/values/RNSkReadonlyValue.h +13 -12
  20. package/ios/RNSkia-iOS/PlatformContext.h +30 -4
  21. package/ios/RNSkia-iOS/SkiaDrawView.mm +9 -12
  22. package/lib/commonjs/{values/animation → animation}/decay/decay.js +0 -0
  23. package/lib/commonjs/{values/animation → animation}/decay/decay.js.map +0 -0
  24. package/lib/commonjs/{values/animation → animation}/decay/index.js +0 -0
  25. package/lib/commonjs/{values/animation → animation}/decay/index.js.map +0 -0
  26. package/lib/commonjs/{values/animation → animation}/decay/runDecay.js +1 -1
  27. package/lib/commonjs/animation/decay/runDecay.js.map +1 -0
  28. package/lib/commonjs/{values/animation → animation}/decay/types.js +0 -0
  29. package/lib/commonjs/{values/animation → animation}/decay/types.js.map +0 -0
  30. package/lib/commonjs/{values/animation → animation}/functions/index.js +0 -0
  31. package/lib/commonjs/{values/animation → animation}/functions/index.js.map +0 -0
  32. package/lib/commonjs/animation/functions/interpolate.js +141 -0
  33. package/lib/commonjs/animation/functions/interpolate.js.map +1 -0
  34. package/lib/commonjs/animation/functions/interpolateColors.js +39 -0
  35. package/lib/commonjs/animation/functions/interpolateColors.js.map +1 -0
  36. package/lib/commonjs/{values/animation → animation}/index.js +0 -0
  37. package/lib/commonjs/{values/animation → animation}/index.js.map +0 -0
  38. package/lib/commonjs/{values/animation → animation}/spring/Spring.js +0 -0
  39. package/lib/commonjs/{values/animation → animation}/spring/Spring.js.map +0 -0
  40. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js +0 -0
  41. package/lib/commonjs/{values/animation → animation}/spring/functions/index.js.map +0 -0
  42. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js +0 -0
  43. package/lib/commonjs/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  44. package/lib/commonjs/{values/animation → animation}/spring/index.js +0 -0
  45. package/lib/commonjs/{values/animation → animation}/spring/index.js.map +0 -0
  46. package/lib/commonjs/{values/animation → animation}/spring/runSpring.js +0 -0
  47. package/lib/commonjs/animation/spring/runSpring.js.map +1 -0
  48. package/lib/commonjs/{values/animation → animation}/spring/types.js +0 -0
  49. package/lib/commonjs/{values/animation → animation}/spring/types.js.map +0 -0
  50. package/lib/commonjs/{values/animation → animation}/spring/useSpring.js +0 -0
  51. package/lib/commonjs/animation/spring/useSpring.js.map +1 -0
  52. package/lib/commonjs/{values/animation → animation}/timing/Easing.js +0 -0
  53. package/lib/commonjs/{values/animation → animation}/timing/Easing.js.map +0 -0
  54. package/lib/commonjs/{values/animation → animation}/timing/createTiming.js +1 -1
  55. package/lib/commonjs/animation/timing/createTiming.js.map +1 -0
  56. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js +0 -0
  57. package/lib/commonjs/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  58. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
  59. package/lib/commonjs/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
  60. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js +0 -0
  61. package/lib/commonjs/{values/animation → animation}/timing/functions/index.js.map +0 -0
  62. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js +0 -0
  63. package/lib/commonjs/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  64. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js +0 -0
  65. package/lib/commonjs/{values/animation → animation}/timing/functions/types.js.map +0 -0
  66. package/lib/commonjs/{values/animation → animation}/timing/index.js +0 -0
  67. package/lib/commonjs/{values/animation → animation}/timing/index.js.map +0 -0
  68. package/lib/commonjs/{values/animation → animation}/timing/runTiming.js +0 -0
  69. package/lib/commonjs/animation/timing/runTiming.js.map +1 -0
  70. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js +0 -0
  71. package/lib/commonjs/{values/animation → animation}/timing/useLoop.js.map +0 -0
  72. package/lib/commonjs/{values/animation → animation}/timing/useTiming.js +1 -1
  73. package/lib/commonjs/animation/timing/useTiming.js.map +1 -0
  74. package/lib/commonjs/{values/animation → animation}/types.js +0 -0
  75. package/lib/commonjs/{values/animation → animation}/types.js.map +0 -0
  76. package/lib/commonjs/index.js +13 -0
  77. package/lib/commonjs/index.js.map +1 -1
  78. package/lib/commonjs/renderer/components/colorFilters/BlendColor.js.map +1 -1
  79. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js +4 -2
  80. package/lib/commonjs/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  81. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js +37 -0
  82. package/lib/commonjs/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  83. package/lib/commonjs/renderer/components/imageFilters/index.js +13 -0
  84. package/lib/commonjs/renderer/components/imageFilters/index.js.map +1 -1
  85. package/lib/commonjs/renderer/components/shaders/Gradient.js +1 -1
  86. package/lib/commonjs/renderer/components/shaders/Gradient.js.map +1 -1
  87. package/lib/commonjs/renderer/components/shaders/Shader.js.map +1 -1
  88. package/lib/commonjs/renderer/processors/Rects.js +5 -15
  89. package/lib/commonjs/renderer/processors/Rects.js.map +1 -1
  90. package/lib/commonjs/renderer/processors/math/Matrix3.js +42 -63
  91. package/lib/commonjs/renderer/processors/math/Matrix3.js.map +1 -1
  92. package/lib/commonjs/renderer/processors/math/Vector.js +4 -5
  93. package/lib/commonjs/renderer/processors/math/Vector.js.map +1 -1
  94. package/lib/commonjs/skia/Color.js +14 -38
  95. package/lib/commonjs/skia/Color.js.map +1 -1
  96. package/lib/commonjs/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  97. package/lib/commonjs/skia/Matrix.js.map +1 -1
  98. package/lib/commonjs/skia/Shader/useShader.js +4 -1
  99. package/lib/commonjs/skia/Shader/useShader.js.map +1 -1
  100. package/lib/commonjs/skia/Skia.js +3 -45
  101. package/lib/commonjs/skia/Skia.js.map +1 -1
  102. package/lib/commonjs/skia/SkiaApi.js +4 -0
  103. package/lib/commonjs/skia/SkiaApi.js.map +1 -0
  104. package/lib/commonjs/values/api.js +4 -6
  105. package/lib/commonjs/values/api.js.map +1 -1
  106. package/lib/commonjs/values/api.web.js +18 -0
  107. package/lib/commonjs/values/api.web.js.map +1 -0
  108. package/lib/commonjs/values/index.js +0 -13
  109. package/lib/commonjs/values/index.js.map +1 -1
  110. package/lib/commonjs/values/web/RNSkAnimation.js +46 -0
  111. package/lib/commonjs/values/web/RNSkAnimation.js.map +1 -0
  112. package/lib/commonjs/values/web/RNSkClockValue.js +75 -0
  113. package/lib/commonjs/values/web/RNSkClockValue.js.map +1 -0
  114. package/lib/commonjs/values/web/RNSkDerivedValue.js +51 -0
  115. package/lib/commonjs/values/web/RNSkDerivedValue.js.map +1 -0
  116. package/lib/commonjs/values/web/RNSkReadonlyValue.js +45 -0
  117. package/lib/commonjs/values/web/RNSkReadonlyValue.js.map +1 -0
  118. package/lib/commonjs/values/web/RNSkValue.js +73 -0
  119. package/lib/commonjs/values/web/RNSkValue.js.map +1 -0
  120. package/lib/commonjs/values/web/api.js +31 -0
  121. package/lib/commonjs/values/web/api.js.map +1 -0
  122. package/lib/commonjs/values/web/index.js +19 -0
  123. package/lib/commonjs/values/web/index.js.map +1 -0
  124. package/lib/commonjs/views/SkiaView.js +13 -10
  125. package/lib/commonjs/views/SkiaView.js.map +1 -1
  126. package/lib/commonjs/views/api.js +11 -0
  127. package/lib/commonjs/views/api.js.map +1 -0
  128. package/lib/commonjs/views/types.js.map +1 -1
  129. package/lib/module/{values/animation → animation}/decay/decay.js +0 -0
  130. package/lib/module/{values/animation → animation}/decay/decay.js.map +0 -0
  131. package/lib/module/{values/animation → animation}/decay/index.js +0 -0
  132. package/lib/module/{values/animation → animation}/decay/index.js.map +0 -0
  133. package/lib/module/{values/animation → animation}/decay/runDecay.js +1 -1
  134. package/lib/module/animation/decay/runDecay.js.map +1 -0
  135. package/lib/module/{values/animation → animation}/decay/types.js +0 -0
  136. package/lib/module/{values/animation → animation}/decay/types.js.map +0 -0
  137. package/lib/module/{values/animation → animation}/functions/index.js +0 -0
  138. package/lib/module/{values/animation → animation}/functions/index.js.map +0 -0
  139. package/lib/module/animation/functions/interpolate.js +132 -0
  140. package/lib/module/animation/functions/interpolate.js.map +1 -0
  141. package/lib/module/animation/functions/interpolateColors.js +23 -0
  142. package/lib/module/animation/functions/interpolateColors.js.map +1 -0
  143. package/lib/module/{values/animation → animation}/index.js +0 -0
  144. package/lib/module/{values/animation → animation}/index.js.map +0 -0
  145. package/lib/module/{values/animation → animation}/spring/Spring.js +0 -0
  146. package/lib/module/{values/animation → animation}/spring/Spring.js.map +0 -0
  147. package/lib/module/{values/animation → animation}/spring/functions/index.js +0 -0
  148. package/lib/module/{values/animation → animation}/spring/functions/index.js.map +0 -0
  149. package/lib/module/{values/animation → animation}/spring/functions/spring.js +0 -0
  150. package/lib/module/{values/animation → animation}/spring/functions/spring.js.map +0 -0
  151. package/lib/module/{values/animation → animation}/spring/index.js +0 -0
  152. package/lib/module/{values/animation → animation}/spring/index.js.map +0 -0
  153. package/lib/module/{values/animation → animation}/spring/runSpring.js +0 -0
  154. package/lib/module/animation/spring/runSpring.js.map +1 -0
  155. package/lib/module/{values/animation → animation}/spring/types.js +0 -0
  156. package/lib/module/{values/animation → animation}/spring/types.js.map +0 -0
  157. package/lib/module/{values/animation → animation}/spring/useSpring.js +0 -0
  158. package/lib/module/animation/spring/useSpring.js.map +1 -0
  159. package/lib/module/{values/animation → animation}/timing/Easing.js +0 -0
  160. package/lib/module/{values/animation → animation}/timing/Easing.js.map +0 -0
  161. package/lib/module/{values/animation → animation}/timing/createTiming.js +1 -1
  162. package/lib/module/animation/timing/createTiming.js.map +1 -0
  163. package/lib/module/{values/animation → animation}/timing/functions/bezier.js +0 -0
  164. package/lib/module/{values/animation → animation}/timing/functions/bezier.js.map +0 -0
  165. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js +0 -0
  166. package/lib/module/{values/animation → animation}/timing/functions/getResolvedParams.js.map +0 -0
  167. package/lib/module/{values/animation → animation}/timing/functions/index.js +0 -0
  168. package/lib/module/{values/animation → animation}/timing/functions/index.js.map +0 -0
  169. package/lib/module/{values/animation → animation}/timing/functions/timing.js +0 -0
  170. package/lib/module/{values/animation → animation}/timing/functions/timing.js.map +1 -1
  171. package/lib/module/{values/animation → animation}/timing/functions/types.js +0 -0
  172. package/lib/module/{values/animation → animation}/timing/functions/types.js.map +0 -0
  173. package/lib/module/{values/animation → animation}/timing/index.js +0 -0
  174. package/lib/module/{values/animation → animation}/timing/index.js.map +0 -0
  175. package/lib/module/{values/animation → animation}/timing/runTiming.js +0 -0
  176. package/lib/module/animation/timing/runTiming.js.map +1 -0
  177. package/lib/module/{values/animation → animation}/timing/useLoop.js +0 -0
  178. package/lib/module/{values/animation → animation}/timing/useLoop.js.map +0 -0
  179. package/lib/module/{values/animation → animation}/timing/useTiming.js +1 -1
  180. package/lib/module/animation/timing/useTiming.js.map +1 -0
  181. package/lib/module/{values/animation → animation}/types.js +0 -0
  182. package/lib/module/{values/animation → animation}/types.js.map +0 -0
  183. package/lib/module/index.js +1 -0
  184. package/lib/module/index.js.map +1 -1
  185. package/lib/module/renderer/components/colorFilters/BlendColor.js.map +1 -1
  186. package/lib/module/renderer/components/imageFilters/InnerShadow.js +3 -2
  187. package/lib/module/renderer/components/imageFilters/InnerShadow.js.map +1 -1
  188. package/lib/module/renderer/components/imageFilters/RuntimeShader.js +19 -0
  189. package/lib/module/renderer/components/imageFilters/RuntimeShader.js.map +1 -0
  190. package/lib/module/renderer/components/imageFilters/index.js +1 -0
  191. package/lib/module/renderer/components/imageFilters/index.js.map +1 -1
  192. package/lib/module/renderer/components/shaders/Gradient.js +2 -2
  193. package/lib/module/renderer/components/shaders/Gradient.js.map +1 -1
  194. package/lib/module/renderer/components/shaders/Shader.js.map +1 -1
  195. package/lib/module/renderer/processors/Rects.js +4 -15
  196. package/lib/module/renderer/processors/Rects.js.map +1 -1
  197. package/lib/module/renderer/processors/math/Matrix3.js +52 -72
  198. package/lib/module/renderer/processors/math/Matrix3.js.map +1 -1
  199. package/lib/module/renderer/processors/math/Vector.js +3 -5
  200. package/lib/module/renderer/processors/math/Vector.js.map +1 -1
  201. package/lib/module/skia/Color.js +9 -25
  202. package/lib/module/skia/Color.js.map +1 -1
  203. package/lib/module/skia/ImageFilter/ImageFilterFactory.js.map +1 -1
  204. package/lib/module/skia/Matrix.js.map +1 -1
  205. package/lib/module/skia/Shader/useShader.js +4 -1
  206. package/lib/module/skia/Shader/useShader.js.map +1 -1
  207. package/lib/module/skia/Skia.js +2 -46
  208. package/lib/module/skia/Skia.js.map +1 -1
  209. package/lib/module/skia/SkiaApi.js +2 -0
  210. package/lib/module/skia/SkiaApi.js.map +1 -0
  211. package/lib/module/values/api.js +4 -6
  212. package/lib/module/values/api.js.map +1 -1
  213. package/lib/module/values/api.web.js +7 -0
  214. package/lib/module/values/api.web.js.map +1 -0
  215. package/lib/module/values/index.js +0 -1
  216. package/lib/module/values/index.js.map +1 -1
  217. package/lib/module/values/web/RNSkAnimation.js +36 -0
  218. package/lib/module/values/web/RNSkAnimation.js.map +1 -0
  219. package/lib/module/values/web/RNSkClockValue.js +65 -0
  220. package/lib/module/values/web/RNSkClockValue.js.map +1 -0
  221. package/lib/module/values/web/RNSkDerivedValue.js +41 -0
  222. package/lib/module/values/web/RNSkDerivedValue.js.map +1 -0
  223. package/lib/module/values/web/RNSkReadonlyValue.js +36 -0
  224. package/lib/module/values/web/RNSkReadonlyValue.js.map +1 -0
  225. package/lib/module/values/web/RNSkValue.js +63 -0
  226. package/lib/module/values/web/RNSkValue.js.map +1 -0
  227. package/lib/module/values/web/api.js +19 -0
  228. package/lib/module/values/web/api.js.map +1 -0
  229. package/lib/module/values/web/index.js +2 -0
  230. package/lib/module/values/web/index.js.map +1 -0
  231. package/lib/module/views/SkiaView.js +1 -3
  232. package/lib/module/views/SkiaView.js.map +1 -1
  233. package/lib/module/views/api.js +4 -0
  234. package/lib/module/views/api.js.map +1 -0
  235. package/lib/module/views/types.js.map +1 -1
  236. package/lib/typescript/src/{values/animation → animation}/decay/decay.d.ts +0 -0
  237. package/lib/typescript/src/{values/animation → animation}/decay/index.d.ts +0 -0
  238. package/lib/typescript/src/{values/animation → animation}/decay/runDecay.d.ts +2 -2
  239. package/lib/typescript/src/{values/animation → animation}/decay/types.d.ts +1 -1
  240. package/lib/typescript/src/{values/animation → animation}/functions/index.d.ts +0 -0
  241. package/lib/typescript/src/animation/functions/interpolate.d.ts +11 -0
  242. package/lib/typescript/src/animation/functions/interpolateColors.d.ts +3 -0
  243. package/lib/typescript/src/{values/animation → animation}/index.d.ts +0 -0
  244. package/lib/typescript/src/{values/animation → animation}/spring/Spring.d.ts +0 -0
  245. package/lib/typescript/src/{values/animation → animation}/spring/functions/index.d.ts +0 -0
  246. package/lib/typescript/src/{values/animation → animation}/spring/functions/spring.d.ts +0 -0
  247. package/lib/typescript/src/{values/animation → animation}/spring/index.d.ts +0 -0
  248. package/lib/typescript/src/{values/animation → animation}/spring/runSpring.d.ts +1 -1
  249. package/lib/typescript/src/{values/animation → animation}/spring/types.d.ts +0 -0
  250. package/lib/typescript/src/{values/animation → animation}/spring/useSpring.d.ts +1 -1
  251. package/lib/typescript/src/{values/animation → animation}/timing/Easing.d.ts +0 -0
  252. package/lib/typescript/src/{values/animation → animation}/timing/createTiming.d.ts +2 -2
  253. package/lib/typescript/src/{values/animation → animation}/timing/functions/bezier.d.ts +0 -0
  254. package/lib/typescript/src/{values/animation → animation}/timing/functions/getResolvedParams.d.ts +0 -0
  255. package/lib/typescript/src/{values/animation → animation}/timing/functions/index.d.ts +0 -0
  256. package/lib/typescript/src/{values/animation → animation}/timing/functions/timing.d.ts +1 -1
  257. package/lib/typescript/src/{values/animation → animation}/timing/functions/types.d.ts +0 -0
  258. package/lib/typescript/src/{values/animation → animation}/timing/index.d.ts +0 -0
  259. package/lib/typescript/src/{values/animation → animation}/timing/runTiming.d.ts +1 -1
  260. package/lib/typescript/src/{values/animation → animation}/timing/useLoop.d.ts +0 -0
  261. package/lib/typescript/src/{values/animation → animation}/timing/useTiming.d.ts +1 -1
  262. package/lib/typescript/src/{values/animation → animation}/types.d.ts +0 -0
  263. package/lib/typescript/src/index.d.ts +1 -0
  264. package/lib/typescript/src/renderer/components/colorFilters/BlendColor.d.ts +1 -1
  265. package/lib/typescript/src/renderer/components/imageFilters/RuntimeShader.d.ts +7 -0
  266. package/lib/typescript/src/renderer/components/imageFilters/index.d.ts +1 -0
  267. package/lib/typescript/src/renderer/components/shaders/Gradient.d.ts +1 -1
  268. package/lib/typescript/src/renderer/components/shaders/Shader.d.ts +2 -2
  269. package/lib/typescript/src/renderer/components/shapes/Circle.d.ts +1 -4
  270. package/lib/typescript/src/renderer/processors/Rects.d.ts +9 -41
  271. package/lib/typescript/src/renderer/processors/math/Matrix3.d.ts +1 -5
  272. package/lib/typescript/src/renderer/processors/math/Vector.d.ts +5 -17
  273. package/lib/typescript/src/skia/Color.d.ts +8 -9
  274. package/lib/typescript/src/skia/ImageFilter/ImageFilterFactory.d.ts +16 -0
  275. package/lib/typescript/src/skia/Matrix.d.ts +7 -1
  276. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffect.d.ts +2 -1
  277. package/lib/typescript/src/skia/RuntimeEffect/RuntimeEffectFactory.d.ts +2 -2
  278. package/lib/typescript/src/skia/Shader/useShader.d.ts +1 -1
  279. package/lib/typescript/src/skia/Skia.d.ts +28 -95
  280. package/lib/typescript/src/skia/SkiaApi.d.ts +71 -0
  281. package/lib/typescript/src/skia/Surface/Surface.d.ts +1 -1
  282. package/lib/typescript/src/skia/Surface/SurfaceFactory.d.ts +2 -2
  283. package/lib/typescript/src/values/api.d.ts +2 -25
  284. package/lib/typescript/src/values/api.web.d.ts +2 -0
  285. package/lib/typescript/src/values/index.d.ts +0 -1
  286. package/lib/typescript/src/values/types.d.ts +24 -1
  287. package/lib/typescript/src/values/web/RNSkAnimation.d.ts +9 -0
  288. package/lib/typescript/src/values/web/RNSkClockValue.d.ts +13 -0
  289. package/lib/typescript/src/values/web/RNSkDerivedValue.d.ts +9 -0
  290. package/lib/typescript/src/values/web/RNSkReadonlyValue.d.ts +11 -0
  291. package/lib/typescript/src/values/web/RNSkValue.d.ts +14 -0
  292. package/lib/typescript/src/values/web/api.d.ts +2 -0
  293. package/lib/typescript/src/values/web/index.d.ts +1 -0
  294. package/lib/typescript/src/views/SkiaView.d.ts +3 -36
  295. package/lib/typescript/src/views/api.d.ts +5 -0
  296. package/lib/typescript/src/views/types.d.ts +32 -0
  297. package/package.json +2 -2
  298. package/src/{values/animation → animation}/decay/decay.ts +0 -0
  299. package/src/{values/animation → animation}/decay/index.ts +0 -0
  300. package/src/{values/animation → animation}/decay/runDecay.ts +2 -2
  301. package/src/{values/animation → animation}/decay/types.ts +1 -1
  302. package/src/{values/animation → animation}/functions/index.ts +0 -0
  303. package/src/animation/functions/interpolate.ts +182 -0
  304. package/src/animation/functions/interpolateColors.ts +58 -0
  305. package/src/{values/animation → animation}/index.ts +0 -0
  306. package/src/{values/animation → animation}/spring/Spring.ts +0 -0
  307. package/src/{values/animation → animation}/spring/functions/index.ts +0 -0
  308. package/src/{values/animation → animation}/spring/functions/spring.ts +0 -0
  309. package/src/{values/animation → animation}/spring/index.ts +0 -0
  310. package/src/{values/animation → animation}/spring/runSpring.ts +1 -1
  311. package/src/{values/animation → animation}/spring/types.ts +0 -0
  312. package/src/{values/animation → animation}/spring/useSpring.ts +1 -1
  313. package/src/{values/animation → animation}/timing/Easing.ts +0 -0
  314. package/src/{values/animation → animation}/timing/createTiming.ts +2 -2
  315. package/src/{values/animation → animation}/timing/functions/__tests__/timing.spec.ts +0 -0
  316. package/src/{values/animation → animation}/timing/functions/bezier.ts +0 -0
  317. package/src/{values/animation → animation}/timing/functions/getResolvedParams.ts +0 -0
  318. package/src/{values/animation → animation}/timing/functions/index.ts +0 -0
  319. package/src/{values/animation → animation}/timing/functions/timing.ts +1 -1
  320. package/src/{values/animation → animation}/timing/functions/types.ts +0 -0
  321. package/src/{values/animation → animation}/timing/index.ts +0 -0
  322. package/src/{values/animation → animation}/timing/runTiming.ts +1 -1
  323. package/src/{values/animation → animation}/timing/useLoop.ts +0 -0
  324. package/src/{values/animation → animation}/timing/useTiming.ts +2 -2
  325. package/src/{values/animation → animation}/types.ts +0 -0
  326. package/src/index.ts +1 -0
  327. package/src/renderer/components/colorFilters/BlendColor.tsx +1 -1
  328. package/src/renderer/components/imageFilters/InnerShadow.tsx +4 -2
  329. package/src/renderer/components/imageFilters/RuntimeShader.tsx +23 -0
  330. package/src/renderer/components/imageFilters/index.ts +1 -0
  331. package/src/renderer/components/shaders/Gradient.ts +2 -4
  332. package/src/renderer/components/shaders/Shader.tsx +2 -2
  333. package/src/renderer/processors/Rects.ts +6 -12
  334. package/src/renderer/processors/math/Matrix3.ts +24 -105
  335. package/src/renderer/processors/math/Vector.ts +3 -2
  336. package/src/skia/Color.ts +13 -27
  337. package/src/skia/ImageFilter/ImageFilterFactory.ts +20 -0
  338. package/src/skia/Matrix.ts +8 -1
  339. package/src/skia/RuntimeEffect/RuntimeEffect.ts +3 -1
  340. package/src/skia/RuntimeEffect/RuntimeEffectFactory.ts +2 -2
  341. package/src/skia/Shader/useShader.ts +4 -1
  342. package/src/skia/Skia.ts +4 -126
  343. package/src/skia/SkiaApi.ts +86 -0
  344. package/src/skia/Surface/Surface.ts +1 -1
  345. package/src/skia/Surface/SurfaceFactory.ts +2 -2
  346. package/src/values/api.ts +3 -42
  347. package/src/values/api.web.ts +5 -0
  348. package/src/values/index.ts +0 -1
  349. package/src/values/types.ts +30 -1
  350. package/src/values/web/RNSkAnimation.ts +33 -0
  351. package/src/values/web/RNSkClockValue.ts +58 -0
  352. package/src/values/web/RNSkDerivedValue.ts +38 -0
  353. package/src/values/web/RNSkReadonlyValue.ts +32 -0
  354. package/src/values/web/RNSkValue.ts +57 -0
  355. package/src/values/web/__tests__/RNSkAnimation.spec.ts +21 -0
  356. package/src/values/web/__tests__/RNSkDerivedValue.spec.ts +15 -0
  357. package/src/values/web/__tests__/RNSkReadonlyValue.spec.ts +8 -0
  358. package/src/values/web/__tests__/RNSkValue.spec.ts +11 -0
  359. package/src/values/web/api.ts +33 -0
  360. package/src/values/web/index.ts +1 -0
  361. package/src/views/SkiaView.tsx +3 -49
  362. package/src/views/api.ts +7 -0
  363. package/src/views/types.ts +40 -0
  364. package/lib/commonjs/values/animation/decay/runDecay.js.map +0 -1
  365. package/lib/commonjs/values/animation/functions/interpolate.js +0 -139
  366. package/lib/commonjs/values/animation/functions/interpolate.js.map +0 -1
  367. package/lib/commonjs/values/animation/functions/interpolateColors.js +0 -47
  368. package/lib/commonjs/values/animation/functions/interpolateColors.js.map +0 -1
  369. package/lib/commonjs/values/animation/spring/runSpring.js.map +0 -1
  370. package/lib/commonjs/values/animation/spring/useSpring.js.map +0 -1
  371. package/lib/commonjs/values/animation/timing/createTiming.js.map +0 -1
  372. package/lib/commonjs/values/animation/timing/runTiming.js.map +0 -1
  373. package/lib/commonjs/values/animation/timing/useTiming.js.map +0 -1
  374. package/lib/module/values/animation/decay/runDecay.js.map +0 -1
  375. package/lib/module/values/animation/functions/interpolate.js +0 -132
  376. package/lib/module/values/animation/functions/interpolate.js.map +0 -1
  377. package/lib/module/values/animation/functions/interpolateColors.js +0 -32
  378. package/lib/module/values/animation/functions/interpolateColors.js.map +0 -1
  379. package/lib/module/values/animation/spring/runSpring.js.map +0 -1
  380. package/lib/module/values/animation/spring/useSpring.js.map +0 -1
  381. package/lib/module/values/animation/timing/createTiming.js.map +0 -1
  382. package/lib/module/values/animation/timing/runTiming.js.map +0 -1
  383. package/lib/module/values/animation/timing/useTiming.js.map +0 -1
  384. package/lib/typescript/scripts/install-npm.d.ts +0 -1
  385. package/lib/typescript/src/values/animation/functions/interpolate.d.ts +0 -7
  386. package/lib/typescript/src/values/animation/functions/interpolateColors.d.ts +0 -3
  387. package/src/values/animation/functions/interpolate.ts +0 -169
  388. package/src/values/animation/functions/interpolateColors.ts +0 -62
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useSpring.ts"],"names":["useTiming","Spring","createSpringEasing","useSpring","toOrParams","config","callback","Config","Default"],"mappings":"AAMA,SAASA,SAAT,QAA0B,WAA1B;AAEA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAKvBN,SAAS,CACPI,UADO,EAEPF,kBAAkB,CAACG,MAAD,aAACA,MAAD,cAACA,MAAD,GAAWJ,MAAM,CAACM,MAAP,CAAcC,OAAzB,CAFX,EAGPF,QAHO,CALJ","sourcesContent":["import type { SkiaReadonlyValue } from \"../../types\";\nimport type {\n SpringConfig,\n AnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport { useTiming } from \"../timing\";\n\nimport { Spring } from \"./Spring\";\nimport { createSpringEasing } from \"./functions/spring\";\n\n/**\n * Creats a spring based animation value that will run whenever\n * the animation parameters change.\n * @param toOrParams\n * @param config\n * @returns\n */\nexport const useSpring = (\n toOrParams: number | AnimationParams,\n config?: SpringConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> =>\n useTiming(\n toOrParams,\n createSpringEasing(config ?? Spring.Config.Default),\n callback\n );\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["createTiming.ts"],"names":["ValueApi","timing","createTiming","params","value","callback","resolvedParams","from","current","animationFunction","t","state","nextState","duration","easing","loop","yoyo","finished","to","createAnimation"],"mappings":"AAMA,SAASA,QAAT,QAAyB,WAAzB;AAEA,SAASC,MAAT,QAAuB,aAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,YAAY,GAAG,CAC1BC,MAD0B,EAE1BC,KAF0B,EAG1BC,QAH0B,KAIvB;AAAA;;AACH;AACA;AACA,QAAMC,cAAc,GAAG,EACrB,GAAGH,MADkB;AAErBI,IAAAA,IAAI,0BAAEJ,MAAM,CAACI,IAAT,uDAAiBH,KAAjB,aAAiBA,KAAjB,uBAAiBA,KAAK,CAAEI,OAAxB,uCAAmC;AAFlB,GAAvB,CAHG,CAQH;;AACA,QAAMC,iBAAiB,GAAG,CAACC,CAAD,EAAYC,KAAZ,KAAkD;AAAA;;AAC1E;AACA,UAAMC,SAAS,GAAGX,MAAM,CACtBS,CADsB,EAEtBP,MAAM,CAACU,QAFe,EAGtBV,MAAM,CAACW,MAHe,kBAItBX,MAAM,CAACY,IAJe,uDAIP,KAJO,kBAKtBZ,MAAM,CAACa,IALe,uDAKP,KALO,EAMtBL,KANsB,aAMtBA,KANsB,cAMtBA,KANsB,GAMb;AAAEH,MAAAA,OAAO,EAAEL,MAAM,CAACI,IAAlB;AAAyBU,MAAAA,QAAQ,EAAE;AAAnC,KANa,CAAxB;AAQA,UAAMT,OAAO,GACXI,SAAS,CAACJ,OAAV,IAAqBF,cAAc,CAACY,EAAf,GAAoBZ,cAAc,CAACC,IAAxD,IACAD,cAAc,CAACC,IAFjB;;AAGA,QAAIF,QAAQ,IAAIO,SAAS,CAACK,QAAV,KAAuB,IAAvC,EAA6C;AAC3CZ,MAAAA,QAAQ,CAACG,OAAD,CAAR;AACD;;AACD,WAAO,EACL,GAAGI,SADE;AAELJ,MAAAA;AAFK,KAAP;AAID,GApBD,CATG,CA+BH;;;AACA,SAAOR,QAAQ,CAACmB,eAAT,CAAyBV,iBAAzB,CAAP;AACD,CArCM","sourcesContent":["import type {\n TimingConfig,\n RequiredAnimationParams,\n AnimationCallback,\n} from \"../types\";\nimport type { AnimationState, SkiaValue } from \"../../types\";\nimport { ValueApi } from \"../../api\";\n\nimport { timing } from \"./functions\";\n\n/**\n * Creates an animation that is driven by a clock value.\n * The value will be run from / to the value in params and modified\n * by the provided easing curve for the length of the duration. When\n * the value has reached its desired \"to\" value the animation\n * will be stopped. If loop is set to true, the animation will continue\n * to run until stopped.\n *\n * @param params Animation parameters\n * @param config Spring or timing configuration\n * @param value Optional value that the animation will update\n * @params an animation value that can be used to start/stop\n * the animation.\n */\nexport const createTiming = (\n params: RequiredAnimationParams & Required<TimingConfig>,\n value?: SkiaValue<number>,\n callback?: AnimationCallback\n) => {\n // Update from to be either the declared from value,\n // the current value of the value or zero\n const resolvedParams = {\n ...params,\n from: params.from ?? value?.current ?? 0,\n };\n\n // Update function for the animation value\n const animationFunction = (t: number, state: AnimationState | undefined) => {\n // Update the input value using the provided update function\n const nextState = timing(\n t,\n params.duration,\n params.easing,\n params.loop ?? false,\n params.yoyo ?? false,\n state ?? { current: params.from!, finished: false }\n );\n const current =\n nextState.current * (resolvedParams.to - resolvedParams.from!) +\n resolvedParams.from!;\n if (callback && nextState.finished === true) {\n callback(current);\n }\n return {\n ...nextState,\n current,\n };\n };\n\n // Create animation value\n return ValueApi.createAnimation(animationFunction);\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["runTiming.ts"],"names":["getResolvedParams","createTiming","runTiming","value","toOrParams","config","callback","resolvedParameters","animation"],"mappings":"AAOA,SAASA,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,KADuB,EAEvBC,UAFuB,EAGvBC,MAHuB,EAIvBC,QAJuB,KAKL;AAClB,QAAMC,kBAAkB,GAAGP,iBAAiB,CAACI,UAAD,EAAaC,MAAb,CAA5C;AACA,QAAMG,SAAS,GAAGP,YAAY,CAACM,kBAAD,EAAqBJ,KAArB,EAA4BG,QAA5B,CAA9B;AACAH,EAAAA,KAAK,CAACK,SAAN,GAAkBA,SAAlB;AACA,SAAOA,SAAP;AACD,CAVM","sourcesContent":["import type { SkiaValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n/**\n * Creates a new animation on an existing value that will be driven by\n * an animation value. The value will be run from / to the value in\n * params and modified by the provided easing curve for the length of\n * the duration. When the value has reached its desired \"to\" value the\n * animation will be stopped.\n *\n * @param value The value to animate\n * @param toOrParams To value or Animation parameters\n * @param config Spring or timing configuration\n * @returns an animation value that can be used to start/stop\n * the animation.\n */\nexport const runTiming = (\n value: SkiaValue<number>,\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaAnimation => {\n const resolvedParameters = getResolvedParams(toOrParams, config);\n const animation = createTiming(resolvedParameters, value, callback);\n value.animation = animation;\n return animation;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["useTiming.ts"],"names":["useEffect","useMemo","useRef","useValue","getResolvedParams","createTiming","useTiming","toOrParams","config","callback","prevCfgRef","resolvedParameters","nextParams","equals","current","value","from","prevAnimationRef","prevParamsRef","animation","undefined","a","b","JSON","stringify"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,OAApB,EAA6BC,MAA7B,QAA2C,OAA3C;AAQA,SAASC,QAAT,QAAyB,sBAAzB;AAEA,SAASC,iBAAT,QAAkC,aAAlC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,SAAS,GAAG,CACvBC,UADuB,EAEvBC,MAFuB,EAGvBC,QAHuB,KAIO;AAAA;;AAC9B;AACA;AACA,QAAMC,UAAU,GAAGR,MAAM,EAAzB;AACA,QAAMS,kBAAkB,GAAGV,OAAO,CAAC,MAAM;AACvC,UAAMW,UAAU,GAAGR,iBAAiB,CAACG,UAAD,EAAaC,MAAb,CAApC;;AACA,QAAI,CAACK,MAAM,CAACH,UAAU,CAACI,OAAZ,EAAqBF,UAArB,CAAX,EAA6C;AAC3CF,MAAAA,UAAU,CAACI,OAAX,GAAqBF,UAArB;AACD;;AACD,WAAOF,UAAU,CAACI,OAAlB;AACD,GANiC,EAM/B,CAACN,MAAD,EAASD,UAAT,CAN+B,CAAlC,CAJ8B,CAY9B;;AACA,QAAMQ,KAAK,GAAGZ,QAAQ,0BAACQ,kBAAkB,CAACK,IAApB,yEAA4B,CAA5B,CAAtB,CAb8B,CAe9B;AACA;;AACA,QAAMC,gBAAgB,GAAGf,MAAM,EAA/B;AACA,QAAMgB,aAAa,GAAGhB,MAAM,EAA5B;AACA,QAAMiB,SAAS,GAAGlB,OAAO,CAAC,MAAM;AAC9B,QAAI,CAACY,MAAM,CAACK,aAAa,CAACJ,OAAf,EAAwBH,kBAAxB,CAAX,EAAwD;AACtDO,MAAAA,aAAa,CAACJ,OAAd,GAAwBH,kBAAxB;AACAM,MAAAA,gBAAgB,CAACH,OAAjB,GAA2BT,YAAY,CACrCM,kBADqC,EAErCI,KAFqC,EAGrCN,QAHqC,CAAvC;AAKD;;AACD,WAAOQ,gBAAgB,CAACH,OAAxB;AACD,GAVwB,EAUtB,CAACL,QAAD,EAAWE,kBAAX,EAA+BI,KAA/B,CAVsB,CAAzB,CAnB8B,CA+B9B;;AACAf,EAAAA,SAAS,CAAC,MAAM;AACde,IAAAA,KAAK,CAACI,SAAN,GAAkBA,SAAlB;AACA,WAAO,MAAOJ,KAAK,CAACI,SAAN,GAAkBC,SAAhC;AACD,GAHQ,EAGN,CAACD,SAAD,EAAYJ,KAAZ,CAHM,CAAT,CAhC8B,CAqC9B;;AACA,SAAOA,KAAP;AACD,CA3CM;;AA6CP,MAAMF,MAAM,GAAG,CAASQ,CAAT,EAAgBC,CAAhB,KAA0B;AACvC,SAAOC,IAAI,CAACC,SAAL,CAAeH,CAAf,MAAsBE,IAAI,CAACC,SAAL,CAAeF,CAAf,CAA7B;AACD,CAFD","sourcesContent":["import { useEffect, useMemo, useRef } from \"react\";\n\nimport type { SkiaReadonlyValue, SkiaAnimation } from \"../../types\";\nimport type {\n AnimationParams,\n TimingConfig,\n AnimationCallback,\n} from \"../types\";\nimport { useValue } from \"../../hooks/useValue\";\n\nimport { getResolvedParams } from \"./functions\";\nimport { createTiming } from \"./createTiming\";\n\n/**\n * Creats an animation value that will run whenever\n * the animation parameters change. The animation start immediately.\n * @param toOrParams\n * @param config\n * @returns A value that is animated\n */\nexport const useTiming = (\n toOrParams: number | AnimationParams,\n config?: TimingConfig,\n callback?: AnimationCallback\n): SkiaReadonlyValue<number> => {\n // Resolve parameters - keep a cached version to avoid\n // unnecesary re-renders.\n const prevCfgRef = useRef<ReturnType<typeof getResolvedParams>>();\n const resolvedParameters = useMemo(() => {\n const nextParams = getResolvedParams(toOrParams, config);\n if (!equals(prevCfgRef.current, nextParams)) {\n prevCfgRef.current = nextParams;\n }\n return prevCfgRef.current!;\n }, [config, toOrParams]);\n\n // Create value\n const value = useValue(resolvedParameters.from ?? 0);\n\n // Create timing animation - keep a cached version to avoid\n // uneccessary recreation of animations\n const prevAnimationRef = useRef<SkiaAnimation>();\n const prevParamsRef = useRef<typeof resolvedParameters>();\n const animation = useMemo(() => {\n if (!equals(prevParamsRef.current, resolvedParameters)) {\n prevParamsRef.current = resolvedParameters;\n prevAnimationRef.current = createTiming(\n resolvedParameters,\n value,\n callback\n );\n }\n return prevAnimationRef.current!;\n }, [callback, resolvedParameters, value]);\n\n // Run animation on the value - and stop it on unmount\n useEffect(() => {\n value.animation = animation;\n return () => (value.animation = undefined);\n }, [animation, value]);\n\n // Return the value that is animated\n return value;\n};\n\nconst equals = <T1, T2>(a: T1, b: T2) => {\n return JSON.stringify(a) === JSON.stringify(b);\n};\n"]}
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- declare type ExtrapolateType = "extend" | "identity" | "clamp";
2
- export declare function interpolate(input: number, inputRange: readonly number[], outputRange: readonly number[], options?: {
3
- easing?: (input: number) => number;
4
- extrapolateLeft?: ExtrapolateType;
5
- extrapolateRight?: ExtrapolateType;
6
- }): number;
7
- export {};
@@ -1,3 +0,0 @@
1
- import type { Color } from "../../../skia";
2
- export declare const interpolateColors: (value: number, inputRange: number[], _outputRange: Color[]) => number;
3
- export declare const mixColors: (value: number, x: number, y: number) => number;
@@ -1,169 +0,0 @@
1
- // eslint-disable-next-line max-len
2
- // Taken from https://github.com/facebook/react-native/blob/0b9ea60b4fee8cacc36e7160e31b91fc114dbc0d/Libraries/Animated/src/nodes/AnimatedInterpolation.js
3
-
4
- type ExtrapolateType = "extend" | "identity" | "clamp";
5
-
6
- function interpolateFunction(
7
- input: number,
8
- inputRange: [number, number],
9
- outputRange: [number, number],
10
- options: {
11
- easing: (input: number) => number;
12
- extrapolateLeft: ExtrapolateType;
13
- extrapolateRight: ExtrapolateType;
14
- }
15
- ): number {
16
- const { extrapolateLeft, extrapolateRight, easing } = options;
17
-
18
- let result = input;
19
- const [inputMin, inputMax] = inputRange;
20
- const [outputMin, outputMax] = outputRange;
21
-
22
- if (result < inputMin) {
23
- if (extrapolateLeft === "identity") {
24
- return result;
25
- }
26
-
27
- if (extrapolateLeft === "clamp") {
28
- result = inputMin;
29
- } else if (extrapolateLeft === "extend") {
30
- // noop
31
- }
32
- }
33
-
34
- if (result > inputMax) {
35
- if (extrapolateRight === "identity") {
36
- return result;
37
- }
38
-
39
- if (extrapolateRight === "clamp") {
40
- result = inputMax;
41
- } else if (extrapolateRight === "extend") {
42
- // noop
43
- }
44
- }
45
-
46
- if (outputMin === outputMax) {
47
- return outputMin;
48
- }
49
-
50
- // Input Range
51
- result = (result - inputMin) / (inputMax - inputMin);
52
-
53
- // Easing
54
- result = easing(result);
55
-
56
- // Output Range
57
- result = result * (outputMax - outputMin) + outputMin;
58
-
59
- return result;
60
- }
61
-
62
- function findRange(input: number, inputRange: readonly number[]) {
63
- let i;
64
- for (i = 1; i < inputRange.length - 1; ++i) {
65
- if (inputRange[i] >= input) {
66
- break;
67
- }
68
- }
69
-
70
- return i - 1;
71
- }
72
-
73
- function checkValidInputRange(arr: readonly number[]) {
74
- for (let i = 1; i < arr.length; ++i) {
75
- if (!(arr[i] > arr[i - 1])) {
76
- throw new Error(
77
- `inputRange must be strictly monotonically non-decreasing but got [${arr.join(
78
- ","
79
- )}]`
80
- );
81
- }
82
- }
83
- }
84
-
85
- function checkInfiniteRange(name: string, arr: readonly number[]) {
86
- if (arr.length < 2) {
87
- throw new Error(name + " must have at least 2 elements");
88
- }
89
-
90
- for (const index in arr) {
91
- if (typeof arr[index] !== "number") {
92
- throw new Error(`${name} must contain only numbers`);
93
- }
94
-
95
- if (arr[index] === -Infinity || arr[index] === Infinity) {
96
- throw new Error(
97
- `${name} must contain only finite numbers, but got [${arr.join(",")}]`
98
- );
99
- }
100
- }
101
- }
102
-
103
- export function interpolate(
104
- input: number,
105
- inputRange: readonly number[],
106
- outputRange: readonly number[],
107
- options?: {
108
- easing?: (input: number) => number;
109
- extrapolateLeft?: ExtrapolateType;
110
- extrapolateRight?: ExtrapolateType;
111
- }
112
- ): number {
113
- if (typeof input === "undefined") {
114
- throw new Error("input can not be undefined");
115
- }
116
-
117
- if (typeof inputRange === "undefined") {
118
- throw new Error("inputRange can not be undefined");
119
- }
120
-
121
- if (typeof outputRange === "undefined") {
122
- throw new Error("outputRange can not be undefined");
123
- }
124
-
125
- if (inputRange.length !== outputRange.length) {
126
- throw new Error(
127
- "inputRange (" +
128
- inputRange.length +
129
- ") and outputRange (" +
130
- outputRange.length +
131
- ") must have the same length"
132
- );
133
- }
134
-
135
- checkInfiniteRange("inputRange", inputRange);
136
- checkInfiniteRange("outputRange", outputRange);
137
-
138
- checkValidInputRange(inputRange);
139
-
140
- const easing = options?.easing ?? ((num: number): number => num);
141
-
142
- let extrapolateLeft: ExtrapolateType = "extend";
143
- if (options?.extrapolateLeft !== undefined) {
144
- // eslint-disable-next-line prefer-destructuring
145
- extrapolateLeft = options.extrapolateLeft;
146
- }
147
-
148
- let extrapolateRight: ExtrapolateType = "extend";
149
- if (options?.extrapolateRight !== undefined) {
150
- // eslint-disable-next-line prefer-destructuring
151
- extrapolateRight = options.extrapolateRight;
152
- }
153
-
154
- if (typeof input !== "number") {
155
- throw new TypeError("Cannot interpolate an input which is not a number");
156
- }
157
-
158
- const range = findRange(input, inputRange);
159
- return interpolateFunction(
160
- input,
161
- [inputRange[range], inputRange[range + 1]],
162
- [outputRange[range], outputRange[range + 1]],
163
- {
164
- easing,
165
- extrapolateLeft,
166
- extrapolateRight,
167
- }
168
- );
169
- }
@@ -1,62 +0,0 @@
1
- import { mix } from "../../../renderer";
2
- import type { Color } from "../../../skia";
3
- import { alphaf, blue, green, red, rgbaColor, Skia } from "../../../skia";
4
-
5
- import { interpolate } from "./interpolate";
6
-
7
- const CLAMP = {
8
- extrapolateLeft: "clamp",
9
- extrapolateRight: "clamp",
10
- } as const;
11
-
12
- const interpolateColorsRGB = (
13
- value: number,
14
- inputRange: number[],
15
- outputRange: number[]
16
- ) => {
17
- const r = interpolate(
18
- value,
19
- inputRange,
20
- outputRange.map((c) => red(c)),
21
- CLAMP
22
- );
23
- const g = interpolate(
24
- value,
25
- inputRange,
26
- outputRange.map((c) => green(c)),
27
- CLAMP
28
- );
29
- const b = interpolate(
30
- value,
31
- inputRange,
32
- outputRange.map((c) => blue(c)),
33
- CLAMP
34
- );
35
- const a = interpolate(
36
- value,
37
- inputRange,
38
- outputRange.map((c) => alphaf(c)),
39
- CLAMP
40
- );
41
- return rgbaColor(r, g, b, a);
42
- };
43
-
44
- export const interpolateColors = (
45
- value: number,
46
- inputRange: number[],
47
- _outputRange: Color[]
48
- ) => {
49
- const outputRange = _outputRange.map((cl) => Skia.Color(cl));
50
- return interpolateColorsRGB(value, inputRange, outputRange);
51
- };
52
-
53
- // This is fast. To be reconcilled with interpolateColors
54
- // it looks like interpolateColors may not be working as expected
55
- // these functions need to be tested more thoroughly on both platform
56
- export const mixColors = (value: number, x: number, y: number) => {
57
- const r = mix(value, red(x), red(y));
58
- const g = mix(value, green(x), green(y));
59
- const b = mix(value, blue(x), blue(y));
60
- const a = mix(value, alphaf(x), alphaf(y));
61
- return rgbaColor(r, g, b, a);
62
- };