@@ -123,6 +123,7 @@ Context2d::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
123
123
Nan::SetPrototypeMethod (ctor, " rotate" , Rotate);
124
124
Nan::SetPrototypeMethod (ctor, " translate" , Translate);
125
125
Nan::SetPrototypeMethod (ctor, " transform" , Transform);
126
+ Nan::SetPrototypeMethod (ctor, " getTransform" , GetTransform);
126
127
Nan::SetPrototypeMethod (ctor, " resetTransform" , ResetTransform);
127
128
Nan::SetPrototypeMethod (ctor, " setTransform" , SetTransform);
128
129
Nan::SetPrototypeMethod (ctor, " isPointInPath" , IsPointInPath);
@@ -1751,11 +1752,11 @@ NAN_SETTER(Context2d::SetQuality) {
1751
1752
}
1752
1753
1753
1754
/*
1754
- * Get current transform.
1755
+ * Helper for get current transform matrix
1755
1756
*/
1756
1757
1757
- NAN_GETTER (Context2d::GetCurrentTransform) {
1758
- Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info. This ());
1758
+ Local<Object>
1759
+ get_current_transform ( Context2d *context) {
1759
1760
Isolate *iso = Isolate::GetCurrent ();
1760
1761
1761
1762
Local<Float64Array> arr = Float64Array::New (ArrayBuffer::New (iso, 48 ), 0 , 6 );
@@ -1771,7 +1772,16 @@ NAN_GETTER(Context2d::GetCurrentTransform) {
1771
1772
1772
1773
const int argc = 1 ;
1773
1774
Local<Value> argv[argc] = { arr };
1774
- Local<Object> instance = Nan::NewInstance (_DOMMatrix.Get (iso), argc, argv).ToLocalChecked ();
1775
+ return Nan::NewInstance (context->_DOMMatrix .Get (iso), argc, argv).ToLocalChecked ();
1776
+ }
1777
+
1778
+ /*
1779
+ * Get current transform.
1780
+ */
1781
+
1782
+ NAN_GETTER (Context2d::GetCurrentTransform) {
1783
+ Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This ());
1784
+ Local<Object> instance = get_current_transform (context);
1775
1785
1776
1786
info.GetReturnValue ().Set (instance);
1777
1787
}
@@ -2243,6 +2253,17 @@ NAN_METHOD(Context2d::Transform) {
2243
2253
cairo_transform (context->context (), &matrix);
2244
2254
}
2245
2255
2256
+ /*
2257
+ * Get the CTM
2258
+ */
2259
+
2260
+ NAN_METHOD (Context2d::GetTransform) {
2261
+ Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This ());
2262
+ Local<Object> instance = get_current_transform (context);
2263
+
2264
+ info.GetReturnValue ().Set (instance);
2265
+ }
2266
+
2246
2267
/*
2247
2268
* Reset the CTM, used internally by setTransform().
2248
2269
*/
0 commit comments