@shopify/react-native-skia 0.1.225 → 0.1.228

Sign up to get free protection for your applications and to get access to all the features.
Files changed (326) hide show
  1. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +3 -3
  2. package/cpp/api/JsiSkCanvas.h +2 -1
  3. package/cpp/api/JsiSkMatrix.h +35 -13
  4. package/cpp/api/JsiSkPictureRecorder.h +10 -3
  5. package/cpp/api/JsiSkTypeface.h +1 -0
  6. package/cpp/rnskia/dom/props/MatrixProp.h +19 -0
  7. package/cpp/rnskia/dom/props/TransformProp.h +76 -9
  8. package/lib/commonjs/animation/spring/runSpring.d.ts +3 -0
  9. package/lib/commonjs/animation/spring/runSpring.js +3 -0
  10. package/lib/commonjs/animation/spring/runSpring.js.map +1 -1
  11. package/lib/commonjs/animation/spring/useSpring.d.ts +3 -0
  12. package/lib/commonjs/animation/spring/useSpring.js +3 -0
  13. package/lib/commonjs/animation/spring/useSpring.js.map +1 -1
  14. package/lib/commonjs/animation/timing/runTiming.d.ts +3 -0
  15. package/lib/commonjs/animation/timing/runTiming.js +3 -0
  16. package/lib/commonjs/animation/timing/runTiming.js.map +1 -1
  17. package/lib/commonjs/animation/timing/useLoop.d.ts +3 -0
  18. package/lib/commonjs/animation/timing/useLoop.js +3 -0
  19. package/lib/commonjs/animation/timing/useLoop.js.map +1 -1
  20. package/lib/commonjs/animation/timing/useTiming.d.ts +3 -0
  21. package/lib/commonjs/animation/timing/useTiming.js +3 -0
  22. package/lib/commonjs/animation/timing/useTiming.js.map +1 -1
  23. package/lib/commonjs/dom/nodes/JsiSkDOM.js +2 -0
  24. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  25. package/lib/commonjs/dom/nodes/datatypes/Fitting.d.ts +5 -5
  26. package/lib/commonjs/dom/nodes/datatypes/Fitting.js.map +1 -1
  27. package/lib/commonjs/dom/nodes/datatypes/Gradient.d.ts +235 -75
  28. package/lib/commonjs/dom/nodes/datatypes/Gradient.js.map +1 -1
  29. package/lib/commonjs/dom/types/Common.d.ts +3 -3
  30. package/lib/commonjs/dom/types/Common.js.map +1 -1
  31. package/lib/commonjs/external/reanimated/interpolators.d.ts +1 -0
  32. package/lib/commonjs/external/reanimated/interpolators.js +24 -5
  33. package/lib/commonjs/external/reanimated/interpolators.js.map +1 -1
  34. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -1
  35. package/lib/commonjs/external/reanimated/moduleWrapper.js +9 -7
  36. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  37. package/lib/commonjs/renderer/Canvas.js +34 -28
  38. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  39. package/lib/commonjs/renderer/components/Drawing.d.ts +5 -0
  40. package/lib/commonjs/renderer/components/Drawing.js +5 -0
  41. package/lib/commonjs/renderer/components/Drawing.js.map +1 -1
  42. package/lib/commonjs/renderer/components/shapes/FitBox.d.ts +5 -5
  43. package/lib/commonjs/skia/core/Matrix.d.ts +2 -2
  44. package/lib/commonjs/skia/core/Matrix.js.map +1 -1
  45. package/lib/commonjs/skia/core/Picture.d.ts +2 -2
  46. package/lib/commonjs/skia/core/Picture.js +12 -2
  47. package/lib/commonjs/skia/core/Picture.js.map +1 -1
  48. package/lib/commonjs/skia/core/Vector.d.ts +0 -5
  49. package/lib/commonjs/skia/core/Vector.js +1 -17
  50. package/lib/commonjs/skia/core/Vector.js.map +1 -1
  51. package/lib/commonjs/skia/types/Canvas.d.ts +1 -1
  52. package/lib/commonjs/skia/types/Canvas.js.map +1 -1
  53. package/lib/commonjs/skia/types/Matrix.d.ts +4 -20
  54. package/lib/commonjs/skia/types/Matrix.js +4 -70
  55. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  56. package/lib/commonjs/skia/types/Matrix4.d.ts +90 -0
  57. package/lib/commonjs/skia/types/Matrix4.js +312 -0
  58. package/lib/commonjs/skia/types/Matrix4.js.map +1 -0
  59. package/lib/commonjs/skia/types/Path/Path.d.ts +1 -1
  60. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  61. package/lib/commonjs/skia/types/Picture/PictureRecorder.d.ts +1 -1
  62. package/lib/commonjs/skia/types/Picture/PictureRecorder.js.map +1 -1
  63. package/lib/commonjs/skia/types/Rect.d.ts +1 -0
  64. package/lib/commonjs/skia/types/Rect.js +18 -0
  65. package/lib/commonjs/skia/types/Rect.js.map +1 -1
  66. package/lib/commonjs/skia/types/index.d.ts +1 -0
  67. package/lib/commonjs/skia/types/index.js +13 -0
  68. package/lib/commonjs/skia/types/index.js.map +1 -1
  69. package/lib/commonjs/skia/web/Host.d.ts +2 -3
  70. package/lib/commonjs/skia/web/Host.js +4 -12
  71. package/lib/commonjs/skia/web/Host.js.map +1 -1
  72. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  73. package/lib/commonjs/skia/web/JsiSkCanvas.js +13 -13
  74. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +1 -1
  76. package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  77. package/lib/commonjs/skia/web/JsiSkFont.js +2 -2
  78. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  79. package/lib/commonjs/skia/web/JsiSkImage.js +6 -6
  80. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  81. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  82. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  83. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +3 -3
  84. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  85. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js +1 -1
  86. package/lib/commonjs/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  87. package/lib/commonjs/skia/web/JsiSkMatrix.d.ts +2 -2
  88. package/lib/commonjs/skia/web/JsiSkMatrix.js +6 -1
  89. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  90. package/lib/commonjs/skia/web/JsiSkPaint.js +3 -3
  91. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  92. package/lib/commonjs/skia/web/JsiSkPath.js +5 -5
  93. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  94. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +1 -1
  95. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  96. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  97. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  98. package/lib/commonjs/skia/web/JsiSkPicture.js +1 -1
  99. package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
  100. package/lib/commonjs/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  101. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +1 -1
  102. package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
  103. package/lib/commonjs/skia/web/JsiSkShaderFactory.js +5 -5
  104. package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js +3 -3
  106. package/lib/commonjs/skia/web/JsiSkVerticesFactory.js.map +1 -1
  107. package/lib/commonjs/values/api.d.ts +23 -2
  108. package/lib/commonjs/values/api.js +44 -1
  109. package/lib/commonjs/values/api.js.map +1 -1
  110. package/lib/commonjs/values/hooks/useClockValue.d.ts +3 -0
  111. package/lib/commonjs/values/hooks/useClockValue.js +3 -0
  112. package/lib/commonjs/values/hooks/useClockValue.js.map +1 -1
  113. package/lib/commonjs/values/hooks/useComputedValue.d.ts +3 -0
  114. package/lib/commonjs/values/hooks/useComputedValue.js +3 -0
  115. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  116. package/lib/commonjs/values/hooks/useValue.d.ts +3 -0
  117. package/lib/commonjs/values/hooks/useValue.js +3 -0
  118. package/lib/commonjs/values/hooks/useValue.js.map +1 -1
  119. package/lib/commonjs/values/hooks/useValueEffect.d.ts +3 -0
  120. package/lib/commonjs/values/hooks/useValueEffect.js +3 -0
  121. package/lib/commonjs/values/hooks/useValueEffect.js.map +1 -1
  122. package/lib/commonjs/values/types.d.ts +4 -4
  123. package/lib/commonjs/values/types.js.map +1 -1
  124. package/lib/commonjs/views/SkiaView.d.ts +5 -0
  125. package/lib/commonjs/views/SkiaView.js +9 -0
  126. package/lib/commonjs/views/SkiaView.js.map +1 -1
  127. package/lib/module/animation/spring/runSpring.d.ts +3 -0
  128. package/lib/module/animation/spring/runSpring.js +3 -0
  129. package/lib/module/animation/spring/runSpring.js.map +1 -1
  130. package/lib/module/animation/spring/useSpring.d.ts +3 -0
  131. package/lib/module/animation/spring/useSpring.js +3 -0
  132. package/lib/module/animation/spring/useSpring.js.map +1 -1
  133. package/lib/module/animation/timing/runTiming.d.ts +3 -0
  134. package/lib/module/animation/timing/runTiming.js +3 -0
  135. package/lib/module/animation/timing/runTiming.js.map +1 -1
  136. package/lib/module/animation/timing/useLoop.d.ts +3 -0
  137. package/lib/module/animation/timing/useLoop.js +3 -0
  138. package/lib/module/animation/timing/useLoop.js.map +1 -1
  139. package/lib/module/animation/timing/useTiming.d.ts +3 -0
  140. package/lib/module/animation/timing/useTiming.js +3 -0
  141. package/lib/module/animation/timing/useTiming.js.map +1 -1
  142. package/lib/module/dom/nodes/JsiSkDOM.js +2 -0
  143. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  144. package/lib/module/dom/nodes/datatypes/Fitting.d.ts +5 -5
  145. package/lib/module/dom/nodes/datatypes/Fitting.js.map +1 -1
  146. package/lib/module/dom/nodes/datatypes/Gradient.d.ts +235 -75
  147. package/lib/module/dom/nodes/datatypes/Gradient.js.map +1 -1
  148. package/lib/module/dom/types/Common.d.ts +3 -3
  149. package/lib/module/dom/types/Common.js.map +1 -1
  150. package/lib/module/external/reanimated/interpolators.d.ts +1 -0
  151. package/lib/module/external/reanimated/interpolators.js +22 -6
  152. package/lib/module/external/reanimated/interpolators.js.map +1 -1
  153. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -1
  154. package/lib/module/external/reanimated/moduleWrapper.js +7 -6
  155. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  156. package/lib/module/renderer/Canvas.js +35 -29
  157. package/lib/module/renderer/Canvas.js.map +1 -1
  158. package/lib/module/renderer/components/Drawing.d.ts +5 -0
  159. package/lib/module/renderer/components/Drawing.js +6 -0
  160. package/lib/module/renderer/components/Drawing.js.map +1 -1
  161. package/lib/module/renderer/components/shapes/FitBox.d.ts +5 -5
  162. package/lib/module/skia/core/Matrix.d.ts +2 -2
  163. package/lib/module/skia/core/Matrix.js.map +1 -1
  164. package/lib/module/skia/core/Picture.d.ts +2 -2
  165. package/lib/module/skia/core/Picture.js +12 -3
  166. package/lib/module/skia/core/Picture.js.map +1 -1
  167. package/lib/module/skia/core/Vector.d.ts +0 -5
  168. package/lib/module/skia/core/Vector.js +0 -13
  169. package/lib/module/skia/core/Vector.js.map +1 -1
  170. package/lib/module/skia/types/Canvas.d.ts +1 -1
  171. package/lib/module/skia/types/Canvas.js.map +1 -1
  172. package/lib/module/skia/types/Matrix.d.ts +4 -20
  173. package/lib/module/skia/types/Matrix.js +3 -71
  174. package/lib/module/skia/types/Matrix.js.map +1 -1
  175. package/lib/module/skia/types/Matrix4.d.ts +90 -0
  176. package/lib/module/skia/types/Matrix4.js +274 -0
  177. package/lib/module/skia/types/Matrix4.js.map +1 -0
  178. package/lib/module/skia/types/Path/Path.d.ts +1 -1
  179. package/lib/module/skia/types/Path/Path.js.map +1 -1
  180. package/lib/module/skia/types/Picture/PictureRecorder.d.ts +1 -1
  181. package/lib/module/skia/types/Picture/PictureRecorder.js.map +1 -1
  182. package/lib/module/skia/types/Rect.d.ts +1 -0
  183. package/lib/module/skia/types/Rect.js +9 -0
  184. package/lib/module/skia/types/Rect.js.map +1 -1
  185. package/lib/module/skia/types/index.d.ts +1 -0
  186. package/lib/module/skia/types/index.js +1 -0
  187. package/lib/module/skia/types/index.js.map +1 -1
  188. package/lib/module/skia/web/Host.d.ts +2 -3
  189. package/lib/module/skia/web/Host.js +2 -7
  190. package/lib/module/skia/web/Host.js.map +1 -1
  191. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  192. package/lib/module/skia/web/JsiSkCanvas.js +14 -14
  193. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  194. package/lib/module/skia/web/JsiSkColorFilterFactory.js +2 -2
  195. package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
  196. package/lib/module/skia/web/JsiSkFont.js +3 -3
  197. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  198. package/lib/module/skia/web/JsiSkImage.js +7 -7
  199. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  200. package/lib/module/skia/web/JsiSkImageFactory.js +3 -3
  201. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  202. package/lib/module/skia/web/JsiSkImageFilterFactory.js +4 -4
  203. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  204. package/lib/module/skia/web/JsiSkMaskFilterFactory.js +2 -2
  205. package/lib/module/skia/web/JsiSkMaskFilterFactory.js.map +1 -1
  206. package/lib/module/skia/web/JsiSkMatrix.d.ts +2 -2
  207. package/lib/module/skia/web/JsiSkMatrix.js +6 -1
  208. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  209. package/lib/module/skia/web/JsiSkPaint.js +4 -4
  210. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  211. package/lib/module/skia/web/JsiSkPath.js +6 -6
  212. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  213. package/lib/module/skia/web/JsiSkPathEffectFactory.js +2 -2
  214. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  215. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  216. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  217. package/lib/module/skia/web/JsiSkPicture.js +2 -2
  218. package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
  219. package/lib/module/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  220. package/lib/module/skia/web/JsiSkPictureRecorder.js +1 -1
  221. package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
  222. package/lib/module/skia/web/JsiSkShaderFactory.js +6 -6
  223. package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
  224. package/lib/module/skia/web/JsiSkVerticesFactory.js +2 -2
  225. package/lib/module/skia/web/JsiSkVerticesFactory.js.map +1 -1
  226. package/lib/module/values/api.d.ts +23 -2
  227. package/lib/module/values/api.js +44 -1
  228. package/lib/module/values/api.js.map +1 -1
  229. package/lib/module/values/hooks/useClockValue.d.ts +3 -0
  230. package/lib/module/values/hooks/useClockValue.js +3 -0
  231. package/lib/module/values/hooks/useClockValue.js.map +1 -1
  232. package/lib/module/values/hooks/useComputedValue.d.ts +3 -0
  233. package/lib/module/values/hooks/useComputedValue.js +3 -0
  234. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  235. package/lib/module/values/hooks/useValue.d.ts +3 -0
  236. package/lib/module/values/hooks/useValue.js +3 -0
  237. package/lib/module/values/hooks/useValue.js.map +1 -1
  238. package/lib/module/values/hooks/useValueEffect.d.ts +3 -0
  239. package/lib/module/values/hooks/useValueEffect.js +3 -0
  240. package/lib/module/values/hooks/useValueEffect.js.map +1 -1
  241. package/lib/module/values/types.d.ts +4 -4
  242. package/lib/module/values/types.js.map +1 -1
  243. package/lib/module/views/SkiaView.d.ts +5 -0
  244. package/lib/module/views/SkiaView.js +10 -0
  245. package/lib/module/views/SkiaView.js.map +1 -1
  246. package/lib/typescript/src/animation/spring/runSpring.d.ts +3 -0
  247. package/lib/typescript/src/animation/spring/useSpring.d.ts +3 -0
  248. package/lib/typescript/src/animation/timing/runTiming.d.ts +3 -0
  249. package/lib/typescript/src/animation/timing/useLoop.d.ts +3 -0
  250. package/lib/typescript/src/animation/timing/useTiming.d.ts +3 -0
  251. package/lib/typescript/src/dom/nodes/datatypes/Fitting.d.ts +5 -5
  252. package/lib/typescript/src/dom/nodes/datatypes/Gradient.d.ts +235 -75
  253. package/lib/typescript/src/dom/types/Common.d.ts +3 -3
  254. package/lib/typescript/src/external/reanimated/interpolators.d.ts +1 -0
  255. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -1
  256. package/lib/typescript/src/renderer/components/Drawing.d.ts +5 -0
  257. package/lib/typescript/src/renderer/components/shapes/FitBox.d.ts +5 -5
  258. package/lib/typescript/src/skia/core/Matrix.d.ts +2 -2
  259. package/lib/typescript/src/skia/core/Picture.d.ts +2 -2
  260. package/lib/typescript/src/skia/core/Vector.d.ts +0 -5
  261. package/lib/typescript/src/skia/types/Canvas.d.ts +1 -1
  262. package/lib/typescript/src/skia/types/Matrix.d.ts +4 -20
  263. package/lib/typescript/src/skia/types/Matrix4.d.ts +90 -0
  264. package/lib/typescript/src/skia/types/Path/Path.d.ts +1 -1
  265. package/lib/typescript/src/skia/types/Picture/PictureRecorder.d.ts +1 -1
  266. package/lib/typescript/src/skia/types/Rect.d.ts +1 -0
  267. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  268. package/lib/typescript/src/skia/web/Host.d.ts +2 -3
  269. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  270. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +2 -2
  271. package/lib/typescript/src/skia/web/JsiSkPictureRecorder.d.ts +1 -1
  272. package/lib/typescript/src/values/api.d.ts +23 -2
  273. package/lib/typescript/src/values/hooks/useClockValue.d.ts +3 -0
  274. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +3 -0
  275. package/lib/typescript/src/values/hooks/useValue.d.ts +3 -0
  276. package/lib/typescript/src/values/hooks/useValueEffect.d.ts +3 -0
  277. package/lib/typescript/src/values/types.d.ts +4 -4
  278. package/lib/typescript/src/views/SkiaView.d.ts +5 -0
  279. package/package.json +2 -1
  280. package/src/animation/spring/runSpring.ts +3 -0
  281. package/src/animation/spring/useSpring.ts +3 -0
  282. package/src/animation/timing/runTiming.ts +3 -0
  283. package/src/animation/timing/useLoop.ts +3 -0
  284. package/src/animation/timing/useTiming.ts +3 -0
  285. package/src/dom/nodes/JsiSkDOM.ts +4 -0
  286. package/src/dom/nodes/datatypes/Fitting.ts +10 -2
  287. package/src/dom/nodes/datatypes/Gradient.ts +2 -2
  288. package/src/dom/types/Common.ts +5 -3
  289. package/src/external/reanimated/interpolators.ts +30 -7
  290. package/src/external/reanimated/moduleWrapper.ts +6 -0
  291. package/src/renderer/Canvas.tsx +41 -30
  292. package/src/renderer/components/Drawing.tsx +5 -0
  293. package/src/skia/core/Matrix.ts +2 -2
  294. package/src/skia/core/Picture.ts +11 -3
  295. package/src/skia/core/Vector.ts +0 -4
  296. package/src/skia/types/Canvas.ts +1 -1
  297. package/src/skia/types/Matrix.ts +7 -85
  298. package/src/skia/types/Matrix4.ts +344 -0
  299. package/src/skia/types/Path/Path.ts +1 -1
  300. package/src/skia/types/Picture/PictureRecorder.ts +1 -1
  301. package/src/skia/types/Rect.ts +14 -0
  302. package/src/skia/types/index.ts +1 -0
  303. package/src/skia/web/Host.ts +4 -3
  304. package/src/skia/web/JsiSkCanvas.ts +24 -17
  305. package/src/skia/web/JsiSkColorFilterFactory.ts +5 -2
  306. package/src/skia/web/JsiSkFont.ts +3 -3
  307. package/src/skia/web/JsiSkImage.ts +14 -11
  308. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  309. package/src/skia/web/JsiSkImageFilterFactory.ts +5 -5
  310. package/src/skia/web/JsiSkMaskFilterFactory.ts +6 -2
  311. package/src/skia/web/JsiSkMatrix.ts +14 -3
  312. package/src/skia/web/JsiSkPaint.ts +4 -4
  313. package/src/skia/web/JsiSkPath.ts +9 -6
  314. package/src/skia/web/JsiSkPathEffectFactory.ts +2 -2
  315. package/src/skia/web/JsiSkPathFactory.ts +2 -2
  316. package/src/skia/web/JsiSkPicture.ts +4 -4
  317. package/src/skia/web/JsiSkPictureRecorder.ts +6 -2
  318. package/src/skia/web/JsiSkShaderFactory.ts +6 -6
  319. package/src/skia/web/JsiSkVerticesFactory.ts +2 -2
  320. package/src/values/api.ts +55 -2
  321. package/src/values/hooks/useClockValue.ts +3 -0
  322. package/src/values/hooks/useComputedValue.ts +3 -0
  323. package/src/values/hooks/useValue.ts +3 -0
  324. package/src/values/hooks/useValueEffect.ts +3 -0
  325. package/src/values/types.ts +6 -6
  326. package/src/views/SkiaView.tsx +11 -0
