Berrie's Tinkering

Forum
Last Post
Threads / Messages

BerrieMilk

Member
Member
Joined
Mar 19, 2024
Messages
22
Points
3
Mysidian Dollar
171
Hello!

Just wanted to share some things I've been learning and working on. I'll just update here as I learn things. Of course this is all on a small server and is no way integrated into my Mysidia site but I feel accomplished just learning these things so far.


Mixing Project: Using PHP I generated layered images from my database. Then for each layer I grabbed the hexcode colors for each layer did a simple color mix and generated the baby image by recoloring with the mixed colors.

Female & Male
basic.png basic.png
Baby

Screenshot 2024-04-04 213403.png
 
Looks good! :D I found a simple formula online that will allow you to get a random hex between 2 colours recently while experimenting with my own breeding system. It should allow you to have greater variation in baby outcomes and if both parents have the same colours, so will the baby!

PHP:
str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, '0', STR_PAD_LEFT)

That randomises between black and white (so pretty much gets any random colour) and converts the result to hex. If you wanted to then display it you could do something like the below. This is the direct formula for experimenting purposes so it would be different for actually breeding pets and storing the info in the DB. But this is a nice way to see it working.

PHP:
$document->add(new Comment("#" . strtoupper(str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, '0', STR_PAD_LEFT)) . ""));

That also puts a hash in front of it (as by default it just spits out the numbers/letters) and converts the text to upper case (strtoupper) for display purposes. Refreshing the page will get a new random colour between your two values.
 
Looks good! :D I found a simple formula online that will allow you to get a random hex between 2 colours recently while experimenting with my own breeding system. It should allow you to have greater variation in baby outcomes and if both parents have the same colours, so will the baby!

PHP:
str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, '0', STR_PAD_LEFT)

That randomises between black and white (so pretty much gets any random colour) and converts the result to hex. If you wanted to then display it you could do something like the below. This is the direct formula for experimenting purposes so it would be different for actually breeding pets and storing the info in the DB. But this is a nice way to see it working.

PHP:
$document->add(new Comment("#" . strtoupper(str_pad(dechex(mt_rand(0x000000, 0xFFFFFF)), 6, '0', STR_PAD_LEFT)) . ""));

That also puts a hash in front of it (as by default it just spits out the numbers/letters) and converts the text to upper case (strtoupper) for display purposes. Refreshing the page will get a new random colour between your two values.
Oh my gosh so cool! I'll definitely test that out I would like the outcome to be more unpredictable it's more fun when you don't know how the baby will come out can't wait to test it
 
Similar threads
Thread starter Title Forum Replies Date
BerrieMilk Berrie's Art Gallery Art Gallery 17

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,120
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top