We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The changes made here:
5d34265
...don't seem to take into account the correct scale (because the NSImage size method returns size information that is screen resolution dependent).
NSImage
@randomeizer has come up with the suggested fix, which I'll do a pull request for shortly:
/// hs.image:colorAt(point) -> table /// Method /// Reads the color of the pixel at the specified location. /// /// Parameters: /// * `point` - a `hs.geometry.point` /// /// Returns: /// * A `hs.drawing.color` object static int colorAt(lua_State* L) { LuaSkin *skin = [LuaSkin sharedWithState:L] ; [skin checkArgs:LS_TUSERDATA, USERDATA_TAG, LS_TTABLE, LS_TBREAK]; NSImage *theImage = [skin luaObjectAtIndex:1 toClass:"NSImage"] ; NSPoint point = [skin tableToPointAtIndex:2] ; NSColor *pixelColor = nil; @autoreleasepool { CGImageRef CGImage = [theImage CGImageForProposedRect:nil context:nil hints:nil]; NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:CGImage]; NSSize imageSize = [theImage size]; NSSize bitmapSize = [rep size]; CGFloat xScale = bitmapSize.width / imageSize.width; CGFloat yScale = bitmapSize.height / imageSize.height; pixelColor = [rep colorAtX:(point.x * xScale) y:(point.y * yScale)]; } [skin pushNSObject:pixelColor]; return 1; }
The text was updated successfully, but these errors were encountered:
hs.image:colorAt() now takes into account scale
bd9870a
- Closes Hammerspoon#3184
4c6f32c
- Closes #3184
Successfully merging a pull request may close this issue.
The changes made here:
5d34265
...don't seem to take into account the correct scale (because the
NSImage
size method returns size information that is screen resolution dependent).@randomeizer has come up with the suggested fix, which I'll do a pull request for shortly:
The text was updated successfully, but these errors were encountered: