feat: automatically round numbers that are converted to points (#14604)
Fixes #14490
This commit is contained in:
parent
7d7401987a
commit
73a1a8b3f0
2 changed files with 7 additions and 2 deletions
|
@ -28,10 +28,11 @@ bool Converter<gfx::Point>::FromV8(v8::Isolate* isolate,
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
return false;
|
return false;
|
||||||
int x, y;
|
double x, y;
|
||||||
if (!dict.Get("x", &x) || !dict.Get("y", &y))
|
if (!dict.Get("x", &x) || !dict.Get("y", &y))
|
||||||
return false;
|
return false;
|
||||||
*out = gfx::Point(x, y);
|
*out = gfx::Point(static_cast<int>(std::round(x)),
|
||||||
|
static_cast<int>(std::round(y)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
|
|
||||||
* `x` Number
|
* `x` Number
|
||||||
* `y` Number
|
* `y` Number
|
||||||
|
|
||||||
|
**Note:** Both `x` and `y` must be whole integers, when providing a point object
|
||||||
|
as input to an Electron API we will automatically round your `x` and `y` values
|
||||||
|
to the nearest whole integer.
|
||||||
|
|
Loading…
Add table
Reference in a new issue