@@ -1,34 +1,37 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React, { useEffect, useCallback, useMemo, forwardRef, useRef, useLayoutEffect } from "react";
4
- import { SkiaDomView, SkiaView } from "../views";
3
+ import React, { useEffect, useCallback, useMemo, forwardRef, useRef } from "react";
4
+ import { SkiaDomView, SkiaPictureView } from "../views";
5
5
  import { Skia } from "../skia/Skia";
6
6
  import { JsiDrawingContext } from "../dom/types";
7
- import { useValue } from "../values";
8
7
  import { SkiaRoot } from "./Reconciler";
9
8
  import { NATIVE_DOM } from "./HostComponents";
10
9
  import { isValue } from "./processors";
11
10
  export const useCanvasRef = () => useRef(null);
12
11
 
13
- const useOnSizeEvent = resultValue => {
14
- const onSize = useValue({
15
- width: 0,
16
- height: 0
17
- });
18
- useLayoutEffect(() => {
19
- if (!resultValue) {
20
- return;
12
+ const useOnSizeEvent = (resultValue, onLayout) => {
13
+ return useCallback(event => {
14
+ if (onLayout) {
15
+ onLayout(event);
21
16
  }
22
17
 
23
- return onSize.addListener(newValue => {
24
- if (isValue(resultValue)) {
25
- resultValue.current = newValue;
26
- } else {
27
- resultValue.value = newValue;
28
- }
29
- });
30
- }, [resultValue, onSize]);
31
- return onSize;
18
+ const {
19
+ width,
20
+ height
21
+ } = event.nativeEvent.layout;
22
+
23
+ if (isValue(resultValue)) {
24
+ resultValue.current = {
25
+ width,
26
+ height
27
+ };
28
+ } else if (resultValue) {
29
+ resultValue.value = {
30
+ width,
31
+ height
32
+ };
33
+ }
34
+ }, [onLayout, resultValue]);
32
35
  };
33
36
 
34
37
  export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
@@ -39,9 +42,10 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
39
42
  mode,
40
43
  onTouch,
41
44
  onSize: _onSize,
45
+ onLayout: _onLayout,
42
46
  ...props
43
47
  } = _ref;
44
- const onSize = useOnSizeEvent(_onSize);
48
+ const onLayout = useOnSizeEvent(_onSize, _onLayout);
45
49
  const innerRef = useCanvasRef();
46
50
  const ref = useCombinedRefs(forwardedRef, innerRef);
47
51
  const redraw = useCallback(() => {
@@ -79,23 +83,25 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
79
83
  style: style,
80
84
  root: root.dom,
81
85
  onTouch: onTouch,
82
- onSize: onSize,
86
+ onLayout: onLayout,
83
87
  mode: mode,
84
88
  debug: debug
85
89
  }, props));
