在Javascript中偏移多边形 [英] Offsetting polygons in Javascript

查看:127
本文介绍了在Javascript中偏移多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EDIT5:终于在Angus Johnson的Clipper库中实现了Javascript,并选择了Sourceforge for host。



LIVE DEMO:

- Clipper Documentation >
- 一个Stackoverflow答案

- 偏移算法

解决方案

div>

我已经成功地将裁剪器移植到JS上,过了一段时间后,经过彻底的测试才发布它。似乎所有功能都可能已被移植。

一个警告,128位支持被减少到106位。

其中一个优点是可以扩展浏览器的空间,并且可以使用svg,vml,html5 canvas作为图形界面。



任何想法,哪个主机最容易发布,具有可能性?




编辑:

最后得到了Angus Johnson的Clipper库,这个库是用Javascript实现的,并且选择了Sourceforge for host。

LIVE DEMO:
http://jsclipper.sourceforge.net/6.1 .1.1 / main_demo.html



下载:
https://sourceforge.net/projects/jsclipper/



Wikipage带分步教程:
< a href =https://sourceforge.net/p/jsclipper/wiki/Home%206/ =nofollow> https://sourceforge.net/p/jsclipper/wiki/Home%206/



演示程序的演示包括几十个样本多边形:
https://sourceforge.net/p/jsclipper/wiki/Main_Demo%206/



我希望这有助于任何需要折线和多边形剪裁库的人使用抵消功能。


EDIT5: Finally got Angus Johnson's Clipper library implemented in Javascript and selected Sourceforge for host.

LIVE DEMO: http://jsclipper.sourceforge.net/6.1.1.1/main_demo.html

Download source: https://sourceforge.net/projects/jsclipper/

Wikipage with step-by-step tutorial: https://sourceforge.net/p/jsclipper/wiki/Home%206/

Presentation of Demo Program including tens of sample polygons: https://sourceforge.net/p/jsclipper/wiki/Main_Demo%206/

I hope this helps anyone who needs polyline and polygon clipping library with offsetting features.


EDIT4: The one possibility is to convert pascal to javascript using http://p2js.gelicon.biz/en/ . Not succeeded yet. p2js.exe clipper.pas gives Fatal error "Can't find unit system used by clipper".


EDIT: I found script# (Github), which seems to be able to convert C# to Javascript. Clipper lib is available in C#, so would it be possible to make C#->JS conversion using Script# and how?

EDIT3: Got not converted with script#, but there is also Emscripten, but 4000 cpp lines converted to 300 000 Javascript lines, so not an option. Manual conversion seems to be a king.


EDIT2: I made an example, which shows the problem. Use arrow left and right to apply offset. In certain distance it works ok, but then something goes wrong. The yellow stroked polygon is so called raw offset polygon, and AFAIK Clipper lib provides a way to take care of removing unneeded parts of raw offset polygon.


There is a Clipper library by Angus Johnson for offsetting polygons.

I'd need this functionality in Javascript for offsetting SVG polygons.

Has someone made a Javascript port of it?

If not, I'd appreciate some guidelines eg. the following:
- how enormous task it would be?
- which one to choose for source (Delphi, C#, C++)?
- is everything in lib needed for offsetting?

The Clipper library produces the following results which are just the desired functionality:

Some links:
- Files in Sourceforge
- Clipper Documentation
- One Stackoverflow answer
- Offsetting algorithm

解决方案

I have succeded in porting clipper to JS, and after a while, after thorough testing going to release it. Seems that all the functionality could have been ported.

One caveat, 128bit support is reduced to 106bit.

One of the pros is to reach large space of browsers and possibility to use svg, vml, html5 canvas as graphics interface.

Any ideas, Which host would be easiest to publish, with demo possibility?


EDIT:

Finally got Angus Johnson's Clipper library implemented in Javascript and selected Sourceforge for host.

LIVE DEMO: http://jsclipper.sourceforge.net/6.1.1.1/main_demo.html

Downloads: https://sourceforge.net/projects/jsclipper/

Wikipage with step-by-step tutorial: https://sourceforge.net/p/jsclipper/wiki/Home%206/

Presentation of Demo Program including tens of sample polygons: https://sourceforge.net/p/jsclipper/wiki/Main_Demo%206/

I hope this helps anyone who needs polyline and polygon clipping library with offsetting features.

这篇关于在Javascript中偏移多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