Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-16-2015, 03:17 PM
ilrak ilrak is offline
Goldfish Fanatic
 
Join Date: Aug 2014
Location: Utah
Posts: 57
Gender: Female
Credits: 11,543
ilrak is on a distinguished road
Default Dynamically Generated images?

I learned that some sites use this for pet images (and that it can be useful for markings, colors, etc). How would one go about coding this with mysidia? I found a couple of php tutorials but I don't know if they would still work with this script or not. If so, this might make things a lot easier on me just for the pet images (instead of creating about 755 separate breeds, just for Common goldfish alone!)
__________________
Auratus Ghoti - Please the gods with your school
Tumblr ~ Forum ~![/URL]
Reply With Quote
  #2  
Old 03-16-2015, 06:51 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,968
Kyttias is on a distinguished road
Default

There are a couple of ways it could be done. Lioden stacks ordinary images on top of one another, Flight Rising saves a bunch of images with the pet's ID (I think), HTML5 Canvas could be an option, but dynamically generating an image from merged layers with a meta header declaring a php script as an image should also work -- I'm just not sure how I feel about the load time of this. If you don't save the "image", merely load it every time for each adopt on the page, then it's like Flight Rising but without the script storing the image afterward.

No matter which route you go you'll want to plan a folder structure ahead of time and add these attributes for your fish into the database as columns (in the table for owned adoptables). You'll want to make a new method inside of the ownedadoptables class, I named mine getLayers(). Look through the whole class and you'll find the method that's being used to call up the images in the site - find every instance where it's being called inside the framework and call your method that'll place in a generated image instead. I won't give you hints on that, though. It's very easy to call up the variables once they exist in your database!

I simply made a column called "p_color" to hold my primary colors, its a SMALLINT, and holds simply numbers. They correspond to array that holds all my color names - and all of these color names are the name images in my folders.

So, like...

PHP Code:
$colors = ["red","yellow","orange"];
$p_color $colors[$adopt->p_color]; 
And $adopt->p_color pulls the number from the current adoptable's p_color column and then the variable $p_color holds the name of the color in the array that corresponds with that color. Easy! You can pull from the existing columns that store breed, level, and gender information if you want. But then you'd also want to create a column for secondary colors and patterns if you want those.

You're basically just going to concatenate these variables together as a string of folders and file names. These are how your code will find the images you want to merge.

I'm already storing some custom images in an /img/ folder I created, and my creatures are called Novu, so my folder structure looks like this -

  Spoiler: folder structure 
This is just for one species - Lythine. I'm checking first what level they are, then if its a boy or a girl, I store the lines there, and the colors and patterns inside folders of their own:

img/
novu/
lythine/
0/

f/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
m/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
1/

f/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
m/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
2/

f/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
m/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
3/

f/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
m/

patterns/

none.png
stripes.png
spots.png

colors/

red.png
yellow.png
orange.png

lines.png
You get the idea.


Obviously you need to make a folder structure that makes sense for you needs. Genders look different, things get bigger with age, that nonsense.

Anyway, I've basically already successfully been able to imitate Lioden with its overlapping images (but not a dynamically generated single image). The concept is virtually the same, its just what you do with those variables once you have them ready to go.

I hope its understandable, though, that I don't want a bunch of sites running around with a clone of this particular technique, at least not for free. So this is about all the help I'm willing to give. But I hope I've at least managed to push you in the right direction!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 03-17-2015 at 02:21 PM.
Reply With Quote
  #3  
Old 08-25-2015, 09:10 AM
ilrak ilrak is offline
Goldfish Fanatic
 
Join Date: Aug 2014
Location: Utah
Posts: 57
Gender: Female
Credits: 11,543
ilrak is on a distinguished road
Default

Thanks so much! I thought I had responded to this but I guess I didn't xD

I went over this with my new programmer last night and he has a good idea on where to start now. I do have another question though:

In my game, the colors are set up kinda like Flight rising, with a primary, secondary, and tertiary (art wise, I think I like doing that sort of thing for the markings and such rather than more slots for markings like Lioden). Would I have each type of color in it's own folder then? Like this:

  Spoiler: folders 
Goldfish
Common
f
5
p_color (this is the body color)
copper.png
s_color (fins)
copper.png
t_color (hidden tertiary)
copper.png
markings
copperstipple.png
copperdot.png
copperflame.png
lines.png


That's just for the adult forms (I am having three other stages where the colors are slowly revealed, much like actual goldfish). I'm not sure if that's what the folder structure should be though. I'm working on recoloring the art to match the folder structure a little more. I'm also wanting to add on mutations if the offspring is inbred, so would that also be in this folder structure? I'm thinking yes, but am not sure.
__________________
Auratus Ghoti - Please the gods with your school
Tumblr ~ Forum ~![/URL]