86
90
  } else {
87
- return /*#__PURE__*/React.createElement(SkiaView // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ // This is for debugging
92
+ const recorder = Skia.PictureRecorder();
93
+ const canvas = recorder.beginRecording(Skia.XYWHRect(0, 0, 2_000_000, 2_000_000));
94
+ const ctx = new JsiDrawingContext(Skia, canvas);
95
+ root.dom.render(ctx);
96
+ const picture = recorder.finishRecordingAsPicture();
97
+ return /*#__PURE__*/React.createElement(SkiaPictureView // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
98
  , _extends({
89
99
  ref: ref,
90
100
  style: style,
91
101
  mode: mode,
92
102
  debug: debug,
93
- onSize: onSize,
94
- onDraw: (canvas, info) => {
95
- onTouch && onTouch(info.touches);
96
- const ctx = new JsiDrawingContext(Skia, canvas);
97
- root.dom.render(ctx);
98
- }
103
+ picture: picture,
104
+ onLayout: onLayout
99
105
  }, props));
100
106
  }
101
107
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","useLayoutEffect","SkiaDomView","SkiaView","Skia","JsiDrawingContext","useValue","SkiaRoot","NATIVE_DOM","isValue","useCanvasRef","useOnSizeEvent","resultValue","onSize","width","height","addListener","newValue","current","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","_onSize","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","canvas","info","touches","ctx","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n useLayoutEffect,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\n\nimport { SkiaDomView, SkiaView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\nimport { useValue } from \"../values\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (resultValue: SkiaBaseViewProps[\"onSize\"]) => {\n const onSize = useValue({\n width: 0,\n height: 0,\n });\n\n useLayoutEffect(() => {\n if (!resultValue) {\n return;\n }\n return onSize.addListener((newValue) => {\n if (isValue(resultValue)) {\n resultValue.current = newValue;\n } else {\n resultValue.value = newValue;\n }\n });\n }, [resultValue, onSize]);\n\n return onSize;\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n { children, style, debug, mode, onTouch, onSize: _onSize, ...props },\n forwardedRef\n ) => {\n const onSize = useOnSizeEvent(_onSize);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onSize={onSize}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n onSize={onSize}\n onDraw={(canvas, info) => {\n onTouch && onTouch(info.touches);\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n }}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targ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Callback","useMemo","forwardRef","useRef","SkiaDomView","SkiaPictureView","Skia","JsiDrawingContext","SkiaRoot","NATIVE_DOM","isValue","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","current","value","Canvas","forwardedRef","children","style","debug","mode","onTouch","onSize","_onSize","_onLayout","props","innerRef","ref","useCombinedRefs","redraw","getNativeId","id","nativeId","registerValues","values","root","render","unmount","dom","recorder","PictureRecorder","canvas","beginRecording","XYWHRect","ctx","picture","finishRecordingAsPicture","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView, SkiaPictureView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { TouchHandler, SkiaBaseViewProps } from \"../views\";\nimport type { SkiaValue } from \"../values/types\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\nimport { isValue } from \"./processors\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (isValue(resultValue)) {\n resultValue.current = { width, height };\n } else if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onTouch,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const registerValues = useCallback(\n (values: Array<SkiaValue<unknown>>) => {\n if (ref.current !== null) {\n return ref.current.registerValues(values);\n }\n return () => {};\n },\n [ref]\n );\n const root = useMemo(\n () => new SkiaRoot(Skia, registerValues, redraw, getNativeId),\n [redraw, registerValues, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onTouch={onTouch}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n // This is for debugging\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(\n Skia.XYWHRect(0, 0, 2_000_000, 2_000_000)\n );\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.dom.render(ctx);\n const picture = recorder.finishRecordingAsPicture();\n return (\n <SkiaPictureView\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n mode={mode}\n debug={debug}\n picture={picture}\n onLayout={onLayout}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,WAFF,EAGEC,OAHF,EAIEC,UAJF,EAKEC,MALF,QAMO,OANP;AAgBA,SAASC,WAAT,EAAsBC,eAAtB,QAA6C,UAA7C;AACA,SAASC,IAAT,QAAqB,cAArB;AAGA,SAASC,iBAAT,QAAkC,cAAlC;AAEA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,OAAT,QAAwB,cAAxB;AAEA,OAAO,MAAMC,YAAY,GAAG,MAAMR,MAAM,CAAc,IAAd,CAAjC;;AAQP,MAAMS,cAAc,GAAG,CACrBC,WADqB,EAErBC,QAFqB,KAGlB;EACH,OAAOd,WAAW,CACfe,KAAD,IAA8B;IAC5B,IAAID,QAAJ,EAAc;MACZA,QAAQ,CAACC,KAAD,CAAR;IACD;;IACD,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAoBF,KAAK,CAACG,WAAN,CAAkBC,MAA5C;;IAEA,IAAIT,OAAO,CAACG,WAAD,CAAX,EAA0B;MACxBA,WAAW,CAACO,OAAZ,GAAsB;QAAEJ,KAAF;QAASC;MAAT,CAAtB;IACD,CAFD,MAEO,IAAIJ,WAAJ,EAAiB;MACtBA,WAAW,CAACQ,KAAZ,GAAoB;QAAEL,KAAF;QAASC;MAAT,CAApB;IACD;EACF,CAZe,EAahB,CAACH,QAAD,EAAWD,WAAX,CAbgB,CAAlB;AAeD,CAnBD;;AAqBA,OAAO,MAAMS,MAAM,gBAAGpB,UAAU,CAC9B,OAWEqB,YAXF,KAYK;EAAA,IAXH;IACEC,QADF;IAEEC,KAFF;IAGEC,KAHF;IAIEC,IAJF;IAKEC,OALF;IAMEC,MAAM,EAAEC,OANV;IAOEhB,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,EAAS;QACP,IAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;UAC7BA,GAAG,CAACqB,SAAS,CAACnC,OAAX,CAAH;QACD,CAFD,MAEO;UACLc,GAAG,CAACd,OAAJ,GAAcmC,SAAS,CAACnC,OAAxB;QACD;MACF;IACF,CARD;EASD,CAVD,EAUG,CAACkC,IAAD,CAVH;EAWA,OAAOC,SAAP;AACD,CAhBD"}
@@ -1,3 +1,8 @@
1
1
  import React from "react";
2
2
  import type { CustomDrawingNodeProps } from "../../dom/types";
3
+ /**
4
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
5
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
6
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
7
+ */
3
8
  export declare const Drawing: (props: CustomDrawingNodeProps) => React.JSX.Element;
@@ -1,4 +1,10 @@
1
1
  import React from "react";
2
+
3
+ /**
4
+ * @deprecated If you are looking to use the Skia imperative API, you can use:
5
+ * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/
6
+ * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures
7
+ */
2
8
  export const Drawing = props => {
3
9
  return /*#__PURE__*/React.createElement("skDrawing", props);
4
10
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","Drawing","props"],"sources":["Drawing.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { CustomDrawingNodeProps } from \"../../dom/types\";\n\nexport const Drawing = (props: CustomDrawingNodeProps) => {\n return <skDrawing {...props} />;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAIA,OAAO,MAAMC,OAAO,GAAIC,KAAD,IAAmC;EACxD,oBAAO,iCAAeA,KAAf,CAAP;AACD,CAFM"}
1
+ {"version":3,"names":["React","Drawing","props"],"sources":["Drawing.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { CustomDrawingNodeProps } from \"../../dom/types\";\n\n/**\n * @deprecated If you are looking to use the Skia imperative API, you can use:\n * The picture API: https://shopify.github.io/react-native-skia/docs/shapes/pictures/\n * The offscreen API: https://shopify.github.io/react-native-skia/docs/animations/textures\n */\nexport const Drawing = (props: CustomDrawingNodeProps) => {\n return <skDrawing {...props} />;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAIA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAIC,KAAD,IAAmC;EACxD,oBAAO,iCAAeA,KAAf,CAAP;AACD,CAFM"}
@@ -8,14 +8,14 @@ interface FitProps {
8
8
  dst: SkRect;
9
9
  children: ReactNode | ReactNode[];
10
10
  }
11
- export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect) => readonly [{
12
- readonly translateX: number;
11
+ export declare const fitbox: (fit: Fit, src: SkRect, dst: SkRect) => [{
12
+ translateX: number;
13
13
  }, {
14
- readonly translateY: number;
14
+ translateY: number;
15
15
  }, {
16
- readonly scaleX: number;
16
+ scaleX: number;
17
17
  }, {
18
- readonly scaleY: number;
18
+ scaleY: number;
19
19
  }];
20
20
  export declare const FitBox: ({ fit, src, dst, children }: FitProps) => React.JSX.Element;
21
21
  export {};
@@ -1,2 +1,2 @@
1
- import type { Transforms2d } from "../types";
2
- export declare const processTransform2d: (transforms: Transforms2d) => import("../types").SkMatrix;
1
+ import type { Transforms3d } from "../types";
2
+ export declare const processTransform2d: (transforms: Transforms3d) => import("../types").SkMatrix;
@@ -1 +1 @@
1
- {"version":3,"names":["Skia","processTransform","processTransform2d","transforms","Matrix"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms2d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms2d) =>\n processTransform(Skia.Matrix(), transforms);\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;AAEA,SAASC,gBAAT,QAAiC,UAAjC;AAEA,OAAO,MAAMC,kBAAkB,GAAIC,UAAD,IAChCF,gBAAgB,CAACD,IAAI,CAACI,MAAL,EAAD,EAAgBD,UAAhB,CADX"}
1
+ {"version":3,"names":["Skia","processTransform","processTransform2d","transforms","Matrix"],"sources":["Matrix.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Transforms3d } from \"../types\";\nimport { processTransform } from \"../types\";\n\nexport const processTransform2d = (transforms: Transforms3d) =>\n processTransform(Skia.Matrix(), transforms);\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;AAEA,SAASC,gBAAT,QAAiC,UAAjC;AAEA,OAAO,MAAMC,kBAAkB,GAAIC,UAAD,IAChCF,gBAAgB,CAACD,IAAI,CAACI,MAAL,EAAD,EAAgBD,UAAhB,CADX"}
@@ -1,8 +1,8 @@
1
- import type { SkCanvas, SkRect } from "../types";
1
+ import { type SkCanvas, type SkRect, type SkSize } from "../types";
2
2
  /**
3
3
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
4
4
  * @param rect Picture bounds
5
5
  * @param cb Callback for drawing to the canvas
6
6
  * @returns SkPicture
7
7
  */
8
- export declare const createPicture: (rect: SkRect, cb: (canvas: SkCanvas) => void) => import("../types").SkPicture;
8
+ export declare const createPicture: (cb: (canvas: SkCanvas) => void, rect?: SkRect | SkSize) => import("../types").SkPicture;
@@ -1,14 +1,23 @@
1
1
  import { Skia } from "../Skia";
2
-
2
+ import { isRect } from "../types";
3
3
  /**
4
4
  * Memoizes and returns an SkPicture that can be drawn to another canvas.
5
5
  * @param rect Picture bounds
6
6
  * @param cb Callback for drawing to the canvas
7
7
  * @returns SkPicture
8
8
  */
9
- export const createPicture = (rect, cb) => {
9
+
10
+ export const createPicture = (cb, rect) => {
11
+ "worklet";
12
+
10
13
  const recorder = Skia.PictureRecorder();
11
- const canvas = recorder.beginRecording(rect);
14
+ let bounds;
15
+
16
+ if (rect) {
17
+ bounds = isRect(rect) ? rect : Skia.XYWHRect(0, 0, rect.width, rect.height);
18
+ }
19
+
20
+ const canvas = recorder.beginRecording(bounds);
12
21
  cb(canvas);
13
22
  return recorder.finishRecordingAsPicture();
14
23
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Skia","createPicture","rect","cb","recorder","PictureRecorder","canvas","beginRecording","finishRecordingAsPicture"],"sources":["Picture.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { SkCanvas, SkRect } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const createPicture = (rect: SkRect, cb: (canvas: SkCanvas) => void) => {\n const recorder = Skia.PictureRecorder();\n const canvas = recorder.beginRecording(rect);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n};\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAG,CAACC,IAAD,EAAeC,EAAf,KAAkD;EAC7E,MAAMC,QAAQ,GAAGJ,IAAI,CAACK,eAAL,EAAjB;EACA,MAAMC,MAAM,GAAGF,QAAQ,CAACG,cAAT,CAAwBL,IAAxB,CAAf;EACAC,EAAE,CAACG,MAAD,CAAF;EACA,OAAOF,QAAQ,CAACI,wBAAT,EAAP;AACD,CALM"}
1
+ {"version":3,"names":["Skia","isRect","createPicture","cb","rect","recorder","PictureRecorder","bounds","XYWHRect","width","height","canvas","beginRecording","finishRecordingAsPicture"],"sources":["Picture.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport { isRect, type SkCanvas, type SkRect, type SkSize } from \"../types\";\n\n/**\n * Memoizes and returns an SkPicture that can be drawn to another canvas.\n * @param rect Picture bounds\n * @param cb Callback for drawing to the canvas\n * @returns SkPicture\n */\nexport const createPicture = (\n cb: (canvas: SkCanvas) => void,\n rect?: SkRect | SkSize\n) => {\n \"worklet\";\n const recorder = Skia.PictureRecorder();\n let bounds: undefined | SkRect;\n if (rect) {\n bounds = isRect(rect) ? rect : Skia.XYWHRect(0, 0, rect.width, rect.height);\n }\n const canvas = recorder.beginRecording(bounds);\n cb(canvas);\n return recorder.finishRecordingAsPicture();\n};\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;AACA,SAASC,MAAT,QAAgE,UAAhE;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,CAC3BC,EAD2B,EAE3BC,IAF2B,KAGxB;EACH;;EACA,MAAMC,QAAQ,GAAGL,IAAI,CAACM,eAAL,EAAjB;EACA,IAAIC,MAAJ;;EACA,IAAIH,IAAJ,EAAU;IACRG,MAAM,GAAGN,MAAM,CAACG,IAAD,CAAN,GAAeA,IAAf,GAAsBJ,IAAI,CAACQ,QAAL,CAAc,CAAd,EAAiB,CAAjB,EAAoBJ,IAAI,CAACK,KAAzB,EAAgCL,IAAI,CAACM,MAArC,CAA/B;EACD;;EACD,MAAMC,MAAM,GAAGN,QAAQ,CAACO,cAAT,CAAwBL,MAAxB,CAAf;EACAJ,EAAE,CAACQ,MAAD,CAAF;EACA,OAAON,QAAQ,CAACQ,wBAAT,EAAP;AACD,CAbM"}
@@ -5,8 +5,3 @@ export declare const neg: (a: Vector) => import("../types").SkPoint;
5
5
  export declare const add: (a: Vector, b: Vector) => import("../types").SkPoint;
6
6
  export declare const sub: (a: Vector, b: Vector) => import("../types").SkPoint;
7
7
  export declare const dist: (a: Vector, b: Vector) => number;
8
- export declare const translate: ({ x, y }: Vector) => readonly [{
9
- readonly translateX: number;
10
- }, {
11
- readonly translateY: number;
12
- }];
@@ -27,17 +27,4 @@ export const dist = (a, b) => {
27
27
 
28
28
  return Math.hypot(a.x - b.x, a.y - b.y);
29
29
  };
30
- export const translate = _ref => {
31
- "worklet";
32
-
33
- let {
34
- x,
35
- y
36
- } = _ref;
37
- return [{
38
- translateX: x
39
- }, {
40
- translateY: y
41
- }];
42
- };
43
30
  //# sourceMappingURL=Vector.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot","translate","translateX","translateY"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\nexport const translate = ({ x, y }: Vector) => {\n \"worklet\";\n return [{ translateX: x }, { translateY: y }] as const;\n};\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;AAGA,OAAO,MAAMC,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOH,IAAI,CAACI,KAAL,CAAWF,CAAX,EAAcC,CAAd,aAAcA,CAAd,cAAcA,CAAd,GAAmBD,CAAnB,CAAP;AACD,CAHM;AAIP,OAAO,MAAMG,KAAK,GAAGJ,GAAd;AACP,OAAO,MAAMK,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAON,GAAG,CAAC,CAACM,CAAC,CAACL,CAAJ,EAAO,CAACK,CAAC,CAACJ,CAAV,CAAV;AACD,CAHM;AAIP,OAAO,MAAMK,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMO,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMQ,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAnB,EAAsBK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAA9B,CAAP;AACD,CAHM;AAIP,OAAO,MAAMW,SAAS,GAAG,QAAsB;EAC7C;;EAD6C,IAArB;IAAEZ,CAAF;IAAKC;EAAL,CAAqB;EAE7C,OAAO,CAAC;IAAEY,UAAU,EAAEb;EAAd,CAAD,EAAoB;IAAEc,UAAU,EAAEb;EAAd,CAApB,CAAP;AACD,CAHM"}
1
+ {"version":3,"names":["Skia","vec","x","y","Point","point","neg","a","add","b","sub","dist","Math","hypot"],"sources":["Vector.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { Vector } from \"../types\";\n\nexport const vec = (x = 0, y?: number) => {\n \"worklet\";\n return Skia.Point(x, y ?? x);\n};\nexport const point = vec;\nexport const neg = (a: Vector) => {\n \"worklet\";\n return vec(-a.x, -a.y);\n};\nexport const add = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x + b.x, a.y + b.y);\n};\nexport const sub = (a: Vector, b: Vector) => {\n \"worklet\";\n return vec(a.x - b.x, a.y - b.y);\n};\nexport const dist = (a: Vector, b: Vector) => {\n \"worklet\";\n return Math.hypot(a.x - b.x, a.y - b.y);\n};\n"],"mappings":"AAAA,SAASA,IAAT,QAAqB,SAArB;AAGA,OAAO,MAAMC,GAAG,GAAG,YAAuB;EACxC;;EADwC,IAAtBC,CAAsB,uEAAlB,CAAkB;EAAA,IAAfC,CAAe;EAExC,OAAOH,IAAI,CAACI,KAAL,CAAWF,CAAX,EAAcC,CAAd,aAAcA,CAAd,cAAcA,CAAd,GAAmBD,CAAnB,CAAP;AACD,CAHM;AAIP,OAAO,MAAMG,KAAK,GAAGJ,GAAd;AACP,OAAO,MAAMK,GAAG,GAAIC,CAAD,IAAe;EAChC;;EACA,OAAON,GAAG,CAAC,CAACM,CAAC,CAACL,CAAJ,EAAO,CAACK,CAAC,CAACJ,CAAV,CAAV;AACD,CAHM;AAIP,OAAO,MAAMK,GAAG,GAAG,CAACD,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMO,GAAG,GAAG,CAACH,CAAD,EAAYE,CAAZ,KAA0B;EAC3C;;EACA,OAAOR,GAAG,CAACM,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAT,EAAYK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAApB,CAAV;AACD,CAHM;AAIP,OAAO,MAAMQ,IAAI,GAAG,CAACJ,CAAD,EAAYE,CAAZ,KAA0B;EAC5C;;EACA,OAAOG,IAAI,CAACC,KAAL,CAAWN,CAAC,CAACL,CAAF,GAAMO,CAAC,CAACP,CAAnB,EAAsBK,CAAC,CAACJ,CAAF,GAAMM,CAAC,CAACN,CAA9B,CAAP;AACD,CAHM"}
@@ -372,7 +372,7 @@ export interface SkCanvas {
372
372
  * Replaces current matrix with m premultiplied with the existing matrix.
373
373
  * @param m
374
374
  */
375
- concat(m: SkMatrix): void;
375
+ concat(m: SkMatrix | number[]): void;
376
376
  /**
377
377
  * Draws the given picture using the current clip, current matrix, and the provided paint.
378
378
  * @param skp
@@ -1 +1 @@
1
- {"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode, ImageInfo } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n\n /** Read Image pixels\n *\n * @param srcX - x-axis upper left corner of the rectangle to read from\n * @param srcY - y-axis upper left corner of the rectangle to read from\n * @param imageInfo - describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX: number,\n srcY: number,\n imageInfo: ImageInfo\n ): Float32Array | Uint8Array | null;\n}\n"],"mappings":"AAgBA,WAAYA,MAAZ;;WAAYA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAKZ,WAAYC,aAAZ;;WAAYA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a"}
1
+ {"version":3,"names":["ClipOp","SaveLayerFlag"],"sources":["Canvas.ts"],"sourcesContent":["import type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkFont } from \"./Font\";\nimport type { SkPath } from \"./Path\";\nimport type { SkImage, MipmapMode, FilterMode, ImageInfo } from \"./Image\";\nimport type { SkSVG } from \"./SVG\";\nimport type { SkColor } from \"./Color\";\nimport type { SkRRect } from \"./RRect\";\nimport type { BlendMode } from \"./Paint/BlendMode\";\nimport type { SkPoint, PointMode } from \"./Point\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { SkImageFilter } from \"./ImageFilter\";\nimport type { SkVertices } from \"./Vertices\";\nimport type { SkTextBlob } from \"./TextBlob\";\nimport type { SkPicture } from \"./Picture\";\n\nexport enum ClipOp {\n Difference,\n Intersect,\n}\n\nexport enum SaveLayerFlag {\n SaveLayerInitWithPrevious = 1 << 2,\n SaveLayerF16ColorType = 1 << 4,\n}\n\nexport interface SkCanvas {\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix, and optionally-provided paint.\n * @param img\n * @param left\n * @param top\n * @param paint\n */\n drawImage: (image: SkImage, x: number, y: number, paint?: SkPaint) => void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * @param img\n * @param src\n * @param dest\n * @param paint\n * @param fastSample - if false, will filter strictly within src.\n */\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param left\n * @param top\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the given image with its top-left corner at (left, top) using the current clip,\n * the current matrix. It will use the provided sampling options if necessary.\n * @param img\n * @param left\n * @param top\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws the provided image stretched proportionally to fit into dst rectangle.\n * The center rectangle divides the image into nine sections: four sides, four corners, and\n * the center.\n * @param img\n * @param center\n * @param dest\n * @param filter - what technique to use when sampling the image\n * @param paint\n */\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the cubic sampling options B and C if necessary.\n * @param img\n * @param src\n * @param dest\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param paint\n */\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ): void;\n\n /**\n * Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.\n * It will use the provided sampling options if necessary.\n * @param img\n * @param src\n * @param dest\n * @param fm - The filter mode.\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps\n * calculated with makeCopyWithDefaultMipmaps;\n * @param paint\n */\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ): void;\n\n /** Fills clip with SkPaint paint. SkPaint components, SkShader,\n SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;\n SkMaskFilter and SkPathEffect in paint are ignored.\n\n @param paint graphics state used to fill SkCanvas\n\n example: https://fiddle.skia.org/c/@Canvas_drawPaint\n */\n drawPaint: (paint: SkPaint) => void;\n\n /** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint stroke width describes the line thickness;\n SkPaint::Cap draws the end rounded or square;\n SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.\n\n @param x0 start of line segment on x-axis\n @param y0 start of line segment on y-axis\n @param x1 end of line segment on x-axis\n @param y1 end of line segment on y-axis\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawLine\n */\n drawLine: (\n x0: number,\n y0: number,\n x1: number,\n y1: number,\n paint: SkPaint\n ) => void;\n /** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.\n In paint: SkPaint::Style determines if rectangle is stroked or filled;\n if stroked, SkPaint stroke width describes the line thickness, and\n SkPaint::Join draws the corners rounded or square.\n\n @param rect rectangle to draw\n @param paint stroke or fill, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawRect\n */\n drawRect: (rect: SkRect, paint: SkPaint) => void;\n\n /**\n * Draws a circle at (cx, cy) with the given radius.\n * @param cx\n * @param cy\n * @param radius\n * @param paint\n */\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint): void;\n\n /**\n * Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the\n * provided paint.\n * If paint contains an Shader and vertices does not contain texCoords, the shader\n * is mapped using the vertices' positions.\n * If vertices colors are defined in vertices, and Paint paint contains Shader,\n * BlendMode mode combines vertices colors with Shader.\n * @param verts\n * @param mode\n * @param paint\n */\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint): void;\n\n /**\n * Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional\n * colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]\n * @param cubics 12 points : 4 connected cubics specifying the boundary of the patch\n * @param colors optional colors interpolated across the patch\n * @param texs optional shader coordinates interpolated across the patch\n * @param mode Specifies how shader and colors blend (if both are specified)\n * @param paint\n */\n drawPatch(\n cubics: readonly SkPoint[],\n colors?: readonly SkColor[] | null,\n texs?: readonly SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ): void;\n\n /**\n * Restores state to a previous stack value.\n * @param saveCount\n */\n restoreToCount(saveCount: number): void;\n\n /**\n * Draws the given points using the current clip, current matrix, and the provided paint.\n *\n * See Canvas.h for more on the mode and its interaction with paint.\n * @param mode\n * @param points\n * @param paint\n */\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint): void;\n\n /** Draws arc using clip, SkMatrix, and SkPaint paint.\n\n Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus\n sweepAngle. startAngle and sweepAngle are in degrees.\n\n startAngle of zero places start point at the right middle edge of oval.\n A positive sweepAngle places arc end point clockwise from start point;\n a negative sweepAngle places arc end point counterclockwise from start point.\n sweepAngle may exceed 360 degrees, a full circle.\n If useCenter is true, draw a wedge that includes lines from oval\n center to arc end points. If useCenter is false, draw arc between end points.\n\n If SkRect oval is empty or sweepAngle is zero, nothing is drawn.\n\n @param oval SkRect bounds of oval containing arc to draw\n @param startAngle angle in degrees where arc begins\n @param sweepAngle sweep angle in degrees; positive is clockwise\n @param useCenter if true, include the center of the oval\n @param paint SkPaint stroke or fill, blend, color, and so on, used to draw\n */\n drawArc: (\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) => void;\n\n /**\n * Draws the given rectangle with rounded corners using the current clip, current matrix,\n * and the provided paint.\n * @param rrect\n * @param paint\n */\n drawRRect(rrect: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws RRect outer and inner using clip, Matrix, and Paint paint.\n * outer must contain inner or the drawing is undefined.\n * @param outer\n * @param inner\n * @param paint\n */\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint): void;\n\n /**\n * Draws an oval bounded by the given rectangle using the current clip, current matrix,\n * and the provided paint.\n * @param oval\n * @param paint\n */\n drawOval(oval: SkRect, paint: SkPaint): void;\n\n /** Draws SkPath path using clip, SkMatrix, and SkPaint paint.\n SkPath contains an array of path contour, each of which may be open or closed.\n\n In paint: SkPaint::Style determines if SkRRect is stroked or filled:\n if filled, SkPath::FillType determines whether path contour describes inside or\n outside of fill; if stroked, SkPaint stroke width describes the line thickness,\n SkPaint::Cap describes line ends, and SkPaint::Join describes how\n corners are drawn.\n\n @param path SkPath to draw\n @param paint stroke, blend, color, and so on, used to draw\n\n example: https://fiddle.skia.org/c/@Canvas_drawPath\n */\n drawPath: (path: SkPath, paint: SkPaint) => void;\n\n /**\n * Draw the given text at the location (x, y) using the provided paint and font. The text will\n * be drawn as is; no shaping, left-to-right, etc.\n * @param str\n * @param x\n * @param y\n * @param paint\n * @param font\n */\n drawText(\n str: string,\n x: number,\n y: number,\n paint: SkPaint,\n font: SkFont\n ): void;\n\n /**\n * Draws the given TextBlob at (x, y) using the current clip, current matrix, and the\n * provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.\n * @param blob\n * @param x\n * @param y\n * @param paint\n */\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;\n\n /**\n * Draws a run of glyphs, at corresponding positions, in a given font.\n * @param glyphs the array of glyph IDs (Uint16TypedArray)\n * @param positions the array of x,y floats to position each glyph\n * @param x x-coordinate of the origin of the entire run\n * @param y y-coordinate of the origin of the entire run\n * @param font the font that contains the glyphs\n * @param paint\n */\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ): void;\n\n /**\n * Renders the SVG Dom object to the canvas. If width/height are omitted,\n * the SVG will be rendered to fit the canvas.\n */\n drawSvg: (svgDom: SkSVG, width?: number, height?: number) => void;\n /** Saves SkMatrix and clip.\n Calling restore() discards changes to SkMatrix and clip,\n restoring the SkMatrix and clip to their state when save() was called.\n\n SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),\n and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().\n\n Saved SkCanvas state is put on a stack; multiple calls to save() should be balance\n by an equal number of calls to restore().\n\n Call restoreToCount() with result to restore this and subsequent saves.\n\n @return depth of saved stack\n\n example: https://fiddle.skia.org/c/@Canvas_save\n */\n save: () => number;\n\n /**\n * Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing.\n * Calling restore() discards changes to Matrix and clip, and draws the SkBitmap.\n * It returns the height of the stack.\n * See Canvas.h for more.\n * @param paint\n * @param bounds\n * @param backdrop\n * @param flags\n */\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ): number;\n\n /** Removes changes to SkMatrix and clip since SkCanvas state was\n last saved. The state is removed from the stack.\n\n Does nothing if the stack is empty.\n\n example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore\n\n example: https://fiddle.skia.org/c/@Canvas_restore\n */\n restore: () => void;\n\n /**\n * Rotates the current matrix by the number of degrees.\n * @param rot - angle of rotation in degrees.\n * @param rx\n * @param ry\n */\n rotate(rotationInDegrees: number, rx: number, ry: number): void;\n\n /**\n * Scales the current matrix by sx on the x-axis and sy on the y-axis.\n * @param sx\n * @param sy\n */\n scale(sx: number, sy: number): void;\n\n /**\n * Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx\n * skews the drawing right as y-axis values increase; a positive value of sy skews\n * the drawing down as x-axis values increase.\n * @param sx\n * @param sy\n */\n skew(sx: number, sy: number): void;\n\n /**\n * Translates Matrix by dx along the x-axis and dy along the y-axis.\n * @param dx\n * @param dy\n */\n translate(dx: number, dy: number): void;\n\n /**\n * Fills clip with the given color.\n * @param color\n * @param blendMode - defaults to SrcOver.\n */\n drawColor(color: SkColor, blendMode?: BlendMode): void;\n\n /**\n * Fills the current clip with the given color using Src BlendMode.\n * This has the effect of replacing all pixels contained by clip with color.\n * @param color\n */\n clear(color: SkColor): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and path,\n * with an aliased or anti-aliased clip edge.\n * @param path\n * @param op\n * @param doAntiAlias\n */\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rect,\n * with an aliased or anti-aliased clip edge.\n * @param rect\n * @param op\n * @param doAntiAlias\n */\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces clip with the intersection or difference of the current clip and rrect,\n * with an aliased or anti-aliased clip edge.\n * @param rrect\n * @param op\n * @param doAntiAlias\n */\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean): void;\n\n /**\n * Replaces current matrix with m premultiplied with the existing matrix.\n * @param m\n */\n concat(m: SkMatrix | number[]): void;\n\n /**\n * Draws the given picture using the current clip, current matrix, and the provided paint.\n * @param skp\n */\n drawPicture(skp: SkPicture): void;\n\n /** Read Image pixels\n *\n * @param srcX - x-axis upper left corner of the rectangle to read from\n * @param srcY - y-axis upper left corner of the rectangle to read from\n * @param imageInfo - describes the pixel format and dimensions of the data to read into\n * @return Float32Array or Uint8Array with data or null if the read failed.\n */\n readPixels(\n srcX: number,\n srcY: number,\n imageInfo: ImageInfo\n ): Float32Array | Uint8Array | null;\n}\n"],"mappings":"AAgBA,WAAYA,MAAZ;;WAAYA,M;EAAAA,M,CAAAA,M;EAAAA,M,CAAAA,M;GAAAA,M,KAAAA,M;;AAKZ,WAAYC,aAAZ;;WAAYA,a;EAAAA,a,CAAAA,a;EAAAA,a,CAAAA,a;GAAAA,a,KAAAA,a"}
@@ -1,19 +1,9 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
2
  import type { SkCanvas } from "./Canvas";
