Bitmap/Fortran: Difference between revisions

Content added Content deleted
No edit summary
(fixed improper use of the "where" statement)
Line 36: Line 36:
type(rgb), intent(out) :: color
type(rgb), intent(out) :: color
integer, intent(in) :: red, green, blue
integer, intent(in) :: red, green, blue
where ( red > 255 )
if ( red > 255 ) then
color%red = 255
color%red = 255
elsewhere ( red < 0 )
elseif ( red < 0 ) then
color%red = 0
color%red = 0
else
else
color%red = red
color%red = red
end where
end if
where ( green > 255 )
if ( green > 255 ) then
color%green = 255
color%green = 255
elsewhere ( green < 0 )
elseif ( green < 0 ) then
color%green = 0
color%green = 0
else
else
color%green = green
color%green = green
end where
end if
where ( blue > 255 )
if ( blue > 255 ) then
color%blue = 255
color%blue = 255
elsewhere ( blue < 0 )
elseif ( blue < 0 ) then
color%blue = 0
color%blue = 0
else
else
color%blue = blue
color%blue = blue
end where
end if
end subroutine set_color
end subroutine set_color