Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Javascript Implementation

2012-03-06
2013-09-03
  • This is a fantastic library :D I think there would be many applications for it
    in a web context. Have you considered what it would take to implement it in
    Javascript? I was looking for a javascript library for polygon clipping and I
    found this and I couldn't find any algorithms implemented in Javascript.

    I took a quick stab at using ScriptSharp to translate the C# code to
    Javascript, but there are too many incompatible structures to use that and I
    couldn't get it to output a javascript file.

    Trying to implement the Vatti clipping algorithm in Javascript seems to be the
    next step.

     
  • Michael
    Michael
    2012-03-06

    Hi I ported the Clipper to ActionScript 3 .It is pretty much like JavaScript.I
    still have a couple of bugs to solve there but generally it work.If you wanna
    help with it to get it into JS you can go ahead .You can fork it from here:

    https://github.com/sasmaster/Clipper

     
  • Michael
    Michael
    2012-03-06

    And yes ,it won't help you using all sorts of automatics conversion tools.The
    clipper has data structures like Int64 or Int128 which are non existent in JS
    or AS .I just removed them altogether .Int32 should be enough for most cases
    unless you work on smth related to geography or huge maps .

     
  • Angus Johnson
    Angus Johnson
    2012-03-06

    I'm stretched maintaining the current Delphi, C# and C++ versions of Clipper
    without trying to learn another language, and then translate and support that
    one too. Nevertheless, I'd be delighted if someone else was prepared to
    translate and maintain a Java version of Clipper.

     
  • Thanks for the suggestion @sasmaster.

    @angusj, I can't believe you've ported it to so many languages as it is :D
    It's really an amazing accomplishment to implement and maintain such a complex
    program in so many formats. I am very impressed by your work and I thank you
    for making it available.

     
  • Mahesh Naik
    Mahesh Naik
    2012-03-14

    Hello BraveHearts!

    ..Anyone has enough courage/guts to translate it into that venerable old
    language called C and maintain it in step

    the flood of new releases Angush slogs over.

     
  • Angus Johnson
    Angus Johnson
    2012-12-12

    Well done Timo!

     
  • Mike Sheldrake
    Mike Sheldrake
    2012-12-13

    That's great!

     
  • Vini gfer
    Vini gfer
    2013-05-02

    I used use the Javascript Clipper, but it freezes the browser. I'm trying to get it working using web Worker (threads in HTML5) and importScripts, but I get an error:
    "window is not defined". Any idea why this happen?

     
    Last edit: Vini gfer 2013-05-02
  • Timo
    Timo
    2013-09-03

    Sorry about late answer. The way you did it is the right one. I have plans to make Javascript Clipper Worker-capable to allow it to run on background (in multiple threads). I have had problems in porting new polynode/polytree functionality, so the process has some delay. Also some features are still incomplete (eg. simplifying and bezierlib), so delaying new version of Javascript Clipper is a good choice at the moment.