- Jun 6, 2020
- 11,559
- 4,422
This is just a bit of fun, inspired by a recent question about the shape of buttons.
Given an image, how hard is it to make a specific area in the picture sensitive to clicks.
It turns out "easy", if the areas have fairly uniform color(s).
The project (about 100 lines of code) uses these techniques:
During the definition phase...
1. Create 2 layers (panels) one for the image and one for the mouse click sensor
2. In response to a click, sample a small rectangle of color using BitmapCreator
3. Use a radial search to detect boundaries (search centered on event point, around the clock in 10 degree steps)
4. Using a path object, connect boundaries and color the inside transparent (see next step)
5. Put the area ID# in the shape's transparency color (1, 2, 3, 4, etc.)
During the testing phase...
1. grab the transparency color of a clicked point to get the shape ID#
2. show a message about the selected shape
I have attached the project as .zip, but you could also just copy the...
Given an image, how hard is it to make a specific area in the picture sensitive to clicks.
It turns out "easy", if the areas have fairly uniform color(s).
The project (about 100 lines of code) uses these techniques:
During the definition phase...
1. Create 2 layers (panels) one for the image and one for the mouse click sensor
2. In response to a click, sample a small rectangle of color using BitmapCreator
3. Use a radial search to detect boundaries (search centered on event point, around the clock in 10 degree steps)
4. Using a path object, connect boundaries and color the inside transparent (see next step)
5. Put the area ID# in the shape's transparency color (1, 2, 3, 4, etc.)
During the testing phase...
1. grab the transparency color of a clicked point to get the shape ID#
2. show a message about the selected shape
I have attached the project as .zip, but you could also just copy the...
برای دیدن لینک ها باید ثبت نام کنید
برای دیدن لینک ها باید ثبت نام کنید