Obj= AddPanel(500, 500);
kontur=Obj.Contour;
StartEditing(Obj);
Hole = NewContour();
Linii = NewContour();
centr = NewPoint(250, 250)
r1 = 100
r2 = 200
c1 = Hole.AddCircle(centr.x,centr.y, r1 );
c2 = Hole.AddCircle(centr.x,centr.y, r2 );
kolSectorov=64;
for (i=0;i<kolSectorov;i++)
{
Linii.Rotate(centr.x,centr.y, i*360/kolSectorov)
l=Linii.AddLine(centr.x,centr.y+r1+2 , centr.x, centr.y+r1)
l=Linii.AddLine(centr.x,centr.y+r2+4 , centr.x, centr.y+r2)
}
k = Linii.Count;
//alert('количество Элементов: '+k)
k = (k)/4;
//alert('количество ДУГ по 6 точек: '+k)
//for (i=0;i<k;i++) {alert('Нарисовали дугу '+i)}
// Obj.Build();
h2= NewContour();
for (i=0;i<k;i++)
{
//StartEditing(Obj); //if (i==1)
{
//n=i;
//alert(' Первый элемент первого цикла: '+n)
}
//else
n=(i)*4;
// alert(' Первый элемент '+i+'го цикла: '+n)
if (i==k-1)
{
n1=n;
n2=n+1;
n3=n+2;
n4=n+3;
n5=0;
n6=1;
}
else if( i==k)
{
n1=n;
n2=n+1;
n3=0;
n4=1;
n5=2;
n6=3;
}
else
{
n1=n;
n2=n+1;
n3=n+2;
n4=n+3;
n5=n+4;
n6=n+5;
}
// alert(' n1 = '+n1+'. n2 = '+n2+' n3 = '+n3+'. n4 = '+n4+ '. n5 = '+ n5 +'. n6 = '+ n6)
p1 = NewPoint(Linii[n2].ClosestPoint(centr).x, Linii[n1].ClosestPoint(centr).y);
//alert(Linii[n2].ClosestPoint(centr).x);
p2 = NewPoint(Linii[n4].ClosestPoint(centr).x, Linii[n3].ClosestPoint(centr).y);
//p3 = NewPoint(Linii[n6].ClosestPoint(centr).x, Linii[n5].ClosestPoint(centr).y);
h2.AddCircle(p1.x, p1.y, 2)
h2.AddCircle(p2.x, p2.y, 4)
// h2.AddCircle(p3.x, p3.y, 6)
//h2.AddCircle(p2.x, p2.y, 10)
// h2.AddArc3(p1, p2, p3);
//alert(p1.x+' -- '+p1.y+'\n'+p2.x+' -- '+p2.y+'\n'+p3.x+' -- '+p3.y+'\n')
//Obj.Contour.Subtraction(h2);
//Obj.Build();
//h2.AddLine(p1.x,p1.y, p3.x,p3.y);
// alert('Нарисовали дугу '+i)
}
k = h2.Count;
//alert('количество окружностей = '+k)
el = NewContour();
x2= h2[0].Center.x;
y2=h2[0].Center.y;
for (i=0;i<k;i++)
{
p2 = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p2.x<x2) {x2=p2.x; y2=p2.y;}
}
p2L=NewPoint(x2,y2);
p_L_Elipsa=p2L;
x1= h2[1].Center.x;
y1=h2[1].Center.y;
for (i=0;i<k;i++)
{
p1L = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p1L.x<x1 & p1L.x!=p2L.x & p1L.y<p2L.y) {x1=p1L.x; y1=p1L.y;}
}
p1L=NewPoint(x1,y1);
p3L=NewPoint(x1,p2L.y+(p2L.y-p1L.y));
//arc1 = el.AddArc3(p1, p2, p3); // АРК Левый
x2= h2[2].Center.x;
y2=h2[2].Center.y;
for (i=0;i<k;i++)
{
p2V = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p2V.y<y2) {x2=p2V.x; y2=p2V.y;}
}
p2V=NewPoint(x2,y2);
p_V_Elipsa=p2V;
x1= h2[3].Center.x;
y1=h2[3].Center.y;
for (i=0;i<k;i++)
{
p1V = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p1V.y<y1 & p1V.y!=p2V.y & p1V.x<p2V.x) {x1=p1V.x; y1=p1V.y;}
}
p1V=NewPoint(x1,y1);
p3V=NewPoint(p2V.x+(p2V.x-p1V.x),y1);
//arc2 = el.AddArc3(p1, p2, p3); // АРК Верхний
kDug = (k/4)/2-1;
//alert(kDug)
x_ur=p3L.x;
y_ur=p3L.y;
for (d=0;d<kDug;d++)
{
p1=NewPoint(x_ur,y_ur);
x2=p_V_Elipsa.x;
y2=p_V_Elipsa.y;
for (i=0;i<k;i++)
{
p2 = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p2.x<x2 & p2.x>p1.x & p2.y>p1.y) {x2=p2.x; y2=p2.y;}
}
p2=NewPoint(x2,y2);
x2=p_V_Elipsa.x;
y2=p_V_Elipsa.y;
for (i=0;i<k;i++)
{
p3 = NewPoint(h2[i].Center.x,h2[i].Center.y);
if (p3.x<x2 & p3.x>p2.x & p3.y>p2.y) {x2=p3.x; y2=p3.y;}
}
p3=NewPoint(x2,y2);
// alert(p1.x+ ' --- '+p1.y + '\n'+ p2.x+ ' --- '+p2.y + '\n'+p3.x+ ' --- '+p3.y )
el.AddArc3(p1, p2, p3);
x_ur=p3.x;
y_ur=p3.y;
}
el.Symmetry(p_V_Elipsa.x, 0, p_V_Elipsa.x, 1, true);
arc2 = el.AddArc3(p1V, p2V, p3V); // АРК Верхний
el.Symmetry(0,p_L_Elipsa.y, 1, p_L_Elipsa.y, true);
arc1 = el.AddArc3(p1L, p2L, p3L); // АРК Левый
p1P = NewPoint(p1L.x+(p_V_Elipsa.x-p1L.x)*2, p1L.y)
p2P = NewPoint(p2L.x+(p_V_Elipsa.x-p2L.x)*2, p2L.y)
p3P = NewPoint(p3L.x+(p_V_Elipsa.x-p3L.x)*2, p3L.y)
arc1 = el.AddArc3(p1P, p2P, p3P); // АРК Правый
Obj.Contour.Subtraction(el);
Obj.Build();
[свернуть]