We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is my result when run the library : The blue line is origin polygon. The red line is margin polygon.
Here is the code :
<!DOCTYPE html> <html lang="en"> <head> <title>Polygon offset</title> <script src="./offset.js"></script> <style> canvas { border: 1px solid black; } </style> </head> <body> <div id="map"></div> <canvas id="canvas" width="1500" height="800"></canvas> <script type="text/javascript"> // Định nghĩa các điểm của đa giác ban đầu var points = [ [207.41840481414974,200.20372440907403], [245.92289376420604,189.36839650932907], [235.69337392696423,228.03824165899934], [198.295999629077,242.23107068015372], [180.4803924910215,278.04453382325767], [189.02644771672152,317.12093258362563], [228.05368347398834,325.8887640798802], [267.193637672605,334.13885409940065], [276.59911837351336,295.2603647668039], [286.6376211005561,256.54049308572576], [317.63878654144327,231.2634730614677], [339.1311293965072,197.5280436348192], [299.89258594647015,189.76037294666878], [281.98407697126083,153.9932748496069], [321.98240236206254,154.35928841704168], [359.30730954747673,168.74161450151823], [386.67597771286154,197.91276468201423], [403.23114639402047,234.3260368494311], [379.3530206516083,266.41708094322075], [354.0706170958918,297.4138561052581], [324.6944471933648,324.5623485469733], [294.72596085850444,351.05555195458874], [264.7799466656382,377.5741536138138], [224.90086666339678,380.68204327962076], [184.957251093291,378.55893819799985], [145.79208250212645,370.42938905763185], [128.10227921210642,334.5536192462341], [110.41245881518829,298.677857869996], [92.72263841827015,262.80209649375786], [110.10971107311899,226.7786360201303] ]; var x = -10; // Khởi tạo đối tượng Offset var offset = new Offset(); var margined = offset.data(points).margin(10); var padding = offset.data(points).padding(10); // Lấy canvas và context để vẽ var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); // Hàm vẽ đa giác function drawPolygon(ctx, polygon, color) { ctx.beginPath(); ctx.moveTo(polygon[0][0], polygon[0][1]); for (var i = 1; i < polygon.length; i++) { ctx.lineTo(polygon[i][0], polygon[i][1]); } ctx.closePath(); ctx.strokeStyle = color; ctx.stroke(); } // Vẽ đa giác ban đầu drawPolygon(ctx, points, 'blue'); // Vẽ đa giác sau khi áp dụng margin margined.forEach(function(polygon) { drawPolygon(ctx, polygon, 'red'); }); // Vẽ đa giác sau khi áp dụng padding padding.forEach(function(polygon) { drawPolygon(ctx, polygon, 'green'); }); </script> </body> </html>
Here is my result when run the library with your example :
<!DOCTYPE html> <html lang="en"> <head> <title>Polygon offset</title> <script src="./offset.js"></script> <style> canvas { border: 1px solid black; } </style> </head> <body> <div id="map"></div> <canvas id="canvas" width="1500" height="800"></canvas> <script type="text/javascript"> // Định nghĩa các điểm của đa giác ban đầu var points = [ [50, 50], [50, 150], [150, 150], [150, 50], [50, 50] ]; var x = -10; // Khởi tạo đối tượng Offset var offset = new Offset(); var margined = offset.data(points).margin(10); var padding = offset.data(points).padding(10); // Lấy canvas và context để vẽ var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); // Hàm vẽ đa giác function drawPolygon(ctx, polygon, color) { ctx.beginPath(); ctx.moveTo(polygon[0][0], polygon[0][1]); for (var i = 1; i < polygon.length; i++) { ctx.lineTo(polygon[i][0], polygon[i][1]); } ctx.closePath(); ctx.strokeStyle = color; ctx.stroke(); } // Vẽ đa giác ban đầu drawPolygon(ctx, points, 'blue'); // Vẽ đa giác sau khi áp dụng margin margined.forEach(function(polygon) { drawPolygon(ctx, polygon, 'red'); }); console.log( margined); // Vẽ đa giác sau khi áp dụng padding padding.forEach(function(polygon) { drawPolygon(ctx, polygon, 'green'); }); </script> </body> </html>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Here is my result when run the library :
The blue line is origin polygon.
The red line is margin polygon.
Here is the code :
Here is my result when run the library with your example :
![rs](https://private-user-images.githubusercontent.com/107876558/358469505-6c3099d7-337d-42b9-82ea-359bee9edc80.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTM5NzIsIm5iZiI6MTczODk5MzY3MiwicGF0aCI6Ii8xMDc4NzY1NTgvMzU4NDY5NTA1LTZjMzA5OWQ3LTMzN2QtNDJiOS04MmVhLTM1OWJlZTllZGM4MC5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQwNTQ3NTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02YTdhN2QwYzY2NjQ0NjkyMmYwYjc1MDY4ZGJiZWJmZmY0MDg4NDE3OWMwYjYzMDIwMDM5NDk0ODE2NmNjZGU0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.u1ETjthFvXngpv8sHixuqoa15cDOlaZTpyq7orkD8x0)
The text was updated successfully, but these errors were encountered: