如何使同心圆之间的距离相等?
平面设计
adobe-illustrator
形状
2022-02-13 06:35:21
4个回答
我想说这样的事情最好用自动化来完成。想象一下你的收藏中间的一个项目的宽度发生了变化,你将不得不重建一半的圆圈。或者你需要把所有的圆圈加宽 50%。天啊!
我不知道 Illustrator 脚本,但在 Photoshop 中它非常简单。基本上,我有一个具有,data等属性的数组name,并且我有一个函数可以在具有特定半径的特定坐标中创建形状图层。另外,我还有几个附加参数,例如圆之间的间隙、圆的最大宽度和起始半径。valuecolor
使用这些数据,我在一个循环中为每个数据条目创建一个圆圈。中心始终是文档中心,宽度是根据最大宽度和找到的最大数据值线性计算的,半径是根据宽度、先前半径和间隙计算的。
以下是基于间隙、起始半径和最大宽度的不同设置的不同结果:
我使用的代码:
function main()
{
//data definitions
var center = {
x: activeDocument.width.as("px") / 2,
y: activeDocument.height.as("px") / 2
};
var gap = 3; // gap between circles
var startRad = 200; // starting radius
var maxWidth = 15; // maximum width
var maxValue = -1; // stores maximum value found
var width, i;
var data = [
{
color: [223,41,53],
value: 22,
name: "Jerelyn Pinkbeard"
},
{
color: [65,39,34],
value: 13,
name: "Spiteful Christine Black"
},
{
color: [223,160,110],
value: 44,
name: "Generous Christi"
},
{
color: [12,243,187],
value: 4,
name: "Scrawny Tiphanie"
},
{
color: [134,186,144],
value: 12,
name: "Cutthroat Deena The Spiteful"
},
{
color: [5,47,95],
value: 22,
name: "Jerilyn Blackhate"
},
{
color: [0,83,119],
value: 60,
name: "Tiphanie Generousparrot"
},
{
color: [6,167,125],
value: 33,
name: "First Mate Christa The Scrawny"
},
{
color: [213,198,122],
value: 12,
name: "Dread Pirate Geraldine"
}];
/////////////////////////////////////////////////////////////////////////////////////
// START
// first calculating maximum value of all data properties to use it later for linear transforms
for (i = 0; i < data.length; i++)
{
if (data[i].value > maxValue) maxValue = data[i].value;
}
// creating circles
for (i = 0; i < data.length; i++)
{
//calculating width lineary based on maximum value found and maximum width possible
width = linear(data[i].value, 0, maxValue, 0, maxWidth);
createCircle(
{
x: center.x, // X center of the document
y: center.y, // Y center of the document
color: data[i].color, // color from my data
width: width, // calculated width
radius: startRad, // starting radius
name: data[i].name // and a name
});
startRad += width + gap; // updating starting radius with width and gap
}
function createCircle(data)
{
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID('contentLayer'));
desc2.putReference(cTID('null'), ref1);
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
var desc5 = new ActionDescriptor();
desc5.putDouble(cTID('Rd '), 45.000001);
desc5.putDouble(cTID('Grn '), 77.000003);
desc5.putDouble(cTID('Bl '), 113.000001);
desc4.putObject(cTID('Clr '), cTID('RGBC'), desc5);
desc3.putObject(cTID('Type'), sTID('solidColorLayer'), desc4);
var desc6 = new ActionDescriptor();
desc6.putInteger(sTID('unitValueQuadVersion'), 1);
desc6.putUnitDouble(cTID('Top '), cTID('#Pxl'), data.y - data.radius);
desc6.putUnitDouble(cTID('Left'), cTID('#Pxl'), data.x - data.radius);
desc6.putUnitDouble(cTID('Btom'), cTID('#Pxl'), data.y + data.radius);
desc6.putUnitDouble(cTID('Rght'), cTID('#Pxl'), data.x + data.radius);
desc3.putObject(cTID('Shp '), cTID('Elps'), desc6);
var desc7 = new ActionDescriptor();
desc7.putInteger(sTID('strokeStyleVersion'), 2);
desc7.putBoolean(sTID('strokeEnabled'), true);
desc7.putBoolean(sTID('fillEnabled'), false);
desc7.putUnitDouble(sTID('strokeStyleLineWidth'), cTID('#Pxl'), data.width);
desc7.putUnitDouble(sTID('strokeStyleLineDashOffset'), cTID('#Pnt'), 0.000000);
desc7.putDouble(sTID('strokeStyleMiterLimit'), 100.000000);
desc7.putEnumerated(sTID('strokeStyleLineCapType'), sTID('strokeStyleLineCapType'), sTID('strokeStyleButtCap'));
desc7.putEnumerated(sTID('strokeStyleLineJoinType'), sTID('strokeStyleLineJoinType'), sTID('strokeStyleMiterJoin'));
desc7.putEnumerated(sTID('strokeStyleLineAlignment'), sTID('strokeStyleLineAlignment'), sTID('strokeStyleAlignOutside'));
desc7.putBoolean(sTID('strokeStyleScaleLock'), false);
desc7.putBoolean(sTID('strokeStyleStrokeAdjust'), false);
var list1 = new ActionList();
desc7.putList(sTID('strokeStyleLineDashSet'), list1);
desc7.putEnumerated(sTID('strokeStyleBlendMode'), cTID('BlnM'), cTID('Nrml'));
desc7.putUnitDouble(sTID('strokeStyleOpacity'), cTID('#Prc'), 100.000000);
var desc8 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
desc9.putDouble(cTID('Rd '), data.color[0]);
desc9.putDouble(cTID('Grn '), data.color[1]);
desc9.putDouble(cTID('Bl '), data.color[2]);
desc8.putObject(cTID('Clr '), cTID('RGBC'), desc9);
desc7.putObject(sTID('strokeStyleContent'), sTID('solidColorLayer'), desc8);
desc7.putDouble(sTID('strokeStyleResolution'), 72.000000);
desc3.putObject(sTID('strokeStyle'), sTID('strokeStyle'), desc7);
desc2.putObject(cTID('Usng'), sTID('contentLayer'), desc3);
desc2.putInteger(cTID('LyrI'), 2);
executeAction(cTID('Mk '), desc2, DialogModes.NO);
if (data.name != undefined)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(cTID("Lyr "), cTID("Ordn"), cTID("Trgt"));
desc.putReference(cTID('null'), ref);
var descName = new ActionDescriptor();
descName.putString(cTID('Nm '), data.name);
desc.putObject(cTID('T '), cTID('Lyr '), descName);
executeAction(cTID('setd'), desc, DialogModes.NO);
}
} // end of createCircle()
function linear(X, A, B, C, D)
{
var Y = (X - A) / (B - A) * (D - C) + C
return Y;
};
function cTID(s)
{
return app.charIDToTypeID(s);
}
function sTID(s)
{
return app.stringIDToTypeID(s);
}
}
app.activeDocument.suspendHistory("create circles", "main()");
其它你可能感兴趣的问题





