Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automatically round numbers that are converted to points #14604

Merged
merged 1 commit into from Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions atom/common/native_mate_converters/gfx_converter.cc
Expand Up @@ -28,10 +28,11 @@ bool Converter<gfx::Point>::FromV8(v8::Isolate* isolate,
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
int x, y;
double x, y;
if (!dict.Get("x", &x) || !dict.Get("y", &y))
return false;
*out = gfx::Point(x, y);
*out = gfx::Point(static_cast<int>(std::round(x)),
static_cast<int>(std::round(y)));
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions docs/api/structures/point.md
Expand Up @@ -2,3 +2,7 @@

* `x` 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.