Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file ocolor_converter.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344openOcolor_types(* Upgrade *)letcolor8_of_color4(c:color4):color8=Standardcletcolor24_of_color4(c:color4):color24=letr,g,b=Ocolor_color_space.rgb_of_color4cin{r24=r;g24=g;b24=b}letcolor24_of_color8(c:color8):color24=matchcwith|Standardc->color24_of_color4c|Cube6{r6;g6;b6}->ifr6<0||r6>5thenraise(Invalid_argument"Red parameter of a color8 should be in [0; 5].");ifg6<0||g6>5thenraise(Invalid_argument"Green parameter of a color8 should be in [0; 5].");ifb6<0||b6>5thenraise(Invalid_argument"Blue parameter of a color8 should be in [0; 5].");{r24=51*r6;g24=51*g6;b24=51*b6}|Grayscalen->ifn<0||n>23thenraise(Invalid_argument"Grayscale parameter of a color8 should be in [0; 23].");letl=n*255/23in{r24=l;g24=l;b24=l}(* Downgrade *)letcolor4_of_color24({r24;g24;b24}:color24):color4=ifr24<0||r24>255thenraise(Invalid_argument"Red parameter of a color8 should be in [0; 255].");ifg24<0||g24>255thenraise(Invalid_argument"Green parameter of a color8 should be in [0; 255].");ifb24<0||b24>255thenraise(Invalid_argument"Blue parameter of a color8 should be in [0; 255].");letc=Ocolor_color_space.closest_color4(r24,g24,b24)incletcolor4_of_color8(c:color8):color4=matchcwith|Standardc->c|Cube6_|Grayscale_->c|>color24_of_color8|>color4_of_color24letcolor8_of_color24({r24;g24;b24}:color24):color8=ifr24<0||r24>255thenraise(Invalid_argument"Red parameter of a color8 should be in [0; 255].");ifg24<0||g24>255thenraise(Invalid_argument"Green parameter of a color8 should be in [0; 255].");ifb24<0||b24>255thenraise(Invalid_argument"Blue parameter of a color8 should be in [0; 255].");letc=Ocolor_color_space.closest_color8(r24,g24,b24)inc