decomp实现拖拽将2d多边形分解示例代码

代码语言:html

所属分类:拖放

代码描述:decomp实现拖拽将2d多边形分解示例代码

代码标签: decomp 拖拽 2d 多边形 分解 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html>
<head>
   
<title>poly-decomp.js</title>
   
<style>
       
* {
           
margin:0;
           
padding:0;
           
-webkit-touch-callout: none; /* iOS Safari */
           
-webkit-user-select: none;   /* Chrome/Safari/Opera */
           
-khtml-user-select: none;    /* Konqueror */
           
-moz-user-select: none;      /* Firefox */
           
-ms-user-select: none;       /* Internet Explorer/Edge */
           
user-select: none;           /* Non-prefixed version, currently not supported by any browser */
       
}
        body
{
           
margin: 0px;
           
padding: 0px;
           
overflow: hidden;
           
font: 13px Helvetica, arial, freesans, clean, sans-serif;
       
}
        p
, h1 {
           
margin-bottom: 5px;
       
}
        h1 a
{
           
text-decoration: none;
       
}
        a
{
           
color: black;
           
text-decoration: underline;
       
}
       
#info {
           
display: block;
           
background-color:#eee;
           
padding:10px;
       
}
        canvas
{
           
width: 100%;
           
height: 100%;
       
}
   
</style>
</head>
<body>
   
<div id="info">
       
<h1><a href="https://github.com/schteppe/poly-decomp.js">poly-decomp.js</a></h1>
       
<p>Decomposition of 2D polygons into convex pieces in JavaScript. See the <a href="https://github.com/schteppe/poly-decomp.js">Github repo</a>.</p>
       
<p>Try drawing a polygon below!</p>
   
</div>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/decomp.min.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script>
   
<script>
    var demoPolygons = [
        {
            "name": "BayazitCase1",
            "data": [
                [192,40],
                [32,48],
                [78,154],
                [118,108],
                [160,150]
            ]
        },
        {
            "name": "BayazitCase2",
            "data": [
                [125,52],
                [161,104],
                [202,52],
                [268,90],
                [260,188],
                [202,228],
                [165,188],
                [122,231],
                [64,192],
                [52,102]
            ]
        },
        {
            "name": "BayazitCase3",
            "data": [
                [160,56],
                [177,84],
                [196,61],
                [214,105],
                [316,56],
                [318,257],
                [219,255],
                [202,231],
                [184,253],
                [166,200],
                [53,252],
                [56,78]
            ]
        },
        {
            "name": "BayazitCase4",
            "data": [
                [186,56],
                [211,110],
                [230,55],
                [263,53],
                [275,84],
                [323,98],
                [319,246],
                [275,245],
                [240,213],
                [202,243],
                [169,218],
                [119,248],
                [54,246],
                [53,81]
            ]
        },
        {
            "name": "BayazitCase5",
            "data": [
                [174,160],
                [131,112],
                [201,270],
                [128,240],
                [52,270],
                [100,52]
            ]
        },
        {
            "name": "Simple",
            "data": [
                [100,180],
                [100,80],
                [300,80],
                [300,180],
                [250,130]
            ]
        },
        {
            "name": "Peaks",
            "data": [
                [50,220.55491449129886],
                [60,200.9165010426762],
                [70,171.70035249020682],
                [80,114.90970199382247],
                [90,165.9804978067106],
                [100,160.4772842673997],
                [110,84.41974678190957],
                [120,293.8773909405506],
                [130,63.92280957183573],
                [140,73.75740089300058],
                [150,61.19584194167069],
                [160,159.87092544067778],
                [170,247.10194630714335],
                [180,183.8388841500984],
                [190,117.18720369155437],
                [200,242.94006022134025],
                [210,206.9854959619504],
                [220,65.3357054.........完整代码请登录后点击上方下载按钮下载查看

网友评论0