(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.0' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 15910, 621]*) (*NotebookOutlinePosition[ 16638, 646]*) (* CellTagsIndexPosition[ 16594, 642]*) (*WindowFrame->Normal*) Notebook[{ Cell["Color conversion. ", "Subsection"], Cell["\<\ There are many models to convert RGB to HSB. I downloaded a dozen or so of \ them off the internet and coded them in until I found the one that \ mathematica uses. The algorithm used here is modified from the one found on \ http://www.xbeat.net/vbspeed/c_HSLToRGB.htm. HSLToRGB02 and RGBToHSL02. Author: Sean Ross 04 November 2003 \ \>", "Text"], Cell["\<\ Version 2. Fixes a bug which returned negative RGB values, 17May2004\ \>", "Text"], Cell[CellGroupData[{ Cell["\<\ BeginPackage[\"Sean`RGBHSBconversion`\"] RGBtoHSB::usage=\"RGBtoHSB[red,green,blue] or \ RGBtoHSB[RGBColor[red,green,blue]] returns Hue[hue,saturation, brilliance] \ representing the same shade and color as the original RGBcolor. By \ mathematica convention, red, green, blue, hue, saturation and brilliance are \ all numbers from 0 to 1. Written by Sean Ross, May 2004 November 2003\"; HSBtoRGB::usage=\"HSBtoRGB[hue,saturation,brilliance] or \ HSBtoRGB[Hue[hue,saturation,brilliance]] returns RGBColor[red,green, blue] \ representing the same shade and color as the original Hue. By mathematica \ convention, red, green, blue, hue, saturation and brilliance are all numbers \ from 0 to 1. Revision 2. Written by Sean Ross, May 2004\"; Begin[\"`Private`\"]\ \>", "Input", InitializationCell->True], Cell[BoxData[ \("Sean`RGBHSBconversion`"\)], "Output"], Cell[BoxData[ \("Sean`RGBHSBconversion`Private`"\)], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["RGB to HSB conversion", "Subsubsection"], Cell["\<\ Clear[RGBtoHSB]; RGBtoHSB[RGBColor[red_,green_,blue_]]:=RGBtoHSB[red,green,blue]; RGBtoHSB[{red_,green_,blue_}]:=RGBtoHSB[red,green,blue]; RGBtoHSB[red_,green_,blue_]:= Block[{r,g,b,h,s,l,maxRGB,minRGB}, {r,g,b}=N[Abs[{red,green,blue}]]; If[(maxRGB=Max[r,g,b])>1,{r,g,b}={r,g,b}/maxRGB]; maxRGB=Max[r,g,b]; minRGB=Min[r,g,b]; l=maxRGB; If[maxRGB==minRGB, Return[Hue[0,0,l]]]; s=(maxRGB-minRGB)/maxRGB; contrast=maxRGB-minRGB; Which[ \tr==maxRGB, \t\th=Mod[(g-b)/contrast,6], \tg==maxRGB, \t\th=2.0+(b-r)/contrast, \tb==maxRGB, \t\th=4.0+(r-g)/contrast ]; h=Abs[h/6]; Return[Hue[h,s,l]] ]; \ \>", "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell["HSB to RGB conversion", "Subsubsection"], Cell[CellGroupData[{ Cell["\<\ Clear[HSBtoRGB]; HSBtoRGB[Hue[hue_,saturation_,brilliance_]]:=HSBtoRGB[hue,saturation,\ brilliance]; HSBtoRGB[Hue[hue_]]:=HSBtoRGB[hue,1,1]; HSBtoRGB[{hue_saturation_,brilliance_}]:=HSBtoRGB[hue,saturation,brilliance]; HSBtoRGB[hue_,saturation_,brilliance_]:= Block[{r,g,b,h,s,l,t1,t2,t3,max,min,mid}, {h,s,l}=Abs[Map[(If[#\[Equal]1,#,Mod[#,1]])&,{hue,saturation,brilliance}]]; If[s==0,Return[RGBColor[l,l,l]]]; If[l==0,Return[RGBColor[0,0,0]]]; max=l; min=(1-s) l; q=(max-min)*6; Which[ h<(1/6), \t{r,g,b}={max,mid=h q + min,min}, h<(1/3), \t{r,g,b}={mid=(h-1/3) q + min,max,min}, h<(1/2), \t{r,g,b}={min,max,mid=(h-1/3)q + min}, h<(2/3), \t{r,g,b}={min,mid=(2/3-h)q + min,max}, h<(5/6), \t{r,g,b}={mid= (h-2/3) q + min,min,max}, True, \t{r,g,b}={max,min,(1-h) q + min}\t\t\t\t\t\t ]; Return[RGBColor[Abs[r],Abs[g],Abs[b]]] ]; \ \>", "Input", InitializationCell->True], Cell[BoxData[ RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible spelling \ error: new symbol name \\\"\\!\\(max\\)\\\" is similar to existing symbol \ \\\"\\!\\(Max\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", \ ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \ ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], "Message"], Cell[BoxData[ RowBox[{\(General::"spell1"\), \(\(:\)\(\ \)\), "\<\"Possible spelling \ error: new symbol name \\\"\\!\\(min\\)\\\" is similar to existing symbol \ \\\"\\!\\(Min\\)\\\". \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", \ ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \ ButtonData:>\\\"General::spell1\\\"]\\)\"\>"}]], "Message"] }, Open ]] }, Open ]], Cell["\<\ End[]; EndPackage[];\ \>", "Input", InitializationCell->True], Cell[CellGroupData[{ Cell["Testing routines and color swatches", "Subsection"], Cell[BoxData[ StyleBox[\({0.0387474, \ 0.916162, \ 0.0398472}\), FormatType->StandardForm, FontFamily->"Courier New"]], "Input"], Cell[CellGroupData[{ Cell["\<\ r=0.0387474;g=0.916162;b= 0.0398472; RGBtoHSB[RGBColor[r,g,b]] Show[GraphicsArray[{ Graphics[ {RGBColor[r,g,b],Rectangle[{0,0},{1,1}]}] , Graphics[ {RGBtoHSB[RGBColor[r,g,b]],Rectangle[{0,0},{1,1}]}] , Graphics[ {Hue[.85,1.,1.],Rectangle[{0,0},{1,1}]}] }] ] \ \>", "Input"], Cell[BoxData[ \(Hue[0.33354224255367226`, 0.957706824775531`, 0.916162`]\)], "Output"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .19314 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.31746 0.00459847 0.31746 [ [ 0 0 0 0 ] [ 1 .19314 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .19314 L 0 .19314 L closepath clip newpath % Start of sub-graphic p 0.0238095 0.00459847 0.321429 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .039 .916 .04 r .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % Start of sub-graphic p 0.35119 0.00459847 0.64881 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .039 .916 .04 r .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % Start of sub-graphic p 0.678571 0.00459847 0.97619 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath 1 0 .9 r .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 55.5625}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg"], ImageRangeCache->{{{0, 287}, {54.5625, 0}} -> {-0.100091, -0.0144882, \ 0.0111505, 0.0111505}, {{8.9375, 93}, {53.25, 1.25}} -> {-0.136642, \ -0.0520051, 0.0124908, 0.0202106}, {{101.438, 185.5}, {53.25, 1.25}} -> \ {-1.29204, -0.0520051, 0.0124908, 0.0202106}, {{193.938, 278}, {53.25, 1.25}} -> \ {-2.44745, -0.0520051, 0.0124908, 0.0202106}}], Cell[BoxData[ TagBox[\(\[SkeletonIndicator] GraphicsArray \[SkeletonIndicator]\), False, Editable->False]], "Output"] }, Open ]], Cell[CellGroupData[{ Cell["\<\ h=0.2; s=1.;b=1.; Show[GraphicsArray[{ Graphics[ {Hue[h,s,b],Rectangle[{0,0},{1,1}]}] , Graphics[ {HSBtoRGB[Hue[h,s,b]],Rectangle[{0,0},{1,1}]}] , Graphics[ {RGBColor[.8,1.,0.],Rectangle[{0,0},{1,1}]}] }] ]\ \>", "Input"], Cell[BoxData[ RowBox[{\(Graphics::"realu"\), \(\(:\)\(\ \)\), "\<\"Argument in \ \\!\\(RGBColor[\\(\\(\\(\\(-0.7999999999999998`\\)\\), 1.`, 0.`\\)\\)]\\) is \ not a real number between 0 and 1. \ \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", ButtonStyle->\\\"RefGuideLinkText\ \\\", ButtonFrame->None, ButtonData:>\\\"Graphics::realu\\\"]\\)\"\>"}]], \ "Message"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .19314 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.31746 0.00459847 0.31746 [ [ 0 0 0 0 ] [ 1 .19314 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .19314 L 0 .19314 L closepath clip newpath % Start of sub-graphic p 0.0238095 0.00459847 0.321429 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .8 1 0 r .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % Start of sub-graphic p 0.35119 0.00459847 0.64881 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath 0 g .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % Start of sub-graphic p 0.678571 0.00459847 0.97619 0.188537 MathSubStart %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations 0.0238095 0.952381 0.0147151 0.588604 [ [ 0 0 0 0 ] [ 1 .61803 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 m 1 0 L 1 .61803 L 0 .61803 L closepath clip newpath .8 1 0 r .02381 .01472 m .02381 .60332 L .97619 .60332 L .97619 .01472 L F MathSubEnd P % End of sub-graphic % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 55.5625}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg"], ImageRangeCache->{{{0, 287}, {54.5625, 0}} -> {-0.100091, -0.0144882, \ 0.0111505, 0.0111505}, {{8.9375, 93}, {53.25, 1.25}} -> {-0.136642, \ -0.0520051, 0.0124908, 0.0202106}, {{101.438, 185.5}, {53.25, 1.25}} -> \ {-1.29204, -0.0520051, 0.0124908, 0.0202106}, {{193.938, 278}, {53.25, 1.25}} -> \ {-2.44745, -0.0520051, 0.0124908, 0.0202106}}], Cell[BoxData[ TagBox[\(\[SkeletonIndicator] GraphicsArray \[SkeletonIndicator]\), False, Editable->False]], "Output"] }, Open ]] }, Open ]] }, FrontEndVersion->"5.0 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 713}}, AutoGeneratedPackage->Automatic, WindowToolbars->"EditBar", CellGrouping->Manual, WindowSize->{795, 670}, WindowMargins->{{Automatic, 102}, {-4, Automatic}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[1754, 51, 41, 0, 38, "Subsection"], Cell[1798, 53, 360, 8, 128, "Text"], Cell[2161, 63, 93, 4, 71, "Text"], Cell[CellGroupData[{ Cell[2279, 71, 817, 17, 246, "Input", InitializationCell->True], Cell[3099, 90, 58, 1, 29, "Output"], Cell[3160, 93, 66, 1, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[3263, 99, 46, 0, 29, "Subsubsection"], Cell[3312, 101, 655, 40, 696, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[4004, 146, 46, 0, 29, "Subsubsection"], Cell[CellGroupData[{ Cell[4075, 150, 893, 44, 750, "Input", InitializationCell->True], Cell[4971, 196, 354, 5, 22, "Message"], Cell[5328, 203, 354, 5, 22, "Message"] }, Open ]] }, Open ]], Cell[5709, 212, 73, 4, 48, "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[5807, 220, 57, 0, 38, "Subsection"], Cell[5867, 222, 144, 3, 30, "Input"], Cell[CellGroupData[{ Cell[6036, 229, 286, 18, 318, "Input"], Cell[6325, 249, 90, 1, 29, "Output"], Cell[6418, 252, 4283, 163, 64, 2136, 132, "GraphicsData", "PostScript", \ "Graphics"], Cell[10704, 417, 135, 3, 29, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[10876, 425, 232, 14, 246, "Input"], Cell[11111, 441, 366, 6, 22, "Message"], Cell[11480, 449, 4264, 163, 64, 2117, 132, "GraphicsData", "PostScript", \ "Graphics"], Cell[15747, 614, 135, 3, 29, "Output"] }, Open ]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)