// Persistence of Vision Ray Tracer Scene Description File // File: ACI_to_RGB.pov // Vers: 3.5 // Desc: Converts colors from ACI (Autocad Color Index) to RGB // Date: 03.07.2003 // Auth: Przemyslaw Loesch #include "colors.inc" #declare write_table = false; // Write color table to text file? #declare cell_size = <1, (24/11)*0.75, 1>; #declare aci_brick_size = ; camera { orthographic location <0,0,-30> look_at <0,0,0> angle 45 translate } background {rgb<1,1,1>} // Converts a color in HSL color space to a color in RGB color space. // Based on CHSL2RGB macro from "Colors.inc". #macro My_CHSL2RGB(HSL) #local H = (HSL.red); #local S = (HSL.green); #local L = (HSL.blue); #local RGB = CH2RGB(H); #local mc = max(RGB.red, max(RGB.green, RGB.blue)); #local RGB = <(mc-S*(mc-RGB.red)),(mc-S*(mc-RGB.green)),(mc-S*(mc-RGB.blue))>; #local RGB = RGB * L; #end //end of macro // Converts ACI to RGB, uses CH2RGB from "Colors.inc" and My_CHSL2RGB macros. #macro ACI2RGB(ACI) #switch (ACI) #case (1) #local rgb_color=<1,0,0>; #break; //standard colors #case (2) #local rgb_color=<1,1,0>; #break; #case (3) #local rgb_color=<0,1,0>; #break; #case (4) #local rgb_color=<0,1,1>; #break; #case (5) #local rgb_color=<0,0,1>; #break; #case (6) #local rgb_color=<1,0,1>; #break; #case (7) #local rgb_color=<1,1,1>; #break; #case (8) #local rgb_color=<1,1,1>*0.5; #break; #case (9) #local rgb_color=<1,1,1>*0.75; #break; #range (10, 249) //full color palette #local rest=mod(ACI,10); #local H = 1.5 * (ACI-rest-10); //hue in range 0-360 #local S = (mod(ACI,2) ? 0.5 : 1.0); //saturation for odd ACI equals 50%, for even 100% #if (rest = 0 | rest = 1) #local L = 1.0; #end //lightness depands on the last decimal digit of ACI #if (rest = 2 | rest = 3) #local L = 0.8; #end #if (rest = 4 | rest = 5) #local L = 0.6; #end #if (rest = 6 | rest = 7) #local L = 0.5; #end #if (rest = 8 | rest = 9) #local L = 0.3; #end #local hsl_color = ; #local rgb_color = My_CHSL2RGB (hsl_color); #break; #case (250) #local rgb_color=<1,1,1>*0.20; #break; //gray shades #case (251) #local rgb_color=<1,1,1>*0.36; #break; #case (252) #local rgb_color=<1,1,1>*0.52; #break; #case (253) #local rgb_color=<1,1,1>*0.68; #break; #case (254) #local rgb_color=<1,1,1>*0.84; #break; #case (255) #local rgb_color=<1,1,1>*1.00; #break; #else #local rgb_color=<0,0,0>; //aci was out of range, return black #end #end //end of macro #macro Draw_aci_brick(row, column, aci_brick_color, ACI) #local position = ; polygon { 5, <0,0>, <0,aci_brick_size.y>, , , <0,0> pigment {rgb aci_brick_color} finish {ambient 1} translate position } text { ttf "crystal.ttf" str(ACI,0,0) 1,0 pigment {rgb<1,1,1>*(ACI=7 | ACI=255 ? 0 : 1)} finish {ambient 1} scale aci_brick_size scale <0.6,0.7,1> translate position-<0,0,1> } #end //end of macro #if (write_table) #fopen file "ACI_to_RGB.txt" write #end //main loop #local ACI=1; #while (ACI<256) #if (ACI<10 | ACI>249) //standard colors and gray shades #local row=10; #local column = (ACI<10 ? ACI-1 : ACI-232); #else //full color palette #local rest = mod(ACI,10); #local row = (mod(ACI,2)=0 ? (5+rest/2) : (9-rest)/2); #local column = int((ACI-rest-10)/10); #end #local rgb_color = ACI2RGB(ACI); Draw_aci_brick(row, column, rgb_color, ACI) #if (write_table) #local rgb_color=rgb_color*255; #write (file "ACI",str(ACI,3,0), "=RGB(", str(rgb_color.x,3,0),",",str(rgb_color.y,3,0),",",str(rgb_color.z,3,0), ")\n") #end #local ACI=ACI+1; #end #ifdef (file) #fclose file #end