Last edited by ilrak; 08-25-2015 at 09:14 AM.
Reply With Quote
  #4  
Old 08-25-2015, 08:03 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,968
Kyttias is on a distinguished road
Default

I'd recommend something like this (just go another folder down):
  Spoiler: folders 
[LIST]
oranda/
  • f/
    • 5/
      • lines.png
        body/
        • alpha/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          beta/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          stipple/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          shine/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          glaze/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          disruption/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)

        fins/
        • crypsis/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          panda/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          point/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          shine/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)

        markings/
        • dalmation/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          flame/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          dot/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          12point/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          counter/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)
          shine/
          • copper.png
            chocolate.png
            obsidian.png
            (etc)


If you wanted to build a female oranda at level 5, with an obsidian stipple body (primary), copper point fins (secondary), and a chocolate dot marking (tertiary), you'd want to load just these files:

images/oranda/f/5/body/stipple/obsidian.png
images/oranda/f/5/fins/point/copper.png
images/oranda/f/5/markings/dot/chocolate.png
images/oranda/f/5/lines.png

(And really, you could just store the lines with the colored images. This would even allow you to make fins of slightly different shapes.)

I won't help, because I've done it myself and it's a trade secret at this point, but ask your programmer if you can save ONE image (for each body, fin and marking pattern), in just a base color, instead of individual colors -- that he can tint with a color hex code programatically. It's definitely possible, and then you don't have to save each color manually! Think about it, as it can even work with markings that involve more than one color (rather than saving a black and white image, you could, for example, make a yellow dot surrounded by a slightly red outline... tinting it programmatically would be to the same effect as sliding the hue in art program so it's a slightly different shade).

If you can get your programmer to tint an image programatically, you can bring it down to just:

images/oranda/f/5/body/stipple.png
images/oranda/f/5/fins/point.png
images/oranda/f/5/markings/dot.png
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 08-25-2015 at 08:27 PM.
Reply With Quote
  #5  
Old 08-27-2015, 06:22 PM
ilrak ilrak is offline
Goldfish Fanatic
 
Join Date: Aug 2014
Location: Utah
Posts: 57
Gender: Female
Credits: 11,543
ilrak is on a distinguished road
Default

Thank you so much! I'll show this to my programmer when ge comes over next! I'm guessing that the pets are still created in the admincp, but I'll have him look at it and see what the best way will be to create them! Thank you again so much!
__________________
Auratus Ghoti - Please the gods with your school
Tumblr ~ Forum ~![/URL]
Reply With Quote
  #6  
Old 08-28-2015, 02:29 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,968
Kyttias is on a distinguished road
Default

I've personally been thinking about creating a separate place to create pets outside the adminCP, too. x'D They're still created there in name and functionality, even though those images aren't ever seen (I'm uploading lines-only placeholders there so I have a visual). Stages of pets and what level they reach them are all still done in the adminCP.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #7  
Old 08-30-2015, 10:06 PM
Kesstryl's Avatar
Kesstryl Kesstryl is offline
Member
 
Join Date: Feb 2012
Posts: 125
Gender: Female
Credits: 17,012
Kesstryl is on a distinguished road
Default

Thanks for this info! I'm actually making a non-Mysidia game (a strategy game, not pet related) with an avatar system and I've been trying to decide if I'm going to use the php ImageCopy or try layering images with CSS. This post is very informative.
Reply With Quote
  #8  
Old 08-30-2015, 10:37 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 86,968
Kyttias is on a distinguished road
Default

The plus side to layering images is that they'll be cached by the browser for fast loading. On the other hand, these images are relatively small in size to begin with so load times don't really matter. The down side is, they're a collection of images rather than a truly merged image and therefore cannot be saved. Merging things with GD is definitely possible, so keep looking into it! On the other-other hand, separate images means you can even layer animated gif images onto your avatars - something PHP is still incapable of doing even a decade after people first asked for such features.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #9  
Old 01-22-2016, 04:08 PM
parayna's Avatar
parayna parayna is offline
Member
 
Join Date: May 2013
Location: Devon, UK
Posts: 342
Gender: Female
Credits: 16,091
parayna is on a distinguished road
Default

Posting here so I can keep track of this post and not lose it again >.>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
GD images mapleblade Mys v1.2.x Mods 11 03-04-2012 04:39 AM
no images RoconzaArt Questions and Supports 1 03-13-2011 10:39 AM
More images would be nice. RoconzaArt Feedback and Suggestions 12 01-22-2011 10:24 PM
I cant see the images zKaZy Questions and Supports 11 03-28-2010 11:49 AM
Images not showing Tequila Questions and Supports 22 03-07-2009 07:15 AM


All times are GMT -5. The time now is 01:10 PM.

Currently Active Users: 443 (0 members and 443 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636