Bitmap/Fortran: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 33: Line 33:
end subroutine init_img
end subroutine init_img


subroutine set_color(color, r, g, b)
subroutine set_color(color, red, green, blue)
type(rgb), intent(out) :: color
type(rgb), intent(out) :: color
integer, intent(in) :: r, g, b
integer, intent(in) :: red, green, blue
where ( r > 255 )
where ( red > 255 )
color%red = 255
color%red = 255
elsewhere ( r < 0 )
elsewhere ( red < 0 )
color%red = 0
color%red = 0
else
else
color%red = r
color%red = red
end where
end where
where ( g > 255 )
where ( green > 255 )
color%green = 255
color%green = 255
elsewhere ( g < 0 )
elsewhere ( green < 0 )
color%green = 0
color%green = 0
else
else
color%green = g
color%green = green
end where
end where
where ( b > 255 )
where ( blue > 255 )
color%blue = 255
color%blue = 255
elsewhere ( b < 0 )
elsewhere ( blue < 0 )
color%blue = 0
color%blue = 0
else
else
color%blue = b
color%blue = blue
end where
end where
end subroutine set_color
end subroutine set_color