Circular path
a while asked if had messed scripting paths in photoshop. got little response. anyway persevered hope of creating circle. kicks, understand (i must out more). turns out there isn't info out there on subject it's not possible create true circle bezier curves. i've had , i've managed circular approximation paths.
// draw circular path // use @ own risk // author: ghoulfool // g. adam stanislav kappa explanation // kappa kappa hey! app.preferences.rulerunits = units.pixels; // optionals var radius = 150; // radius of circle drawn var circx = 160; // centre of circle x var circy = 160; // centre of circle y // create document work var docref = app.documents.add("320px", "320px", 72, "circle"); // call source document var srcdoc = app.activedocument; // create new layer var layerref = srcdoc.artlayers.add() layerref.name = "circle" layerref.blendmode = blendmode.normal //draw circle drawcircle(circx , circy, radius, "circle") function drawcircle(x,y,rad, pathname) { var k = (4 * (math.sqrt(2) - 1) / 3)* rad // define circle points var c = new array(); c = [x, y - rad, x + rad, y, x, y + rad, x - rad, y, x + k, y - rad, x + rad, y - k, x + rad, y + k, x - k, y + rad, x + k, y + rad, x - rad, y + k, x - rad, y - k, x - k, y - rad]; // create array of pathpointinfo objects var linearray = new array(); linearray.push(new pathpointinfo()); linearray[0].kind = pointkind.cornerpoint; linearray[0].anchor = new array(c[0], c[1]); // linearray[0].leftdirection = [c[8], c[9]]; linearray[0].rightdirection = linearray[0].anchor; linearray.push(new pathpointinfo()); linearray[1].kind = pointkind.cornerpoint; linearray[1].anchor = new array(c[2], c[3]); // b linearray[1].leftdirection = [c[12], c[13]]; linearray[1].rightdirection = [c[10], c[11]]; linearray.push(new pathpointinfo()); linearray[2].kind = pointkind.cornerpoint; linearray[2].anchor = new array(c[4], c[5]); // c linearray[2].leftdirection = [c[14], c[15]]; linearray[2].rightdirection = [c[16], c[17]]; linearray.push(new pathpointinfo()); linearray[3].kind = pointkind.cornerpoint; linearray[3].anchor = new array(c[6], c[7]); // d linearray[3].leftdirection = [c[20], c[21]]; linearray[3].rightdirection = [c[18], c[19]]; linearray.push(new pathpointinfo()); linearray[4].kind = pointkind.cornerpoint; linearray[4].anchor = new array(c[0], c[1]); linearray[4].leftdirection = linearray[4].anchor; linearray[4].rightdirection = [c[22], c[23]]; // create subpathinfo object, holds line array in entiresubpath property. var linesubpatharray = new array(); linesubpatharray.push(new subpathinfo()); linesubpatharray[0].operation = shapeoperation.shapexor; linesubpatharray[0].closed = false; linesubpatharray[0].entiresubpath = linearray; //create path item, passing subpath add method var mypathitem = docref.pathitems.add(pathname, linesubpatharray); // set foreground colour green var fgcolor = new solidcolor; fgcolor.rgb.hexvalue="00ff80" //green colour foregroundcolor = fgcolor //fill path mypathitem.fillpath(fgcolor,colorblendmode.normal,100,false,0,true,true); //deselect path // ======================================================= var id630 = charidtotypeid( "dslc" ); var desc154 = new actiondescriptor(); var id631 = charidtotypeid( "null" ); var ref127 = new actionreference(); var id632 = charidtotypeid( "path" ); ref127.putclass( id632 ); desc154.putreference( id631, ref127 ); executeaction( id630, desc154, dialogmodes.no ); }
this second attempt. first on semi circle basis 2 points - circles looked oval. better feel.
enjoy!
turns out there isn't info out there on subject it's not possible create true circle bezier curves.
is indeed?
the ellipse tool (constrained) seems create decent crircular path , if pasted above , rotated cannot notice misalignments.
More discussions in Photoshop Scripting
adobe
Comments
Post a Comment