3
- export declare enum MatrixIndex {
4
- ScaleX = 0,
5
- SkewX = 1,
6
- TransX = 2,
7
- SkewY = 3,
8
- ScaleY = 4,
9
- TransY = 5,
10
- Persp0 = 6,
11
- Persp1 = 7,
12
- Persp2 = 8
13
- }
3
+ import type { Matrix3, Matrix4, Transforms3d } from "./Matrix4";
14
4
  export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
15
5
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
16
- concat: (matrix: SkMatrix) => SkMatrix;
6
+ concat: (matrix: SkMatrix | Matrix4 | Matrix3 | number[]) => SkMatrix;
17
7
  translate: (x: number, y: number) => SkMatrix;
18
8
  scale: (x: number, y?: number) => SkMatrix;
19
9
  skew: (x: number, y: number) => SkMatrix;
@@ -25,14 +15,8 @@ export interface SkMatrix extends SkJSIInstance<"Matrix"> {
25
15
  identity: () => SkMatrix;
26
16
  get: () => number[];
27
17
  }
28
- type Transform2dName = "translateX" | "translateY" | "scale" | "skewX" | "skewY" | "scaleX" | "scaleY" | "rotateZ" | "rotate";
29
- type Transformations = {
30
- readonly [Name in Transform2dName]: number;
31
- };
32
- export type Transforms2d = readonly (Pick<Transformations, "translateX"> | Pick<Transformations, "translateY"> | Pick<Transformations, "scale"> | Pick<Transformations, "scaleX"> | Pick<Transformations, "scaleY"> | Pick<Transformations, "skewX"> | Pick<Transformations, "skewY"> | Pick<Transformations, "rotate">)[];
33
18
  export interface TransformProp {
34
- transform?: Transforms2d;
19
+ transform?: Transforms3d;
35
20
  }
