Results 1 to 5 of 5

Thread: color fun

  1. #1
    Join Date
    Jan 2007
    Location
    Manila, Philippines
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default color fun

    what i want to do is divide a range of colors from red to blue into 255 colors store them in an array and get them later

    but do you thin I can divide the color range

    I have started this but it starts at green and i cant get it to work..

    im using out of sequence sin phases to get the color range but that’s about where i get stuck. I can’t divide the range into a certain amount of colors with in a color range. That doesn’t loop

    Code:
    var frequency = .3;
    for (var i = 0; i < 32; ++i){
        r = Math.sin(frequency*i + 0) * 127 + 128;
        g = Math.sin(frequency*i + 2) * 127 + 128;
        b = Math.sin(frequency*i +4) * 127 + 128;
        var color24:Number = r << 16 | g << 8 |  b
        bmpData.setPixel(400, i, color24);
        bmpData.setPixel(401, i, color24);
        bmpData.setPixel(402, i, color24);
    }
    Anyone who knows how to do this please let me know

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Are you by chance trying to make something similar to a color chooser?

    There are many different methods to doing so, and sin/cos is one of the more difficult.

    If you are doing something similar to this and are not against dropping the current method I have a few ideas.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jan 2007
    Location
    Manila, Philippines
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well I have solved with a bit of a hack and thinking outside the box, but it works for me thought you might like to know.

    I have a symbol that is 255px wide with the color range I require, I then create a bmpdata object, attach the symbol with the color range I want. Copy the symbol to the bmpdata object then, loop through one line of pixels and extract the colors into the array.

    This works surprisingly fast with no hanging while I loop… but with a larger size I can foresee a speed issue

    You could also do this by creating a movieclip dynamically with the gradient/color range you want.

    If anyone has a better solution please let me know



    And what idea it would be?
    Last edited by eXceed69; 02-23-2007 at 04:40 AM. Reason: add new info

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Sounds like you have one of the more efficient methods for doing it with single MCs instead of multiples inside a single.

    nice job
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Jan 2007
    Location
    Manila, Philippines
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If anyone has a better solution please let me know

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •