I just shared this code in the V2 Development Blog thread in response to Santman asking if such a feature existed, but figure it could be useful to anyone who isn't monitoring that thread as the topic has come up in the past.
There isn't a native command for this capability (Lee originally said it was omitted due to mobile performance reasons when AppGameKit was young) but with memblocks it becomes easy to integrate such functionality yourself. Here is a function that does just that. It is fast enough to be called each frame and run full speed on the devices I tested, but could slow down depending on your requirements (i.e., if you need to call it for many different coords each frame). Essentially it grabs an image at the specified coordinates, converts it to a memblock and then extracts the color value and returns it to you for further processing.
Instructions: Copy the functions below to your app.
Usage: colorVal = Point(x, y, returnType)
x, y: The coordinate that you wish to extract the color value from.
returnType: 0 = raw integer value, 1/2/3/4 = Red/Green/Blue/Alpha component value
If using '0' as the return type to get the full RGBA value, you can then extract the RGBA components manually using the GetColorR[G/B/A]() functions provided. AppGameKit V2 includes GetColorRed[Green/Blue] natively as well, but these functions I've included ensure compatibility with V1 and support easy alpha extraction.
Attached also is a full working example.
`FUNCTION: Get Color Data of Point
Function Point(x as integer, y as integer, returnType as integer)
// ReturnType 0: Return raw INTEGER color value
// ReturnType 1: Return RED color component value
// ReturnType 2: Return GREEN color component value
// ReturnType 3: Return BLUE color component value
// ReturnType 4: Return ALPHA color component value
// Prepare scene for capturing image
Update(0) : Render()
// Get temporary image at specified coordinates
pointImg = GetImage(x, y, 1, 1)
// Convert captured image to memblock
pointMb = CreateMemblockFromImage(pointImg)
// Store raw integer color value
pointColor = GetMemblockInt(pointMb, 12)
// Clean Up
DeleteImage(pointImg)
DeleteMemblock(pointMb)
// Swap Buffer
Swap()
// Return appropriate data
Select returnType
// Red Value
Case 1
pointColor = GetColorR(pointColor)
EndCase
// Green Value
Case 2
pointColor = GetColorG(pointColor)
EndCase
// Blue Value
Case 3
pointColor = GetColorB(pointColor)
EndCase
// Alpha Value
Case 4
pointColor = GetColorA(pointColor)
EndCase
EndSelect
EndFunction pointColor
`FUNCTION: Get Individual Color Data from Raw Integer Value
`Red
Function GetColorR(colorVal As Integer)
result = colorVal && 0xff
Endfunction result
`Green
Function GetColorG(colorVal As Integer)
result = (colorVal >> 8) && 0xff
Endfunction result
`Blue
Function GetColorB(colorVal As Integer)
result = (colorVal >> 16) && 0xff
Endfunction result
`Alpha
Function GetColorA(colorVal As Integer)
result = (colorVal >> 24) && 0xff
Endfunction result