36
- export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms2d) => T;
21
+ export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms3d) => T;
37
22
  export declare const toDegrees: (rad: number) => number;
38
- export {};
@@ -1,78 +1,10 @@
1
- export let MatrixIndex;
2
-
3
- (function (MatrixIndex) {
4
- MatrixIndex[MatrixIndex["ScaleX"] = 0] = "ScaleX";
5
- MatrixIndex[MatrixIndex["SkewX"] = 1] = "SkewX";
6
- MatrixIndex[MatrixIndex["TransX"] = 2] = "TransX";
7
- MatrixIndex[MatrixIndex["SkewY"] = 3] = "SkewY";
8
- MatrixIndex[MatrixIndex["ScaleY"] = 4] = "ScaleY";
9
- MatrixIndex[MatrixIndex["TransY"] = 5] = "TransY";
10
- MatrixIndex[MatrixIndex["Persp0"] = 6] = "Persp0";
11
- MatrixIndex[MatrixIndex["Persp1"] = 7] = "Persp1";
12
- MatrixIndex[MatrixIndex["Persp2"] = 8] = "Persp2";
13
- })(MatrixIndex || (MatrixIndex = {}));
14
-
1
+ import { processTransform3d } from "./Matrix4";
15
2
  export const isMatrix = obj => obj !== null && obj.__typename__ === "Matrix";
