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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Working with polygons

    Hello
    Can JavaScript work with polygons image witch was created in Photoshop?
    I mean capture polygons coordinates and make these polygons interactive?

    I have a very simple task to be done - draw a map with thousands of polygons, each polygon must have its properties and be interactive. And there will be circle-shape objects that user can move through the polygons on a distance for instance two-three polygons in a round. And these circle objects must also have their properties.

    So I decided to draw polygon-map in Photoshop and do the rest in JavaScript. But I have doubts - can JavaScript "see" these polygons and operate with them or Photoshop-made image is not good for this.
    Any advice on this matter?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,252
    Thanks
    203
    Thanked 2,557 Times in 2,535 Posts
    I don't think that Photoshop and Javascript can interact in the way you want.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you Philip, I understand Photophop is not what I need.
    Any suggestions what to use drawing my map so JavaScript \or anything\ could work with polygons in it?

  • #4
    New Coder
    Join Date
    Sep 2011
    Posts
    43
    Thanks
    6
    Thanked 6 Times in 6 Posts
    .
    You might have a look at some javascript vector libs. Graphics would be parametric, so you could use datasets to define objects/maps.

    One example:
    http://raphaeljs.com/

  • Users who have thanked morongo47 for this post:

    Akora (09-25-2011)

  • #5
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by morongo47 View Post
    .
    You might have a look at some javascript vector libs. Graphics would be parametric, so you could use datasets to define objects/maps.

    One example:
    http://raphaeljs.com/
    Thank you, I will dig in this direction.

  • #6
    New Coder
    Join Date
    Sep 2011
    Posts
    43
    Thanks
    6
    Thanked 6 Times in 6 Posts
    Another way you might be able to do what you describe is with a game-engine, this is from gameQuery Docs:
    collision(filter)
    This method returns the list of elements collisioning with the selected one but only those that match with the filter given as parameter.
    http://gamequery.onaluf.org/

    So, if your circle intersected with the boundaries of several underlying objects, you get the list of objects returned and can use a callback to further process that return according to your game-logic (but of course, it doesn't have to be a game, you just use the functionality provided).

    Have a look at this demo too:
    http://www.java2s.com/Code/JavaScrip...nDetection.htm
    .
    Last edited by morongo47; 09-25-2011 at 10:49 PM.

  • #7
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,529
    Thanks
    3
    Thanked 511 Times in 498 Posts
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #8
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you guys, I think will do it in Adobe Illustrator. I found a way through image maping to grasp the coordinates of polygons.
    Its just such a pity that graphic redactors doesn't have the option of showing coordinates of drawing and people like me must use image mapping plus special drawing technique to do such a simple task.


  •  

    Posting Permissions

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