Time for action – testing a getPixel function
Before getting to useful examples, let's make a getPixel
function, and a quick test case.
Make a new Mainstack. Save it as
ImageDataTests
.Note
We'll use the same stack to illustrate several things, and at the end we may dare to try it on a mobile device!
Make the stack of the size of your largest test device. Or just try 1024x768 if you'll use the iPad Simulator.
From the File menu, choose Import as Control/Image, and select any small image file you have, to place it in the upper left-hand side corner of the card window. The example shown below uses a LiveCode logo image.
Place a new Graphic object next to the image. It's going to be showing a single color, so just make it big enough to easily see the color. Name it
swatch
.Graphics have a default value set to show an empty box, so type this in the message box to make it be filled in:
set the filled of graphic 1 to true
Edit the script of the image, and type in these lines:
on mouseMove pMx,pMy --put...