{ Analytica Model Color_library, encoding="UTF-8" } SoftwareVersion 6.2.0 {!-60000|Attribute AcpStyles} LinkLibrary Color_library Title: Color library Description: Some functions for manipulating the components of color integers.~ Currently just RGBA components. Would like to add HSV and HSL in the future. Author: Lonnie Chrisman~ Lumina Decision Systems Date: Thu, Dec 29, 2022 8:57 AM DiagState: 2,0,0,944,403,17,10 FontStyle: Arial,15 FileInfo: 0,LinkLibrary Color_library,2,2,0,0,W:\TestModels\Color library.ana Function RGBA( R,G,B : nonNegative ; A : nonNegative = 1 ) Title: RGBA Description: Converts amount of Red, Green, Blue and optionally Alpha, each on a scale of 0.0 to 1.0, to a color integer. A is the alpha channel, or degree of opacity, where 0=transparent, 1=opaque. Definition: Local shift := Array(Color_component,[16,8,0,24]);~ Local span := if Color_component='A' then 255 else 254;~ Local off := Color_component='A';~ Local component := round(Array(Color_component,[R,G,B,A]) * span + off);~ component := if component>0xff then 0xff else component;~ BitOr(BitShift(component,shift,left:true),Color_component) NodeLocation: 128,72,1 NodeSize: 64,24 WindState: 2,983,96,720,506 Constant Color_component Title: Color component Definition: ['R','G','B','A'] NodeLocation: 128,152,1 NodeSize: 64,24 Variable Example_usage_of_RGB Title: Example usage of RGB Definition: RGBA(0.5,0.5,0.5,0.5) NodeLocation: 128,264,1 NodeSize: 64,24 ValueState: 2,1288,551,416,303,,MIDM NumberFormat: 2,H,4,2,0,0,4,0,$,0,"ABBREV",0,,,0,0,15, Function ColorNameToColorInt( c : color ) Title: Color name to Color int Description: Returns the color integer given either a color name or a color int. Definition: c NodeLocation: 288,72,1 NodeSize: 64,24 Function RGBA_components( c : color atom ) Title: RGBA components Description: Returns the R, G, B and A components of a color, each on a scale of 0.0 to 1.0.~ A is the alpha channel, or degree of opacity, with 0=transparent, 1=opaque.~ Definition: Local shift := Array(Color_component,[16,8,0,24]);~ Local h := BitAnd([0xff,BitShift(c,shift)]);~ if Color_component='A' then ~ if h=0 then 1.0 else (h-1)/254~ else h/255~ NodeLocation: 448,72,1 NodeSize: 64,24 WindState: 2,931,380,720,350 Variable Example_usage_of_RG1 Title: Example usage of RGBA components Definition: RGBA_components(0x01808080) NodeLocation: 304,264,1 NodeSize: 64,32 ValueState: 2,57,695,416,154,,MIDM NumberFormat: 2,D,4,2,0,0,4,0,$,0,"ABBREV",0,,,0,0,15, Close Color_library