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 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    197
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Polygon Clipping

    Does anyone know of a javascript polygon clipping routine
    I have two simple polygons A and B and i need to be able to
    clip A with B
    I have found some c programs to do this but i was wondering if any1 has seen a javascript to do this?

    Thanks in advance
    ez
    Animation Rule #64
    Poor quality images are often artistic,
    Poor quality sound is ALWAYS annoying.

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    If I understand what you are trying to do correctly (as in the demonstration here: http://www.cs.man.ac.uk/aig/staff/al...tware/gpc.html) this would only be possible in Java not JavaScript. JavaScript cannot deal with painting and so would be impossible. If What you are trying to do is very simple, it might be possible in JavaScript using divs and images. A request for code like this would be appropriate in the computer programming section.
    ps. yes this thread is over a month old, but I hate seeing threads with 0 replies.
    Kris Hubby
    kwhubby site

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    You may "mime" cropping and clipping using layers, but first you must be able to draw a polygon... To do that, see:
    http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ^ Nice!!!
    <JPM />

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    Wow that jsgraphics thing is impressive Kor. Even though that's an amazingly efficient way of doing this with DHTML it still is limited to relatively simple shapes and still probably a hundred times slower then if you were to use Java. If you wanted to use complex or large polygons this would not be appropriate. Anyways, I have some uses for that jsgraphics thing thanks for posting that site Kor.
    Kris Hubby
    kwhubby site

  • #6
    New Coder
    Join Date
    Oct 2002
    Location
    Buffalo, NY
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just Browsing Aroung After Posting A Thread.
    I've Gotta Say, Thats Quite Impressive !

  • #7
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    To kwhubby:

    DHTML iapplications are not so slow as you may think. For the same types (movement,visibility) it is faster than Flash or Java equivalents. Still, the main disadvateges of javascript graphics are:
    1. a non-vectorial curves (which is infact a HTML work space disadvantege)
    2. intricate way of rotate objects (or transform them upon other axes than X or Y).

    Many users avoid Java, due to the latest security wekness. Thus, probably the best present way for a high graphical site is using DHTML in combination with Flash.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    JavaScript might be faster for moving visual html objects or hiding and showing them, and certainly more convenient, easier, and comonly found in browsers then java and flash, but emulation of drawing certainly cannot be faster? Try to generate an image with javascript using divs. Even a relatively small image takes a massive amount of time, ineffective for most uses. The dynamically generated divs would suck up a lot or ram and processing time. Try to do 3d rendering in JavaScript: so slow it would be a complete waste of time to make the script. Even In flash 3d rendering would be slow. Both of these are done with a relatively great speed and efficiency in java (take runescape as an example of 3d rendering with java). If the polygons for what ez4ne12c Is trying to do are simple it will be fast enough and optimal for this environment in javascript. But try to do complex series of polygons (where u get tens of thousands of dynamically generated divs), the processing would take much time compared to java. Hopefully what ez4ne12c is trying to do will be simple enough to be efficient in JavaScript using the dhtml example you posted or something similar.
    Last edited by kwhubby; 05-31-2004 at 08:44 AM.
    Kris Hubby
    kwhubby site

  • #9
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    yes, you might be right. Except that there is a sort of "thermo-dynamics 3-rd law" apllied on connection speed. Java or Flash have a superior speed on final approach, but there is certain time for initial applet to be loaded, which almost compensates for the total time...

    In my oppinion, the reason for using Flash or Java for certain applications stands mostly for the vectorial design possibilities, not for speed which, most of the time, is inferior to DHTML application.

    But we did not solve ez4ne12c's problem. I said that a DHTML solution would be intricate so, this particular case, a Flash or, if you want it so much, a Java solution would be probably a better one.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #10
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    Very true, loading time of the applet/flash code and plugin would be a major issue here, that's why we need more information from ez4ne12c in order to see what this is being used for, and exactly what and how he wants to clip B with A.
    Kris Hubby
    kwhubby site


  •  

    Posting Permissions

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