16
3
  export const processTransform = (m, transforms) => {
17
- for (const transform of transforms) {
18
- const key = Object.keys(transform)[0];
19
- const value = transform[key];
20
-
21
- if (key === "translateX") {
22
- m.translate(value, 0);
23
- continue;
24
- }
25
-
26
- if (key === "translateY") {
27
- m.translate(0, value);
28
- continue;
29
- }
30
-
31
- if (key === "scale") {
32
- m.scale(value, value);
33
- continue;
34
- }
35
-
36
- if (key === "scaleX") {
37
- m.scale(value, 1);
38
- continue;
39
- }
40
-
41
- if (key === "scaleY") {
42
- m.scale(1, value);
43
- continue;
44
- }
45
-
46
- if (key === "skewX") {
47
- m.skew(value, 0);
48
- continue;
49
- }
50
-
51
- if (key === "skewY") {
52
- m.skew(0, value);
53
- continue;
54
- }
55
-
56
- if (key === "rotate" || key === "rotateZ") {
57
- if (isMatrix(m)) {
58
- m.rotate(value);
59
- } else {
60
- m.rotate(toDegrees(value), 0, 0);
61
- }
62
-
63
- continue;
64
- }
65
-
66
- exhaustiveCheck(key);
67
- }
68
-
4
+ const m3 = processTransform3d(transforms);
5
+ m.concat(m3);
69
6
  return m;
70
7
  };
