Masking Pictures

new topic     » topic index » view thread      » older message » newer message

Hi all

i have altered display_image a bit so you can have masks (colours that
are 'clear'). (copy & paste it out of the bottom of this message...)

its really simple: masked_image({x, y}, image_sequence, mask_color)

eg: masked_image({100, 200}, face, 14)

would display the image just like display_image, but all pixels of the
colour 14 would not be drawn, so seeming 'clear' :)

hope its a help to someone...

PS: it will probibally be slower than display_image, because it draws
the pictures pixel-by-pixel, not line-by-line. :(

Mike Fowler - mike.fowler at nelsun.gen.nz
  o__ ---
 _,>/'_ ---
(_) \(_) ---
Tip for the month: Buy a paper schredder for cutting cabbages.

-- [CODE START HERE] --
global procedure masked_image(sequence xy, sequence pixels, atom mask)
-- display a 2-d sequence of pixels at location xy,
-- with "mask" being clear
-- N.B. coordinates are {x, y} with {0,0} at top left of screen
-- and x values increasing towards the right,
-- and y values increasing towards the bottom of the screen
-- eg: image_masked({100, 100}, face, 15) draws the picture 'face' with
-- all pixels the color '15' left as clear.

    for i = 1 to length(pixels) do
 for i2 = 1 to length(pixels[i]) do
     if pixels[i][i2] = mask_color then
      xy[1] = xy[1] + 1
     else
  machine_proc(4, {pixels[i][i2], xy})
      xy[1] = xy[1] + 1
     end if
 end for

    xy[1] = xy[1] - length(pixels[i])
    xy[2] = xy[2] + 1
    end for
end procedure
-- [CODE ENDS HERE] --

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu