forum.webdiplomacy.net

webDip dev coordination forum / public access todo list
It is currently Mon Oct 23, 2017 5:01 pm

All times are UTC




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Mon May 27, 2013 8:06 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
The interface will now work with the normal smallmap.png, too. I implement some functions which color every sea-territory with an unique color, so it can be detected later:

Attachment:
interactive.zip [20.85 KiB]
Downloaded 182 times


Now you will have to add "true" or "false" as a parameter for loadIA() in orderinterface.php:

Code:
loadIA("variants/'.$Game->Variant->name.'/resources/Smallmap.png",true);


true -> every sea-territory should be colored on load (lags a bit; won't work well for maps, where Sea-Territories aren't separated exactly (e.g. in AncMed: LigSea and TyrSea between Sar and Cor))

false -> the loaded map must have colored sea-territories to work well

This should only be a temporary solution. Later there should be an auto-detection, if the sea-territories need to be colored or not.


Top
 Profile  
 
PostPosted: Mon May 27, 2013 10:12 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Creating a special IA_mal.png is really easy.
If it's better for performance it might be no problem to keep this.
Also it might help to grey-out invalid target-territories (like I explained in my PM)


Top
 Profile  
 
PostPosted: Sun Jun 02, 2013 8:12 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Update:
- fully colored maps are now auto generated by a php script, if they are not existing already (also supports maps consisting of two maps like map.png and map_2.png for WWIV or map_1.png and map_2.png for Heaven) -> nearly every not-FoW variant should be ready for the interface now
- large maps can be displayed with scrollbars or without
- variant-specific changes for the drawing of orders are supported (an example for the WWIV variant - order arrows on a globe map - is inside the zip file)
- a README.txt file is added which describes the installation

required changes for existing installations:
- add "IAgetMap.php" in the main directory of the site
- replace the existing "interactive" folder by the new one
- remove the parameters of the "loadIA()" function call in "board/orders/order interface.php"

--------------------------

auto generated map - IAgetMap.php - how it works:

- check if "IA_smallMap.png" exists in the variant's resource directory

- if not create a new one:
- load the existing "smallMap.png" or "map.png" or "map_1.png"
- check if there is a "map_2.png" and copy it onto the existing map
- check for each territory position if its color is unique and if this is not the case, color the territory with a unique color using the php flood fill function
- control if every territory has a unique color (will abort if two or more territories have the same color - probably a missing border)
- save the completely colored map as "IA_smallMap.png"

- display the "IA_smallMap.png"


You can run the php script to generate a map directly by opening "IAgetMap.php?variantID=[yourVarID]".

As the map is auto generated it may be wise over-work it:
Attachment:
test_IA_smallMap.png
test_IA_smallMap.png [ 177.05 KiB | Viewed 3008 times ]


But as the colors are already generated this should only take a few minutes:
Attachment:
IA_smallMap.png
IA_smallMap.png [ 178.83 KiB | Viewed 3008 times ]


Attachments:
interactive.zip [59.45 KiB]
Downloaded 152 times
Top
 Profile  
 
PostPosted: Sun Jun 02, 2013 8:18 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Sleepcap wrote:
Also it might help to grey-out invalid target-territories (like I explained in my PM)


The problem with the grey-out is that a canvas element is not designed for that much interaction. A flood fill simply takes too much time. I have not worked on the grey-out so far but I assume that it will cause performance issues. Perhaps I can add a "smaller" sign for valid target-territories in future. :)


Top
 Profile  
 
PostPosted: Sun Jun 02, 2013 9:40 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Is there a way for javascript to work with a multi-layer image?
So we could do a multi-layer-image with each territory put on one layer.
It would take some time to manually generate the necessary image, but it might be worth it.
A very quick'n dirty solution would be to make a separate PNG for each territory and stack these one on another.


Top
 Profile  
 
PostPosted: Mon Jun 03, 2013 8:11 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Today I've tried to implement a grey-out of the territories which can not be reached with only one "layer" (another canvas-element placed above the old one). But the problem is the execution time. I decided to only color every 10th pixel and I've got the time down to 0.14s for the Classic map. But as have to check every 10th pixel if its equivalent pixel on the colored map has the same color as one of the possible choices to move, it still takes nearly 8s(!) on the WWIV-map.
It seems like the only solution is to prepare each greyed-out territory in a separate image by a php script. Perhaps it might be good to save the images like the completely colored map to avoid too much calculating on server side as the images would have to be prepared for every user using the interface. On the other hand an image for each territory of variants like WWIV would also take much disk space I assume.

I don't have enough knowledge to know what would be the best solution, maybe you could help me?


Top
 Profile  
 
PostPosted: Wed Jun 05, 2013 10:10 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Another solution would be to give these indexed-palette PNGs a try. (That's how webdip colors it's images).
Instead of floodfilling each territory it checks for the color-index and than change the color of this one index-entry.
Maybe JS can do the same with transparency (eg. set the alpha-channel of the corresponding index).
A problem is the max-255-colors per image. That's why some maps use 2 parts.
To load an image for each territory is possible, but I'm unsure about the serverload if each page needed to request 200+ small PNG files.


Top
 Profile  
 
PostPosted: Thu Jun 06, 2013 4:53 pm 
Offline

Joined: Tue Nov 15, 2011 2:54 pm
Posts: 44
Well, I thought about this as well. But it seems that you can not access a color palette or change it with javascript. At least I didn't find anything with google. :(


Top
 Profile  
 
PostPosted: Thu Jun 06, 2013 6:34 pm 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
So let's go with the one-file per territory-solution.
I'll try to so this for the classic-map, but I'm a bit busy this weekend. Maybe on Sunday evening.
After the files are cached on the client loading-times should be ok.


Top
 Profile  
 
PostPosted: Sun Jun 09, 2013 6:35 am 
Offline

Joined: Wed Jul 29, 2009 10:22 am
Posts: 841
Is there an easy (and fast) way for javascript to flood-fill a territory?
With an transparent image that has clear borders it should be possible to floodfill the unwanted territories with gray. If this image is put on top of the original map (with an opaque of 50%) it should do the same.

Found an example here: http://www.williammalone.com/articles/html5-canvas-javascript-paint-bucket-tool/

But I have op clue about the performance...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group