Image fill question

FlexibleLearning.com admin at FlexibleLearning.com
Wed Nov 5 10:40:58 EST 2014


Thierry, Scott...

Thank you both. Clear and concise. Since I need the black border, I will use
Thiery's custom routine (added bonus points for arbitrary border color!),
but for a generic solution for any arbitrary sized image where fill-only is
required, Scott's is faster as it has no internal custom switch
requirements.

Both solutions show us how imageData can be constructed.

Gotta love this list!

Best regards,

Hugh Senior
FLCo

For the record:

The Challenge:
"Fill a 10x10 image with an arbitrary solid color and a 1px black border."

[1] Thierry Douez solution...
-- I assume your original image is already 10x10
-- next 2 lines:  0, R, G and Blue
 put numtochar(0) & numtochar(178) & numtochar(150) &  numtochar(255) into
myColor
   put numtochar(0) & numtochar(0) & numtochar(0) &  numtochar(0) into
myBorderColor
   repeat with i=0 to  99
      if i < 10 then get myBorderColor
      else if i > 90 then get myBorderColor
      else if i mod 10 is 0 then get myBorderColor
      else if i mod 10 is 9 then get myBorderColor
      else get myColor
      put IT after T
   end repeat
   set the imageData of image 1 to T


[2] Scott Rossi solution...

on mouseUp
   put long id of img 1 into pImage --- THE TARGET IMAGE
   put "255,0,0" into pColor --- THE RGB COLOR
   fillImageWithColor pImage, pColor
end mouseUp

command fillImageWithColor pImage, pColor
   put binaryEncode("CCCC",0,item 1 of pColor,item 2 of pColor,item 3 of
pColor) into theData
   repeat (width of pImage * height of pImage)
      put theData after theColorData
   end repeat
   set imageData of pImage to theColorData
end fillImageWithColor





More information about the use-livecode mailing list