Results 1 to 5 of 5

Thread: bagaimana mencampurkan dua warna menjadi satu?

  1. #1
    Ririn Indah is offline Anggota BabaFlash
    Join Date
    Apr 2012
    Posts
    11

    Default bagaimana mencampurkan dua warna menjadi satu?

    mohon bantuannya...
    saya mau tanya
    bagaimana mencampurkan 2 warna menjadi satu pada flash ???
    terimakasih

  2. #2
    dedet's Avatar
    dedet is offline Dah Nggak Dibanned
    Join Date
    Apr 2010
    Location
    Tanah Airku Indonesia
    Posts
    580

    Default

    Quote Originally Posted by Ririn Indah View Post
    mohon bantuannya...
    saya mau tanya
    bagaimana mencampurkan 2 warna menjadi satu pada flash ???
    terimakasih
    matematikanya harus kuat yah
    AS3 Flash: Extracting and Combining RGB Color Components, Converting to Hex
    Albert Einstein - “The important thing is not to stop questioning. Curiosity has its own reason for existing.”
    "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Chinese Proverb

    http://irzal.com

  3. #3
    Ririn Indah is offline Anggota BabaFlash
    Join Date
    Apr 2012
    Posts
    11

    Default


    kalo melalui script pada flash,,,bearti harus menghitung setiap nilai rgb yg di maksudkan u/ hasil warna dr pancampurannya?
    kalo diatas kan om contoh in dg cara mngatur scrol..
    saya maksudkan kalo mencampur 2 warna berbeda pada 1 tempat objek mungkin dengan cara memindahkannya dg di drag dr warna yg dipilih ketempat u/ dicampurkan yg jadi satu itu bagaimana om ??
    Last edited by Ririn Indah; 05-30-2012 at 06:16 AM.

  4. #4
    dedet's Avatar
    dedet is offline Dah Nggak Dibanned
    Join Date
    Apr 2010
    Location
    Tanah Airku Indonesia
    Posts
    580

    Default

    Quote Originally Posted by Ririn Indah View Post

    kalo melalui script pada flash,,,bearti harus menghitung setiap nilai rgb yg di maksudkan u/ hasil warna dr pancampurannya?
    Betul tiap warna harus dipisahkan dulu R-G-B nya

    Quote Originally Posted by Ririn Indah View Post
    kalo diatas kan om contoh in dg cara mngatur scrol..
    saya maksudkan kalo mencampur 2 warna berbeda pada 1 tempat objek mungkin dengan cara memindahkannya dg di drag dr warna yg dipilih ketempat u/ dicampurkan yg jadi satu itu bagaimana om ??
    Berikut script dari AS1 saya convert menjadi AS3
    source:mixing color
    Code:
    function MixRGBColor(color1:uint, color2:uint):uint{
        ///////////////////////////////////////////////////////////////////////////////
        /*
        English : 
    
        We are melting two colors (color1 and color2)
    
        Input parameters :
        color1:uint
        color2:uint
        
        Output parameter :
    
        colorMixRGB:uint
    
        (c) Cheesecom 2002
        **converted to AS3**
        */
        ///////////////////////////////////////////////////////////////////////////////
        
        /**
         * Split color to RGB
         */
        var clR1:uint = (( color1 >> 16 ) & 0xFF);
        var clG1:uint = (( color1 >> 8 ) & 0xFF);
        var clB1:uint = ( color1 & 0xFF );
        
        var clR2:uint = (( color2 >> 16 ) & 0xFF);
        var clG2:uint = (( color2 >> 8 ) & 0xFF);
        var clB2:uint = ( color2 & 0xFF );
         
        /*
        English : 
        Test if both color are primary colors in CMY mode.
        */
        
        var testCMY:Boolean = (((clR1 == 255 && clG1 == 255 && clB1== 0) ||
            (clR1 == 255 && clG1 == 0 && clB1== 255) ||
            (clR1 == 0 && clG1 == 255 && clB1== 255)) &&
            ((clR2 == 255 && clG2 == 255 && clB2== 0) ||
            (clR2 == 255 && clG2 == 0 && clB2== 255) ||
            (clR2 == 0 && clG2 == 255 && clB2== 255)));
            trace("CMY = " , testCMY);
    
        /*
        English : 
        Test if both colors are primary colors in RGB mode.
        */
        var testRGB:Boolean = (((clR1 == 255 && clG1 == 0 && clB1== 0) ||
            (clR1 == 0 && clG1 == 255 && clB1== 0) ||
            (clR1 == 0 && clG1 == 0 && clB1== 255)) &&
            ((clR2 == 255 && clG2 == 0 && clB2== 0) ||
            (clR2 == 0 && clG2 == 255 && clB2== 0) ||
            (clR2 == 0 && clG2 == 0 && clB2== 255)));
            trace("RGB = ", testRGB);
            
        /*
        * New color RGB
        */
        var colorR:uint
        var colorG:uint
        var colorB:uint
        
        /*
        English : 
        test if both colors are the same.
        */
        var sameColor:Boolean = (clR1==clR2 && clG1==clG2 && clB1==clB2);
    
        if (sameColor){
            
            /*
        English :
        Both colors are the same, we keep only one.
            */
            colorR = clR1;
            colorG = clG1;
            colorB = clB1;
            //trace("2 fois la même couleur !!!")
            
        }else if (testRGB && !testCMY){
            
            /*
        English :
        They are both RGB primary colors. We use a XOR operator to calculate the color mix.
            */
            colorR = clR1 ^ clR2;
            //trace(colorr);
            colorG = clG1 ^ clG2;
            //trace(colorg);
            colorB = clB1 ^ clB2;
            //trace(colorb);
            //trace("dans la boucle RGB");
            
        } else if (testCMY && !testRGB){
            
            /*
        English : 
        They are both CMY primary colors. We use a logical AND to calculate the color mix.
            */
            colorB = clR1 && clR2;
            //trace(colorr);
            colorB = clG1 && clG2;
            //trace(colorg);
            colorB = clB1 && clB2;
            //trace(colorb);
            //trace("dans la boucle CMY");
            
        }else{
            
            /*
        English :
    
        They are not both primary colors. We calculate the average between each color.
            */
            colorR = Math.floor((clR1+clR2)/2);
            trace(colorR);
            colorG = Math.floor((clG1+clG2)/2);
            trace(colorG);
            colorB = Math.floor((clB1+clB2)/2);
            trace(colorB);
        }
        return ( ( colorR<< 16 ) | ( colorG << 8 ) | colorB );
    }
    Demo
    http://sites.google.com/site/irzali/...lor-mixing.swf

    source file (minimal CS4):
    http://sites.google.com/site/irzali/...lor-mixing.fla


    Edit:
    Script ditersebut masih ada bugsnya, misalnya kombinasi dari biru dan kuning ternyata menghasilnya uint untuk warna abu-abu

    Peringatan!
    kalo bikin thread cukup satu cari sub-topic yang kira-kira berhubungan dengan subjectnya, jangan bikin banyak!
    Last edited by dedet; 06-02-2012 at 12:35 AM.
    Albert Einstein - “The important thing is not to stop questioning. Curiosity has its own reason for existing.”
    "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Chinese Proverb

    http://irzal.com

  5. #5
    dedet's Avatar
    dedet is offline Dah Nggak Dibanned
    Join Date
    Apr 2010
    Location
    Tanah Airku Indonesia
    Posts
    580

    Default

    ini code yang baru, dapat dari AS3 Average Colour Between Two Colours - ActionScript 3 - Snipplr Social Snippet Repository

    pencampuran warna RGB dan CMY berhasil, biru+kuning tidak menghasilkan warna abu-abu

    demo:
    http://sites.google.com/site/irzali/...mixing-new.swf

    source-demo:
    http://sites.google.com/site/irzali/...mixing-new.fla

    scratchbrain AverageColor source:
    http://sites.google.com/site/irzali/...ratchbrain.zip
    Albert Einstein - “The important thing is not to stop questioning. Curiosity has its own reason for existing.”
    "Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Chinese Proverb

    http://irzal.com

Similar Threads

  1. bagaimana mencampurkan dua warna menjadi satu?
    By Ririn Indah in forum 2D Animation
    Replies: 0
    Last Post: 05-29-2012, 10:57 AM
  2. dua angka berbeda
    By papercut in forum ActionScript 1.0/2.0
    Replies: 7
    Last Post: 11-07-2010, 07:46 PM
  3. bagaimana biar file swf menjadi full screen AS3
    By rudynovri in forum Flash CS3, CS4, CS5.5 dan Action Script 3
    Replies: 4
    Last Post: 06-07-2010, 07:16 PM
  4. bisa gak gabungin dua file flash?
    By heru iswantoro in forum Beginner
    Replies: 5
    Last Post: 08-25-2009, 08:50 PM
  5. Re: Deteksi warna
    By babaforum in forum Feed Milis BabaFlash
    Replies: 0
    Last Post: 04-11-2009, 01:20 AM

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
  •