// QFRestore ¯559,88® #include "common.ch" #include "Gra.ch" #include "Xbp.ch" #include "Appevent.ch" #include "Font.ch" #include "dll.ch" //** the starting angle #Define CRLF Chr(13) + Chr(10) #Define aBase {255,0,0} Procedure AppSys() Return Procedure Main() Local oDlg, oDa, mp1, mp2, nEvent, oXbp, oFocus Local oPicker, oWheel, aGroups, oPart, oHelp aGroups := {} oHelp := ToolTips():New():Start() //** create the window oDlg := XbpDialog():New(AppDesktop(),,{10,10},{336,400}) oDlg:icon := 1 oDlg:tasklist := .T. oDlg:title := "Color Finder" oDlg:minbutton := .F. oDlg:maxbutton := .F. oDlg:Create() //** get the drawing area oDa := oDlg:DrawingArea oDa:SetColorBG(GraMakeRGBColor({228,228,228})) oPicker := ColorPicker():New() oPicker:nColor := GraMakeRGBColor(aBase) oPicker:bColorPick := {|nColor| oWheel:NewBase(nColor) } oPicker:Create(oDa,,{8,296}) oXbp := XbpStatic():new( oDa, , {8,248}, {308,44} ) oXbp:caption := Space(4) + "Monochrome Colors" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{26,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{34,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{58,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{82,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{106,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{130,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{154,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{178,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{202,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{226,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{250,8},{24,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[1,2],oPart) oPart := XbpStatic():New(oXbp,,{274,8},{26,20}) oPart:caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[1,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {32,200}, {84,44} ) oXbp:caption := Space(4) + "Comp" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{34,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[2,2],oPart) oPart := XbpStatic():New(oXbp,,{42,8},{34,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[2,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {120,200}, {84,44} ) oXbp:caption := Space(4) + "Split" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[3,2],oPart) oPart := XbpStatic():New(oXbp,,{31,8},{22,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[3,2],oPart) oPart := XbpStatic():New(oXbp,,{53,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[3,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {208,200}, {84,44} ) oXbp:caption := Space(4) + "Triad" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[4,2],oPart) oPart := XbpStatic():New(oXbp,,{31,8},{22,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[4,2],oPart) oPart := XbpStatic():New(oXbp,,{53,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[4,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {32,150}, {84,44} ) oXbp:caption := Space(4) + "Tetrad" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{17,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[5,2],oPart) oPart := XbpStatic():New(oXbp,,{25,8},{17,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_YELLOW) oPart:Create() aAdd(aGroups[5,2],oPart) oPart := XbpStatic():New(oXbp,,{42,8},{17,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_BLACK) oPart:Create() aAdd(aGroups[5,2],oPart) oPart := XbpStatic():New(oXbp,,{59,8},{17,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_GREEN) oPart:Create() aAdd(aGroups[5,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {120,150}, {84,44} ) oXbp:caption := Space(4) + "Analogus" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[6,2],oPart) oPart := XbpStatic():New(oXbp,,{31,8},{22,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[6,2],oPart) oPart := XbpStatic():New(oXbp,,{53,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[6,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp oXbp := XbpStatic():new( oDa, , {208,150}, {84,44} ) oXbp:caption := Space(4) + "Mono" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():New(oXbp,,{8,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_RED) oPart:Create() aAdd(aGroups[7,2],oPart) oPart := XbpStatic():New(oXbp,,{31,8},{22,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_WHITE) oPart:Create() aAdd(aGroups[7,2],oPart) oPart := XbpStatic():New(oXbp,,{53,8},{23,20}) oPart:Caption := "" oPart:SetColorBG(GRA_CLR_BLUE) oPart:Create() aAdd(aGroups[7,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {12,28}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetParent():Cargo := oXbp //** My custom colors stuff oXbp := XbpStatic():new( oDa, , {216,12}, {24,128} ) oXbp:caption := "" oXbp:clipSiblings := .T. oXbp:type := XBPSTATIC_TYPE_GROUPBOX oXbp:create() aAdd(aGroups,{oXbp,{}}) oPart := XbpStatic():new( oXbp, , {4,88}, {16,20}, { { XBP_PP_BGCLR, GRA_CLR_BLACK } } ) oPart:create() aAdd(aGroups[8,2],oPart) oPart := XbpStatic():new( oXbp, , {4,68}, {16,20}, { { XBP_PP_BGCLR, GRA_CLR_PINK } } ) oPart:create() aAdd(aGroups[8,2],oPart) oPart := XbpStatic():new( oXbp, , {4,48}, {16,20}, { { XBP_PP_BGCLR, GRA_CLR_BLACK } } ) oPart:create() aAdd(aGroups[8,2],oPart) oPart := XbpStatic():new( oXbp, , {4,28}, {16,20}, { { XBP_PP_BGCLR, GRA_CLR_PINK } } ) oPart:create() aAdd(aGroups[8,2],oPart) oPart := XbpStatic():new( oXbp, , {4, 8}, {16,20}, { { XBP_PP_BGCLR, GRA_CLR_BLACK } } ) oPart:create() aAdd(aGroups[8,2],oPart) oXbp := XbpCheckbox():new( oXbp, , {8,110}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oXbp:SetData(.T.) oXbp:SetParent():Cargo := oXbp oXbp := XbpSLE():New(oDa,,{252,64},{68,24}) oXbp:SetFontCompoundName('12.Courier New') oXbp:keyboard := {|nKey,un1,o| If(nKey==xbeK_RETURN,UpdateColorFromHex(o,oWheel),nil)} oXbp:bufferLength := 6 oXbp:Create() //** now do the buttons oXbp := XbpPushButton():new( oDa, , {252,36}, {68,24}, { { XBP_PP_BGCLR, XBPSYSCLR_BUTTONMIDDLE }, { XBP_PP_FGCLR, -58 } } ) oXbp:caption := "Export" oXbp:tabStop := .T. oXbp:create() oXbp:activate := {|| ExportColors(aGroups) } oXbp := XbpPushButton():new( oDa, , {252,8}, {68,24}, { { XBP_PP_BGCLR, XBPSYSCLR_BUTTONMIDDLE }, { XBP_PP_FGCLR, -58 } } ) oXbp:caption := "Close" oXbp:tabStop := .T. oXbp:create() oXbp:activate := {|| PostAppEvent(xbeP_Close,,,oDlg) } //** now draw the wheel part oWheel := ColorWheel():New() oWheel:aBaseClr := aClone(aBase) oWheel:Create(oDa,,{65,10},{130,130}) oWheel:bNewBase := {|x| oPicker:ChooseTheColor(nil,x), LoadGroupColors(aGroups,oWheel) } oWheel:aBig := {1} aAdd(aGroups,{oWheel,{}}) oXbp := XbpCheckbox():new( oDa, , {55,120}, {10,18} ) oXbp:tabStop := .T. oXbp:create() oWheel:Cargo := oXbp LoadGroupColors(aGroups,oWheel) For mp1 := 1 to Len(aGroups) For mp2 := 1 to Len(aGroups[mp1,2]) aGroups[mp1,2,mp2]:lbClick := {|u1,u2,o| oWheel:NewBase(o:SetColorBG()) } Next mp2 Next mp1 //** show our form oDlg:Show() oFocus := SetAppFocus(oDlg) SetAppWindow(oDlg) //** event loop nEvent := 0 Do While nEvent <> xbeP_Close nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) EndDo //** put the focus back to previous SetAppFocus(oFocus) //** hide our form and clear it from memory oDlg:Hide() oDlg:Destroy() Return Procedure LoadGroupColors(aGroups,oWheel) Local i, x, aRGB, nXB, aHSL,aWork, nColor aRGB := aClone(oWheel:aBaseClr) aHSL := RGBtoHSL(aRGB) ***************************** ** monochrome 10% swatches ** ***************************** x := {0.00,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,0.95,1.00} aWork := aClone(aHSL) For i := 1 to Len(aGroups[1,2]) aWork[3] := x[i] nColor := HSLtoRGB(aWork) nColor := GraMakeRGBColor(nColor) aGroups[1,2,i]:SetColorBG(nColor) Next i *********************** ** Color Complements ** *********************** aGroups[2,2,1]:SetColorBG(oWheel:aColors[1]) aGroups[2,2,2]:SetColorBG(oWheel:aColors[7]) ***************************** ** Split Color Complements ** ***************************** aGroups[3,2,1]:SetColorBG(oWheel:aColors[1]) aGroups[3,2,2]:SetColorBG(oWheel:aColors[6]) aGroups[3,2,3]:SetColorBG(oWheel:aColors[8]) ****************** ** Triad Colors ** ****************** aGroups[4,2,1]:SetColorBG(oWheel:aColors[1]) aGroups[4,2,2]:SetColorBG(oWheel:aColors[5]) aGroups[4,2,3]:SetColorBG(oWheel:aColors[9]) ************* ** Tetrads ** ************* aGroups[5,2,1]:SetColorBG(oWheel:aColors[1]) aGroups[5,2,2]:SetColorBG(oWheel:aColors[4]) aGroups[5,2,3]:SetColorBG(oWheel:aColors[7]) aGroups[5,2,4]:SetColorBG(oWheel:aColors[10]) ************** ** Analogus ** ************** aGroups[6,2,1]:SetColorBG(oWheel:aColors[2]) aGroups[6,2,2]:SetColorBG(oWheel:aColors[1]) aGroups[6,2,3]:SetColorBG(oWheel:aColors[12]) **************** ** Monochrome ** **************** nColor := oWheel:aColors[1] nColor := RGBtoHSL(GraGetRGBIntensity(nColor)) nColor[3] -= 0.15 nColor := HSLtoRGB(nColor) nColor := GraMakeRGBColor(nColor) aGroups[7,2,1]:SetColorBG(nColor) nColor := oWheel:aColors[1] nColor := RGBtoHSL(GraGetRGBIntensity(nColor)) nColor := HSLtoRGB(nColor) nColor := GraMakeRGBColor(nColor) aGroups[7,2,2]:SetColorBG(nColor) nColor := oWheel:aColors[1] nColor := RGBtoHSL(GraGetRGBIntensity(nColor)) nColor[3] += 0.15 nColor := HSLtoRGB(nColor) nColor := GraMakeRGBColor(nColor) aGroups[7,2,3]:SetColorBG(nColor) x := {0.40,0.55,0.65,0.80,0.95} For i := 1 to Len(x) nColor := oWheel:aColors[1] nColor := RGBtoHSL(GraGetRGBIntensity(nColor)) nColor[3] := x[i] nColor := HSLtoRGB(nColor) nColor := GraMakeRGBColor(nColor) aGroups[8,2,i]:SetColorBG(nColor) Next i LoadToolTips(aGroups) Return Procedure LoadToolTips(aGroups) Local i, j, cTxt, nColor, cHex, aRGB, aHSL For i := 1 to Len(aGroups) For j := 1 to Len(aGroups[i,2]) //** get differenet color descriptions nColor := aGroups[i,2,j]:SetColorBG() aRGB := GraGetRGBIntensity(nColor) cHex := "#" + Base2Base(StrZero(aRGB[1]),10,16,2) + Base2Base(StrZero(aRGB[2],2),10,16) + Base2Base(StrZero(aRGB[3],2),10,16) aHSL := RGBtoHSL(aRGB) cTxt := "Xb : " + AllTrim(Str(nColor)) + CRLF cTxt += "Hex: " + cHex + CRLF cTxt += "RGB: " + Var2Char(aRGB) + CRLF cTxt += "HSL: " + Var2Char(aHSL) aGroups[i,2,j]:helplink := cTxt Next j Next i Return Procedure LoadMono(aColor,aMono) Local aHSL, aL, i, nColor aHSL := RGBtoHSL(aColor) aL := {1.00,0.00,0.56,0.67,0.73,0.89,0.96} For i := 1 to 7 aHSL[3] := aL[i] nColor := GraMakeRGBColor(HSLtoRGB(aHSL)) aMono[i]:SetColorBG(nColor) Next i Return Procedure LoadFade(aColor,aFade) Local i, aHSL, lDone lDone := .F. If ValType(aColor) == 'N' aColor := GraGetRGBIntensity(aColor) EndIf aFade[29]:SetColorBG(GraMakeRGBColor(aColor)) aHSL := RGBtoHSL(aColor) For i := 28 to 1 Step -1 If ! lDone aHSL[3] -= 0.10//0.02 aFade[i]:Show() aFade[i]:SetColorBG(GraMakeRGBColor(HSLtoRGB(aHSL))) If Round(aHSL[3],2) < 0.00 lDone := .T. EndIf Else aFade[i]:Hide() EndIf Next i aHSL := RGBtoHSL(aColor) lDone := .F. For i := 30 to 57 If !lDone aHSL[3] += 0.10//0.02 aFade[i]:Show() aFade[i]:SetColorBG(GraMakeRGBColor(HSLtoRGB(aHSL))) If Round(aHSL[3],2) == 1.00 lDone := .T. EndIf Else aFade[i]:Hide() EndIf Next i Return /* Name : DrawFilledPartialArc ** ** Purpose : This function is used to help in the creation of a pie charge ** it is from the GraArc Examples in the XPP Help File, slightly ** modifies ** ** Parameters : oPS - the presentation space we will be drawing on ** aCenter - the center point we got ** nRadius - radius of the chart ** nStartAngle - angle of the arc ** nSweepAngle - the angle of the sweep ** nPattern - the fill pattern to use ** lOutline - outline?! ** ** Coder : Alaska-Software ** ** Change Log : Date Who What ** -------------------------------------------------------------------------------- ** 06/27/2005 RLHJ Initial Header ** */ Procedure DrawFilledPartialArc(oPS,aCenter,nRadius,nStartAngle,nSweepAngle,nPattern,lOutline,nBGColor) Local aAttr, aLineAttr,nSegment //** Default some of the stuff Default nPattern to GRA_SYM_SOLID Default lOutline to .T. Default nBGColor to GRA_CLR_YELLOW //** select fill pattern aAttr := Array( GRA_AA_COUNT ) aAttr [ GRA_AA_COLOR ] := nBGColor aAttr [ GRA_AA_SYMBOL ] := nPattern aLineAttr := Array( GRA_AL_COUNT ) aLineAttr [ GRA_AL_WIDTH ] := 2 aLineAttr := GraSetAttrLine(oPS,aLineAttr) //** set the new attributes and save the old ones aAttr := GraSetAttrArea( oPS, aAttr ) //** open a new segment nSegment := GraSegOpen( oPS, GRA_SEG_MODIFIABLE ) //** begin a new path definition GraPathBegin(oPS) //** move the pointer to the center point we specified GraPos( oPS, aCenter ) //** now define the arc itself GraArc( oPS, aCenter, nRadius,, nStartAngle, nSweepAngle ) //** end the path now GraPathEnd( oPS, .T. ) //** Close out the segment GraSegClose(oPS) //** now create the path itself GraSegDraw( oPS, nSegment ) //** fill the path using the current setup GraPathFill(oPS) //** if we are supposed to outline this baby then //** we will do that now. If lOutline //** recreate path GraSegDraw( oPS, nSegment ) //** outline the path GraPathOutline(oPS) EndIf //** Now remove the segment from mem GraSegDestroy( oPS, nSegment) //** restore the settings that we had when we got here GraSetAttrArea( oPS, aAttr ) RETURN /* ** Converted From Code On EasyRGB.com */ Function HSLtoRGB(aHSL) Local nR,nG,nB,nH,nS,nL,x1,x2 Default aHSL to {0,0,0} nH := aHSL[1] / 360 nS := aHSL[2] nL := aHSL[3] If ( nS == 0 ) nR = nL * 255 nG = nL * 255 nB = nL * 255 Else If (nL < 0.5) x2 := nL * ( 1 + nS ) Else x2 := ( nL + nS ) - ( nS * nL ) EndIf x1 := 2 * nL - x2 nR := 255 * Hue2RGB(x1,x2,nH + (1/3)) nG := 255 * Hue2RGB(x1,x2,nH) nB := 255 * Hue2RGB(x1,x2,nH - (1/3)) EndIf nR := Int(nR) nG := Int(nG) nB := Int(nB) Return {nR,nG,nB} /* ** Converted From Code On EasyRGB.com */ Function Hue2RGB(v1,v2,vH) Local nRet If vH < 0 vH++ ElseIf vH > 1 vH-- EndIf nRet := 0 If ( ( 6 * vH ) < 1 ) nRet := ( v1 + ( v2 - v1 ) * 6 * vH ) ElseIf ( ( 2 * vH ) < 1 ) nRet := v2 ElseIf ( ( 3 * vH ) < 2 ) nRet := ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 ) Else nRet := v1 EndIf Return nRet /* ** Converted From Code On EasyRGB.com */ Function RGBtoHSL(aRGB) Local nR, nG, nB, nH, nS, nL, vMin, vMax, dMax, vR, vG, vB, dR, dG, dB Default aRGB to {0,0,0} nR := aRGB[1] nG := aRGB[2] nB := aRGB[3] vR := ( nR / 255 ) vG := ( nG / 255 ) vB := ( nB / 255 ) vMin := Min(vR,Min(vG,vB)) vMax := Max(vR,Max(vG,vB)) dMax := vMax - vMin nL := ( vMax + vMin ) / 2 If ( dMax == 0 ) nH := 0 nS := 0 Else If ( nL < 0.5 ) nS := dMax / ( vMax + vMin ) Else nS := dMax / (2 - vMax - vMin) EndIf dR := ( ( ( vMax - vR ) / 6 ) + ( dMax / 2 ) ) / dMax dG := ( ( ( vMax - vG ) / 6 ) + ( dMax / 2 ) ) / dMax dB := ( ( ( vMax - vB ) / 6 ) + ( dMax / 2 ) ) / dMax If ( vR == vMax ) nH := dB - dG ElseIf ( vG == vMax ) nH := ( 1 / 3 ) + dR - dB ElseIf ( vB == vMax ) nH := ( 2 / 3 ) + dG - dR EndIf If nH < 0 nH++ ElseIf nH > 1 nH-- EndIf nH := nH * 360 EndIf Return {nH,nS,nL} Function ClrWin2Xb(nColor) Local x x := AllTrim(Str(nColor)) x := Base2Base(x,10,16) x := Right(Replicate("0",6) + x,6) x := { , , , x} x[1] := Right(x[4],2) x[2] := SubStr(x[4],3,2) x[3] := Left (x[4],2) aSize(x,3) x[1] := Val(Base2Base(x[1],16,10)) x[2] := Val(Base2Base(x[2],16,10)) x[3] := Val(Base2Base(x[3],16,10)) Return GraMakeRGBColor(x) /* Name : Base2Base ** ** Purpose : This will convert any numeric base to another base specified ** ** Parameters : cNumber - string containing the number to convert ** nFromBase - base of the number we are converting ** nToBase - base to convert the number into (max base 36) ** nLen - lenght the number should be when returned (pad w/0) ** ** Coder : Richard L. Hankins, Jr. ** ** Change Log : Date Who What ** -------------------------------------------------------------------------------- ** 04/07/2005 RLHJ Initial Write ** */ Function Base2Base(cNumber,nFromBase, nToBase, nLen) Local cBaseExt, nMaxBase, cRetVal, x, y, nDec, nInLen //** default our variables cBaseExt := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" nMaxBase := Len(cBaseExt) nDec := 0 nInLen := Len(cNumber) cRetVal := '' //** first make sure that the numbers fit within the range If ! ( (nFromBase > nMaxBase) .or. (nToBase > nMaxBase) ) //** first we will convert the number to decimal For x := 1 to nInLen For y := 1 to nFromBase If cNumber[x] == cBaseExt[y] nDec += Int((y-1)*(nFromBase^(nInLen-x))+0.5) EndIf Next y Next x //** now convert it from base 10 to base x Do While nDec > 0 x := Int(((nDec/nToBase)-Int(nDec/nToBase))*nToBase+1.5) cRetVal := cBaseExt[x] + cRetVal nDec := Int(nDec/nToBase) EndDo If !Empty(nLen) cRetVal := PadL(cRetVal,nLen,"0") EndIf EndIf Return cRetVal Procedure UpdateColorFromHex(o,oWheel) Local x, aClr x := AllTrim(o:GetData()) x := Right("000000" + x,6) aClr := {Left(x,2),SubStr(x,3,2),Right(x,2)} aClr[1] := Val(Base2Base(aClr[1],16,10)) aClr[2] := Val(Base2Base(aClr[2],16,10)) aClr[3] := Val(Base2Base(aClr[3],16,10)) oWheel:NewBase(aClr) o:clear() Return Procedure ExportColors(aGroups) Local i, j, cColors, nColor, aColor cColors := "" For i := 1 to Len(aGroups) If aGroups[i,1]:Cargo:GetData() If Empty(cColors) nColor := aGroups[Len(aGroups),1]:aColors[1] aColor := GraGetRGBIntensity(nColor) nColor := "#" + Base2Base(AllTrim(Str(aColor[1])),10,16) + Base2Base(AllTrim(Str(aColor[2])),10,16) + Base2Base(AllTrim(Str(aColor[3])),10,16) cColors += "************" + CRLF cColors += "** " + nColor + "**" + CRLF cColors += "************" + CRLF EndIf If !Empty(aGroups[i,1]:caption) cColors += "//** " + AllTrim(aGroups[i,1]:caption) + CRLF ElseIf aGroups[i,1]:isDerivedFrom("ColorWheel") cColors += "//** Entire Color Wheel" + CRLF Else cColors += "//** My Custom Settings" + CRLF EndIf If aGroups[i,1]:isDerivedFrom("ColorWheel") For j := 1 to 12 nColor := aGroups[i,1]:aColors[j] aColor := GraGetRGBIntensity(nColor) cColors += "GraMakeRGBColor({" + StrZero(aColor[1],3) + "," + StrZero(aColor[2],3) + "," + StrZero(aColor[3],3) + "})" + CRLF Next j cColors += CRLF Else For j := 1 to Len(aGroups[i,2]) nColor := aGroups[i,2,j]:SetColorBG() aColor := GraGetRGBIntensity(nColor) cColors += "GraMakeRGBColor({" + StrZero(aColor[1],3) + "," + StrZero(aColor[2],3) + "," + StrZero(aColor[3],3) + "})" + CRLF Next j cColors += CRLF EndIf EndIf Next i If !Empty(cColors) If MemoWrit("C:\COLORS.TMP.TXT",cColors) RunShell("/C C:\COLORS.TMP.TXT") Else MsgBox("Could not create the colors file") EndIf EndIf Return