/* @N This Genie will adjust the colors of a selection of objects. You may adjust the RGB, CMYK or HSV values of the selection. When prompted, input the values for each color you want to adjust. */ call pdm_AutoUpdate(0) msg = PDSetup.rexx(2,0) units =getclip(pds_units) if msg ~= 1 then exit_msg(msg) cr = '0a'x obj = pdm_SelFirstObj() if obj = 0 then exit_msg("Select a group of objects first") type = pdm_SelectFromList("Select Color Model..", 24, 3, 0, "HSV"cr"RGB"cr"YMCK") if type = '' then exit_msg() if type = "RGB" then do type = 1 adjfunc = "AdjustRGB" form = "Red %"cr"Green %"cr"Blue %" end else if type = "YMCK" then do type = 2 adjfunc = "AdjustYMCK" form = "Yellow %"cr"Magenta %"cr"Cyan %"cr"Black %" end else do type = 3 adjfunc = "AdjustHSV" form = "Hue %"cr"Saturation %"cr"Value %" end fills = pdm_SelectFromList("Select attributes to set..", 25, 2, 1, "Line Color"cr"Fill Color") if fills = '' then exit_msg() if pos("Line", fills) ~= 0 then adjline = 1 else adjline = 0 if pos("Fill", fills) ~= 0 then adjfill = 1 else adjfill = 0 input = pdm_GetForm("Enter offsets..", 8, form) if input = '' then exit_msg() if type = 1 then do parse var input red '0a'x green '0a'x blue if red = '' then red = 0 if green = '' then green = 0 if blue = '' then blue = 0 if ~(datatype(red, n) & datatype(green, n) & datatype(blue, n)) then exit_msg("Invalid Entry") end else if type = 2 then do parse var input yellow '0a'x magenta '0a'x cyan '0a'x black if yellow = '' then yellow = 0 if magenta = '' then magenta = 0 if cyan = '' then cyan = 0 if black = '' then black = 0 if ~(datatype(black, n) & datatype(magenta, n) & datatype(yellow, n) & datatype(cyan, n)) then exit_msg("Invalid Entry") end else do parse var input hue '0a'x saturation '0a'x value if hue = '' then hue = 0 if saturation = '' then saturation = 0 if value= '' then value = 0 if ~(datatype(hue, n) & datatype(saturation, n) & datatype(value, n)) then exit_msg("Invalid Entry") end do while obj ~= 0 if adjline then do colordata = pdm_GetColorData(pdm_GetLineColor(obj)) interpret "call pdm_SetLineColor(obj," adjfunc"(colordata))" end if adjfill then do pattern = pdm_GetFillPattern(obj) parse var pattern type '0a'x color1 '0a'x color2 '0a'x a '0a'x b '0a'x c '0a'x d if type = 0 then break interpret "color1 = "adjfunc"(pdm_GetColorData('"color1"'))" if type = 2 then interpret "color2 = "adjfunc"(pdm_GetColorData('"color2"'))" call pdm_SetFillPattern(obj, type, color1, color2, a, b, c, d) end obj = pdm_SelNextObj(obj) end exit_msg() exit_msg: procedure expose units do parse arg message if message ~= '' then call pdm_Inform(1,message,) call pdm_AutoUpdate(1) call pdm_SetUnits(units) exit end AdjustRGB: procedure expose red green blue do parse arg colordata ored = range(15, 0, red * 15 / 100) * 1 ogreen = range(15, 0, green * 15 / 100) * 1 oblue = range(15, 0, blue * 15 / 100) * 1 return('UNNAMED RGB 'ored' 'ogreen' 'oblue) end AdjustYMCK: procedure expose black magenta yellow cyan do parse arg colordata oblack = range(100, 0, black) * 1 omagenta= range(100, 0, magenta) * 1 oyellow = range(100, 0, yellow) * 1 ocyan = range(100, 0, cyan) * 1 return('UNNAMED YMCK 'oyellow' 'omagenta' 'ocyan' 'oblack) end AdjustHSV: procedure expose hue saturation value do parse arg colordata return("UNNAMED RGB " || HSVtoRGB(hue, saturation, value)) end HSVToRGB: procedure do parse arg h, s , v r = 0 g = 0 b = 0 if s = 0 & h = 0 then do r = v g = v b = v end else do if h = 360 then h = 0 h = h / 60 i = floor(h) * 1 f = h - i p = v * (1 - s) q = v * ( - (s * f)) t = v * (1 - (s * (1 - f))) if i = 0 then do r = v g = t b = p end else if i = 1 then do r = q g = v b = p end else if i = 2 then do r = p g = v b = t end else if i = 3 then do r = p g = q b = v end else if i = 4 then do r = t g = p b = v end else if i = 5 then do r = v g = p b = q end end r = r * 15 g = g * 15 b = b * 15 return(r" "g || " " || b) end