Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Coloring an image, based on the colors of other images

    I have a browser game already running that revolves around breeding dogs. Right now we use static images, and I'd like markings and colors to be traits that are inheritable through generations.

    I am able to layer images based on the parents layers to create a new dog with new markings. However, this only works with precolored layers. Which means the markings and such are not really being inherited, there is no chance for uniqueness at all.

    What I would like to achieve is the ability to colors parts of a layer or whole image based on what the parents have colored. So lets say you are breeding two border collies, the sire has four while socks and the dam has no socks at all. It should produce puppies anywhere on that spectrum, some with half socks, some with just white feet, etc.

    I hope I'm explaining this correctly. In my head, I see this being possible by coloring only those certain parts of an image. So I only color the feet for example, in a somewhat random pattern based on the parents feet patterns. So this eliminates the need for precolored layers and presents to possibility of random mutations.

    Is this at all achieveable? Is there another way that I'm not thinking of?

    I have an intermediate working knowledge of php, I've coded most of the game myself, but then I hit something like this and get completely stuck. Help put me on the right track please?

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Posts
    454
    Thanks
    0
    Thanked 20 Times in 20 Posts
    If you are working things in layers then changing just the colors of the feet would probably be some serious calculations.
    The best thing I think of, which more experienced coders may help with is a uniqueness generator,

    An old one of mine written in js

    The one on my site should give you an idea of how they work. But to handle just the feet you would need to create object groups. Four feet x 2 main colors etc
    Then your generator should handle color variations.
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Posts
    454
    Thanks
    0
    Thanked 20 Times in 20 Posts
    breeding two border collies, the sire has four while socks and the dam has no socks at all. It should produce puppies anywhere on that spectrum, some with half socks, some with just white feet,
    After mulling it over the is probably an easier way using random selection.
    puppies = 6
    feet = 4 each
    colors = 2 (0 socks - 4brown socks)


    $str = '01234'; //( number of feet to color)
    for($x=0; $x<6; $x++){
    $tmp = shuffle($str);
    echo 'puppy ' .$x. ' has ' .substr(0,1). ' colored feet<br />';
    }

    could work???!!!
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.


  •  

    Posting Permissions

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