Vertical Black&White Gradient

From Director Online Wiki
Jump to: navigation, search

Description

Create a vertical Black&White gradient image

Code

-- VerticalGradientBW gradientSizeX, gradientSizeY
--
-- Example:
-- myImage = VerticalGradientBW(600,400)
 
on VerticalGradientBW gradientSizeX, gradientSizeY
  if ilk(gradientSizeX, #integer) AND ilk(gradientSizeY, #integer) then
    myGradientColumn = image(1, 256, 32,0)
    repeat with y = 0  to 255
      myGradientColumn.setPixel(0, y, rgb(y,y,y))
    end repeat
    myGradientImage = image(gradientSizeX, gradientSizeY, 32,0)
    myGradientImage.copyPixels(myGradientColumn,myGradientImage.rect,myGradientColumn.rect)
    return myGradientImage
  else
    alert "Integer expected!"
  end if
end