71
-
72
- const exhaustiveCheck = a => {
73
- throw new Error(`Unknown transformation: ${a}`);
74
- };
75
-
76
8
  export const toDegrees = rad => {
77
9
  return rad * 180 / Math.PI;
78
10
  };
@@ -1 +1 @@
1
- {"version":3,"names":["MatrixIndex","isMatrix","obj","__typename__","processTransform","m","transforms","transform","key","Object","keys","value","translate","scale","skew","rotate","toDegrees","exhaustiveCheck","a","Error","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nexport enum MatrixIndex {\n ScaleX = 0,\n SkewX = 1,\n TransX = 2,\n SkewY = 3,\n ScaleY = 4,\n TransY = 5,\n Persp0 = 6,\n Persp1 = 7,\n Persp2 = 8,\n}\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: SkMatrix) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\ntype Transform2dName =\n | \"translateX\"\n | \"translateY\"\n | \"scale\"\n | \"skewX\"\n | \"skewY\"\n | \"scaleX\"\n | \"scaleY\"\n | \"rotateZ\"\n | \"rotate\";\n\ntype Transformations = {\n readonly [Name in Transform2dName]: number;\n};\n\nexport type Transforms2d = readonly (\n | Pick<Transformations, \"translateX\">\n | Pick<Transformations, \"translateY\">\n | Pick<Transformations, \"scale\">\n | Pick<Transformations, \"scaleX\">\n | Pick<Transformations, \"scaleY\">\n | Pick<Transformations, \"skewX\">\n | Pick<Transformations, \"skewY\">\n | Pick<Transformations, \"rotate\">\n)[];\n\nexport interface TransformProp {\n transform?: Transforms2d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms2d\n) => {\n for (const transform of transforms) {\n const key = Object.keys(transform)[0] as Transform2dName;\n const value = (transform as Pick<Transformations, typeof key>)[key];\n if (key === \"translateX\") {\n m.translate(value, 0);\n continue;\n }\n if (key === \"translateY\") {\n m.translate(0, value);\n continue;\n }\n if (key === \"scale\") {\n m.scale(value, value);\n continue;\n }\n if (key === \"scaleX\") {\n m.scale(value, 1);\n continue;\n }\n if (key === \"scaleY\") {\n m.scale(1, value);\n continue;\n }\n if (key === \"skewX\") {\n m.skew(value, 0);\n continue;\n }\n if (key === \"skewY\") {\n m.skew(0, value);\n continue;\n }\n if (key === \"rotate\" || key === \"rotateZ\") {\n if (isMatrix(m)) {\n m.rotate(value);\n } else {\n m.rotate(toDegrees(value), 0, 0);\n }\n continue;\n }\n exhaustiveCheck(key);\n }\n return m;\n};\n\nconst exhaustiveCheck = (a: never): never => {\n throw new Error(`Unknown transformation: ${a}`);\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":"AAEA,WAAYA,WAAZ;;WAAYA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA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AIH,GAAG,KAAK,QAAR,IAAoBA,GAAG,KAAK,SAAhC,EAA2C;MACzC,IAAIP,QAAQ,CAACI,CAAD,CAAZ,EAAiB;QACfA,CAAC,CAACU,MAAF,CAASJ,KAAT;MACD,CAFD,MAEO;QACLN,CAAC,CAACU,MAAF,CAASC,SAAS,CAACL,KAAD,CAAlB,EAA2B,CAA3B,EAA8B,CAA9B;MACD;;MACD;IACD;;IACDM,eAAe,CAACT,GAAD,CAAf;EACD;;EACD,OAAOH,CAAP;AACD,CA9CM;;AAgDP,MAAMY,eAAe,GAAIC,CAAD,IAAqB;EAC3C,MAAM,IAAIC,KAAJ,CAAW,2BAA0BD,CAAE,EAAvC,CAAN;AACD,CAFD;;AAIA,OAAO,MAAMF,SAAS,GAAII,GAAD,IAAiB;EACxC,OAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,EAA1B;AACD,CAFM"}
1
+ {"version":3,"names":["processTransform3d","isMatrix","obj","__typename__","processTransform","m","transforms","m3","concat","toDegrees","rad","Math","PI"],"sources":["Matrix.ts"],"sourcesContent":["import type { SkJSIInstance } from \"./JsiInstance\";\nimport type { SkCanvas } from \"./Canvas\";\nimport type { Matrix3, Matrix4, Transforms3d } from \"./Matrix4\";\nimport { processTransform3d } from \"./Matrix4\";\n\nexport const isMatrix = (obj: unknown): obj is SkMatrix =>\n obj !== null && (obj as SkJSIInstance<string>).__typename__ === \"Matrix\";\n\nexport interface SkMatrix extends SkJSIInstance<\"Matrix\"> {\n concat: (matrix: SkMatrix | Matrix4 | Matrix3 | number[]) => SkMatrix;\n translate: (x: number, y: number) => SkMatrix;\n scale: (x: number, y?: number) => SkMatrix;\n skew: (x: number, y: number) => SkMatrix;\n rotate: (theta: number) => SkMatrix;\n postTranslate: (x: number, y: number) => SkMatrix;\n postScale: (x: number, y?: number) => SkMatrix;\n postSkew: (x: number, y: number) => SkMatrix;\n postRotate: (theta: number) => SkMatrix;\n identity: () => SkMatrix;\n get: () => number[];\n}\n\nexport interface TransformProp {\n transform?: Transforms3d;\n}\n\nexport const processTransform = <T extends SkMatrix | SkCanvas>(\n m: T,\n transforms: Transforms3d\n) => {\n const m3 = processTransform3d(transforms);\n m.concat(m3);\n return m;\n};\n\nexport const toDegrees = (rad: number) => {\n return (rad * 180) / Math.PI;\n};\n"],"mappings":"AAGA,SAASA,kBAAT,QAAmC,WAAnC;AAEA,OAAO,MAAMC,QAAQ,GAAIC,GAAD,IACtBA,GAAG,KAAK,IAAR,IAAiBA,GAAD,CAA+BC,YAA/B,KAAgD,QAD3D;AAqBP,OAAO,MAAMC,gBAAgB,GAAG,CAC9BC,CAD8B,EAE9BC,UAF8B,KAG3B;EACH,MAAMC,EAAE,GAAGP,kBAAkB,CAACM,UAAD,CAA7B;EACAD,CAAC,CAACG,MAAF,CAASD,EAAT;EACA,OAAOF,CAAP;AACD,CAPM;AASP,OAAO,MAAMI,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAQA,GAAG,GAAG,GAAP,GAAcC,IAAI,CAACC,EAA1B;AACD,CAFM"}