home *** CD-ROM | disk | FTP | other *** search
- /*
- * $VER: Find 1.00.00 (24.9.92)
- *
- * Arexx program for the ImageFX image processing system.
- * Written by Thomas Krehbiel
- *
- * This program will find and activate the nearest palette color for
- * the pixel that the user clicks the mouse over. Demonstrates the use
- * of the WAITFOR command.
- *
- */
-
- OPTIONS RESULTS
-
- /* Save current color, because we're going to trash it */
- GetPalette '-1'
- PARSE VAR result oldr oldg oldb
-
- LockInput ; LockGui
-
- /* Pick color, wait for user to pick something */
- Pick
- WaitFor SELECTUP
-
- /* Find out what we got, save it */
- GetPalette '-1'
- PARSE VAR result dstr dstg dstb
-
- /* Restore original palette color */
- SetPalette '-1' oldr oldg oldb
-
- UnlockGui
-
- /* Now look through the palette for the closest match. This is
- a fairly elementary matching routine, since we don't happen
- to have square roots available in standard REXX. */
-
- bestdist = 999999
- bestcol = 0
-
- BeginBar 'Finding' 1
-
- DO i = 0 TO 31
-
- GetPalette i
- PARSE VAR result r g b
-
- dist = ABS(r - dstr) + ABS(g - dstg) + ABS(b - dstb)
- IF dist < bestdist THEN DO
- bestdist = dist
- bestcol = i
- END
-
- END
-
- EndBar
-
- ActiveColor bestcol
-
- UnlockInput
-
- EXIT
-