Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Custom Angled Polygons

$
0
0

Hello,

I would like to create cairo-pentagon tiling.

Cairo pentagonal tiling - Wikipedia, the free encyclopedia

 

Last year I had asked about custom angled triangle, gladly someone had helped me but now I'm facing with a problem to create different angled polygons in illustrator. Of course it can be done manually but I would like to create lots of tilings like cairo pattern. For example it has 5 sides and their angles are 120, 90,90,120,120.

A Script would be great which allows populating an input box with these numbers and creates such polygons.

 

By the way last year CarlosCanto had helped me and his polygonal script was : (This script creates polygons with custom length and side numbers.What I need at this point is entering custom angles. If it's hard to create number of sides option additionally  it would be still handy to have pentagon script with custom angles. Thank you for your help.

 

#target Illustrator
// script.name = polygonBySide.jsx;
// script.description = creates a polygone based on side length;
// script.required = an open document;
// script.parent = CarlosCanto; // 11/21/13;
// script.elegant = false;
// Shared via Creativetuts.com – Author : Carlos Canto
if (app.documents.length>0) polygonBySide ();
else alert (“no document to draw the polygon”);
function polygonBySide() {
var title = “Create Polygon by Side”;
var sideLen = Number(prompt (“Enter Side Length in Points”, 20, title));
var numberOfSides = Number(prompt (“Enter number of sides”, 5, title));
//var s = 2*r*Math.sin(Math.PI/n); // side length = 2*radius*sin(180 deg/number of sides)
var radius = sideLen/(2*Math.sin(Math.PI/numberOfSides));
var idoc = app.activeDocument;
var ctr = idoc.activeView.centerPoint;
dw = idoc.width;
dh = idoc.height;
wc= dw /2;
hc = dh *-0.5;
var ipoly = idoc.pathItems.polygon (ctr[0], ctr[1], radius, numberOfSides);
ipoly.position = Array(wc-(ipoly.width/2),hc+(ipoly.height/2));
}

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>