sort color array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • me

    sort color array?

    good day,

    i found this message:
    and i want to know more about it too.
    =============== =============== ============

    Hey all,

    example:
    $s_Colors="0066 FF;0066CC;3366C C;0033FF;003399 ;003366;99CCFF; 3399FF;0099FF;6 6
    99CC;336699;006 699;66CCFF;33CC FF;00CCFF;3399C C;0099CC;003333 ;99CCCC;66CCCC; 3
    39999;669999;00 6666;336666;CCF FFF;99FFFF;66FF FF;33FFFF;00FFF F;00CCCC;99FFCC ;
    66FFCC;33FFCC;0 0FFCC;33CCCC;00 9999;66CC99;33C C99;00CC99;3399 66;009966;00663 3
    ;66FF99;33FF99; 00FF99;33CC66;0 0CC66;009933;99 FF99;66FF66;33F F66;00FF66;3399 3
    3;006600;CCFFCC ;99CC99;66CC66; 669966;336633;0 03300;33FF33;00 FF33;00FF00;00C C
    00;33CC33;00CC3 3;66FF00;66FF33 ;33FF00;33CC00; 339900;009900;C CFF99;99FF66;66 C
    C00;66CC33;6699 33;336600;99FF0 0;99FF33;99CC66 ;99CC00;99CC33; 669900;CCFF66;C C
    FF00;CCFF33;CCC C99;666633;3333 00;CCCC66;CCCC3 3;999966;999933 ;999900;666600; F
    FFFFF;CCCCCC;99 9999;666666;333 333;000000;43dd dd;65432b;77766 5;4443cc;CCCCC3 ;
    A906B0;9CC33F;C 8C8C8;688888;77 7752;66E554;765 5FF;555577;D4DC E8;99AECE;3A5A8 A
    ;9A0030;EF3F6B; FFF543;C906CF;A A2222 ";
    And true a function i add random colors in the string,
    $s_Colors.= ";".strtoupper( $_POST['colorvalue']);

    then i make one array:
    $a_Colors=array _change_key_cas e(split(";",$s_ Colors), CASE_UPPER);
    when i do
    sort($a_Colors) ;
    print_r($a_Colo rs);

    or
    asort($a_Colors );
    print_r($a_Colo rs);


    the values are not correct sorted..!
    oke i understand the difference of the hex index so anybody idea??

    Cheers,

    D
    =============== =============== =============== ======


  • Michael Austin

    #2
    Re: sort color array?

    me wrote:[color=blue]
    > good day,
    >
    > i found this message:
    > and i want to know more about it too.
    > =============== =============== ============
    >
    > Hey all,
    >
    > example:
    > $s_Colors="0066 FF;0066CC;3366C C;0033FF;003399 ;003366;99CCFF; 3399FF;0099FF;6 6
    > 99CC;336699;006 699;66CCFF;33CC FF;00CCFF;3399C C;0099CC;003333 ;99CCCC;66CCCC; 3
    > 39999;669999;00 6666;336666;CCF FFF;99FFFF;66FF FF;33FFFF;00FFF F;00CCCC;99FFCC ;
    > 66FFCC;33FFCC;0 0FFCC;33CCCC;00 9999;66CC99;33C C99;00CC99;3399 66;009966;00663 3
    > ;66FF99;33FF99; 00FF99;33CC66;0 0CC66;009933;99 FF99;66FF66;33F F66;00FF66;3399 3
    > 3;006600;CCFFCC ;99CC99;66CC66; 669966;336633;0 03300;33FF33;00 FF33;00FF00;00C C
    > 00;33CC33;00CC3 3;66FF00;66FF33 ;33FF00;33CC00; 339900;009900;C CFF99;99FF66;66 C
    > C00;66CC33;6699 33;336600;99FF0 0;99FF33;99CC66 ;99CC00;99CC33; 669900;CCFF66;C C
    > FF00;CCFF33;CCC C99;666633;3333 00;CCCC66;CCCC3 3;999966;999933 ;999900;666600; F
    > FFFFF;CCCCCC;99 9999;666666;333 333;000000;43dd dd;65432b;77766 5;4443cc;CCCCC3 ;
    > A906B0;9CC33F;C 8C8C8;688888;77 7752;66E554;765 5FF;555577;D4DC E8;99AECE;3A5A8 A
    > ;9A0030;EF3F6B; FFF543;C906CF;A A2222 ";
    > And true a function i add random colors in the string,
    > $s_Colors.= ";".strtoupper( $_POST['colorvalue']);
    >
    > then i make one array:
    > $a_Colors=array _change_key_cas e(split(";",$s_ Colors), CASE_UPPER);
    > when i do
    > sort($a_Colors) ;
    > print_r($a_Colo rs);
    >
    > or
    > asort($a_Colors );
    > print_r($a_Colo rs);
    >
    >
    > the values are not correct sorted..!
    > oke i understand the difference of the hex index so anybody idea??
    >
    > Cheers,
    >
    > D
    > =============== =============== =============== ======
    >
    >[/color]


    What exactly is NOT working? the UPPERCASE function: here is why - from
    the manual:

    array_change_ke y_case() changes the keys in the input array to be all
    lowercase or uppercase. The change depends on the last optional case
    parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
    The default is CASE_LOWER. **The function will leave number indices as
    is.** and a hex value is considered a number.

    try:
    $a_Colors= explode(";",str toupper($s_Colo rs));
    sort($a_Colors) ;
    print_r($a_Colo rs);


    Michael Austin.

    Comment

    • me

      #3
      Re: sort color array?

      Hey Michael,

      Wel as you probaly tested the colors are sorterd in a alpha numeric way but
      not in a hex ritme..
      I want to have a all the colors that are example in the range of red
      together.. and if you make a test and print a table with the colors you see
      that they are not sort properly.

      Cheers,

      M



      "Michael Austin" <maustin@firstd basource.com> wrote in message
      news:grfEc.9053 $6a1.2092@newss vr22.news.prodi gy.com...[color=blue]
      > me wrote:[color=green]
      > > good day,
      > >
      > > i found this message:
      > > and i want to know more about it too.
      > > =============== =============== ============
      > >
      > > Hey all,
      > >
      > > example:
      > >[/color][/color]
      $s_Colors="0066 FF;0066CC;3366C C;0033FF;003399 ;003366;99CCFF; 3399FF;0099FF;6 6[color=blue][color=green]
      > >[/color][/color]
      99CC;336699;006 699;66CCFF;33CC FF;00CCFF;3399C C;0099CC;003333 ;99CCCC;66CCCC; 3[color=blue][color=green]
      > >[/color][/color]
      39999;669999;00 6666;336666;CCF FFF;99FFFF;66FF FF;33FFFF;00FFF F;00CCCC;99FFCC ;[color=blue][color=green]
      > >[/color][/color]
      66FFCC;33FFCC;0 0FFCC;33CCCC;00 9999;66CC99;33C C99;00CC99;3399 66;009966;00663 3[color=blue][color=green]
      > >[/color][/color]
      ;66FF99;33FF99; 00FF99;33CC66;0 0CC66;009933;99 FF99;66FF66;33F F66;00FF66;3399 3[color=blue][color=green]
      > >[/color][/color]
      3;006600;CCFFCC ;99CC99;66CC66; 669966;336633;0 03300;33FF33;00 FF33;00FF00;00C C[color=blue][color=green]
      > >[/color][/color]
      00;33CC33;00CC3 3;66FF00;66FF33 ;33FF00;33CC00; 339900;009900;C CFF99;99FF66;66 C[color=blue][color=green]
      > >[/color][/color]
      C00;66CC33;6699 33;336600;99FF0 0;99FF33;99CC66 ;99CC00;99CC33; 669900;CCFF66;C C[color=blue][color=green]
      > >[/color][/color]
      FF00;CCFF33;CCC C99;666633;3333 00;CCCC66;CCCC3 3;999966;999933 ;999900;666600; F[color=blue][color=green]
      > >[/color][/color]
      FFFFF;CCCCCC;99 9999;666666;333 333;000000;43dd dd;65432b;77766 5;4443cc;CCCCC3 ;[color=blue][color=green]
      > >[/color][/color]
      A906B0;9CC33F;C 8C8C8;688888;77 7752;66E554;765 5FF;555577;D4DC E8;99AECE;3A5A8 A[color=blue][color=green]
      > > ;9A0030;EF3F6B; FFF543;C906CF;A A2222 ";
      > > And true a function i add random colors in the string,
      > > $s_Colors.= ";".strtoupper( $_POST['colorvalue']);
      > >
      > > then i make one array:
      > > $a_Colors=array _change_key_cas e(split(";",$s_ Colors), CASE_UPPER);
      > > when i do
      > > sort($a_Colors) ;
      > > print_r($a_Colo rs);
      > >
      > > or
      > > asort($a_Colors );
      > > print_r($a_Colo rs);
      > >
      > >
      > > the values are not correct sorted..!
      > > oke i understand the difference of the hex index so anybody idea??
      > >
      > > Cheers,
      > >
      > > D
      > > =============== =============== =============== ======
      > >
      > >[/color]
      >
      >
      > What exactly is NOT working? the UPPERCASE function: here is why - from
      > the manual:
      >
      > array_change_ke y_case() changes the keys in the input array to be all
      > lowercase or uppercase. The change depends on the last optional case
      > parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
      > The default is CASE_LOWER. **The function will leave number indices as
      > is.** and a hex value is considered a number.
      >
      > try:
      > $a_Colors= explode(";",str toupper($s_Colo rs));
      > sort($a_Colors) ;
      > print_r($a_Colo rs);
      >
      >
      > Michael Austin.[/color]


      Comment

      • Michael Austin

        #4
        Re: sort color array?

        > "Michael Austin" <maustin@firstd basource.com> wrote in message[color=blue]
        > news:grfEc.9053 $6a1.2092@newss vr22.news.prodi gy.com...
        >[color=green]
        >>me wrote:
        >>[color=darkred]
        >>>good day,
        >>>
        >>>i found this message:
        >>>and i want to know more about it too.
        >>>============ =============== ===============
        >>>
        >>>Hey all,
        >>>
        >>>example:
        >>>[/color][/color]
        >
        > $s_Colors="0066 FF;0066CC;3366C C;0033FF;003399 ;003366;99CCFF; 3399FF;0099FF;6 6
        >
        > 99CC;336699;006 699;66CCFF;33CC FF;00CCFF;3399C C;0099CC;003333 ;99CCCC;66CCCC; 3
        >
        > 39999;669999;00 6666;336666;CCF FFF;99FFFF;66FF FF;33FFFF;00FFF F;00CCCC;99FFCC ;
        >
        > 66FFCC;33FFCC;0 0FFCC;33CCCC;00 9999;66CC99;33C C99;00CC99;3399 66;009966;00663 3
        >
        > ;66FF99;33FF99; 00FF99;33CC66;0 0CC66;009933;99 FF99;66FF66;33F F66;00FF66;3399 3
        >
        > 3;006600;CCFFCC ;99CC99;66CC66; 669966;336633;0 03300;33FF33;00 FF33;00FF00;00C C
        >
        > 00;33CC33;00CC3 3;66FF00;66FF33 ;33FF00;33CC00; 339900;009900;C CFF99;99FF66;66 C
        >
        > C00;66CC33;6699 33;336600;99FF0 0;99FF33;99CC66 ;99CC00;99CC33; 669900;CCFF66;C C
        >
        > FF00;CCFF33;CCC C99;666633;3333 00;CCCC66;CCCC3 3;999966;999933 ;999900;666600; F
        >
        > FFFFF;CCCCCC;99 9999;666666;333 333;000000;43dd dd;65432b;77766 5;4443cc;CCCCC3 ;
        >
        > A906B0;9CC33F;C 8C8C8;688888;77 7752;66E554;765 5FF;555577;D4DC E8;99AECE;3A5A8 A
        >[color=green][color=darkred]
        >>>;9A0030;EF3F 6B;FFF543;C906C F;AA2222 ";
        >>>And true a function i add random colors in the string,
        >>>$s_Colors. = ";".strtoupper( $_POST['colorvalue']);
        >>>
        >>>then i make one array:
        >>>$a_Colors=ar ray_change_key_ case(split(";", $s_Colors), CASE_UPPER);
        >>>when i do
        >>>sort($a_Colo rs);
        >>>print_r($a_C olors);
        >>>
        >>>or
        >>>asort($a_Col ors);
        >>>print_r($a_C olors);
        >>>
        >>>
        >>>the values are not correct sorted..!
        >>>oke i understand the difference of the hex index so anybody idea??
        >>>
        >>>Cheers,
        >>>
        >>>D
        >>>============ =============== =============== =========
        >>>
        >>>[/color]
        >>
        >>
        >>What exactly is NOT working? the UPPERCASE function: here is why - from
        >>the manual:
        >>
        >>array_change_ key_case() changes the keys in the input array to be all
        >>lowercase or uppercase. The change depends on the last optional case
        >>parameter. You can pass two constants there, CASE_UPPER and CASE_LOWER.
        >>The default is CASE_LOWER. **The function will leave number indices as
        >>is.** and a hex value is considered a number.
        >>
        >>try:
        >> $a_Colors= explode(";",str toupper($s_Colo rs));
        >> sort($a_Colors) ;
        >> print_r($a_Colo rs);
        >>
        >>
        >>Michael Austin.[/color]
        >
        >
        >[/color]
        me wrote:
        [color=blue]
        > Hey Michael,
        >
        > Wel as you probaly tested the colors are sorterd in a alpha numeric[/color]
        way but[color=blue]
        > not in a hex ritme..
        > I want to have a all the colors that are example in the range of red
        > together.. and if you make a test and print a table with the colors[/color]
        you see[color=blue]
        > that they are not sort properly.
        >
        > Cheers,
        >
        > M
        >[/color]

        [top-post-corrected]

        Now that is a horse of a different color. :)

        Once you have your array, you will need to break it down into RGB order

        FFFFFF
        |||||+--> Blue LSByte
        ||||+---> Blue MSByte
        |||+----> Green LSByte
        ||+-----> Green MSByte
        |+------> Red LSByte
        +-------> Red MSByte

        and sort where Red is predominate etc..., I am guessing you already
        figured that one out. In essence you need a 3-dimensional array (not
        multiple arrays)... and a way to sort it and still keep the colors intact.

        to see how difficult this would be look at a chart I found:


        After 2.5 hours, I am giving up and going to bed... good night.

        Michael Austin.

        oh... I guess I should have hit the send button....

        Comment

        • Sjeef

          #5
          Re: sort color array?

          Look here for a colorchart::



          Gerard Schaefers
          --
          Voor meer kook- en eetplezier? Kijk hier!



          Comment

          • me

            #6
            Re: sort color array?

            Thanks but hehe how can i do this in php? :)

            I need a color algoritme? that knows wich part is in red and wich part is in
            green etc etc??

            Cheers,

            M
            "Sjeef" <sjeef@(WEGHALE N)zeepost.nl> wrote in message
            news:40e2c5c1$0 $65124$e4fe514c @news.xs4all.nl ...[color=blue]
            > Look here for a colorchart::
            >
            > http://www.xs4all.nl/~sjeef/Nederlands/colorchart.html
            >
            > Gerard Schaefers
            > --
            > Voor meer kook- en eetplezier? Kijk hier!
            > http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html
            >
            >[/color]


            Comment

            • Sjeef

              #7
              Re: sort color array?

              me wrote:[color=blue]
              > Thanks but hehe how can i do this in php? :)
              >
              > I need a color algoritme? that knows wich part is in red and wich
              > part is in green etc etc??
              >
              > Cheers,
              >
              > M
              > "Sjeef" <sjeef@(WEGHALE N)zeepost.nl> wrote in message
              > news:40e2c5c1$0 $65124$e4fe514c @news.xs4all.nl ...[color=green]
              >> Look here for a colorchart::
              >>
              >> http://www.xs4all.nl/~sjeef/Nederlands/colorchart.html
              >>
              >> Gerard Schaefers
              >> --
              >> Voor meer kook- en eetplezier? Kijk hier!
              >> http://www.xs4all.nl/~sjeef/Nederlands/Recepten.html[/color][/color]

              Sorry can't help you in this.

              Gerard Schaefers
              --
              Voor meer kook- en eetplezier? Kijk hier!



              Comment

              Working...