Commit e5d1f0a8 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47014 954022d7-b5bf-4e40-9824-e11837661b57
parent b1716242
This diff is collapsed.
// размеры стрелок;
var lg=500, mid=300, sm=200;
//типы стрелок
var ar_arrow=0, ar_diamond=1, ar_none=2, ar_oval=3, ar_stealth=4, ar_triangle=5;
//рисуем конечную стрелку
function DrawTailEnd(type, length, width, x, y, angle, graphics)
{
var sin, cos;
sin=Math.sin(angle);
cos=Math.cos(angle);
x*=100;
y*=100;
switch(type)
{
case ar_arrow:
{
var xb, yb, xc, yc;
xb=-length;
yb=-width*0.5;
xc=xb;
yc=yb+width;
graphics._s();
graphics._m(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(x, y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics.ds();
break;
}
case ar_diamond:
{
var xd, yd;
xb=-length*0.5;
yb=-width*0.5;
xc=-length;
yc=0;
xd=xb;
yd=yb+width;
graphics._s();
graphics._m(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(x, y);
graphics._l(xd*cos-yd*sin+x, xd*sin+yd*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
case ar_none:
{
break;
}
case ar_oval:
{
EllipseN(graphics, x, y, length*0.5, width*0.5, angle);
break;
}
case ar_stealth:
{
xb=-length;
yb=-width*0.5;
xc=-length*0.5;
yc=0;
xd=xb;
yd=-yb;
graphics._s();
graphics._m(x, y);
graphics._l(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._l(xd*cos-yd*sin+x, xd*sin+yd*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
case ar_triangle:
{
xb=-length;
yb=-width*0.5;
xc=xb;
yc=-yb;
graphics._s();
graphics._m(x, y);
graphics._l(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
}
}
//рисуем начальную стрелку
function DrawHeadEnd(type, length, width, x, y, angle, graphics)
{
var sin, cos;
sin=Math.sin(angle);
cos=Math.cos(angle);
x*=100;
y*=100;
switch(type)
{
case ar_arrow:
{
var xb, yb, xc, yc;
xb=length;
yb=-width*0.5;
xc=xb;
yc=yb+width;
graphics._s();
graphics._m(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(x, y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics.ds();
break;
}
case ar_diamond:
{
var xd, yd;
xb=length*0.5;
yb=-width*0.5;
xc=length;
yc=0;
xd=xb;
yd=yb+width;
graphics._s();
graphics._m(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(x, y);
graphics._l(xd*cos-yd*sin+x, xd*sin+yd*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
case ar_none:
{
break;
}
case ar_oval:
{
Ellipse2(graphics, x, y, length*0.5, width*0.5, angle);
break;
}
case ar_stealth:
{
xb=length;
yb=-width*0.5;
xc=length*0.5;
yc=0;
xd=xb;
yd=-yb;
graphics._s();
graphics._m(x, y);
graphics._l(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._l(xd*cos-yd*sin+x, xd*sin+yd*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
case ar_triangle:
{
xb=length;
yb=-width*0.5;
xc=xb;
yc=-yb;
graphics._s();
graphics._m(x, y);
graphics._l(xb*cos-yb*sin+x, xb*sin+yb*cos+y);
graphics._l(xc*cos-yc*sin+x, xc*sin+yc*cos+y);
graphics._z();
graphics.ds();
graphics.df();
break;
}
}
}
This diff is collapsed.
function clone(obj)
{
if(obj == null || typeof(obj) != 'object')
return obj;
if(obj.constructor == Array)
{
var t=[];
for(var i=0;i< obj.length;i++)
t[i]=clone(obj[i]);
return t;
}
var temp = {};
for(var key in obj)
if(key=="Parent"||key=="DrawingDocument"||key=="Document" || key=="Container")//чтобы избежать бесконечной рекурсии копируем просто ссылки
temp[key]=obj[key];
else if(key!="DocumentContent")
temp[key] = clone(obj[key]);
return temp;
}
function cloneDC(obj)
{
if(obj == null || typeof(obj) != 'object')
return obj;
if(obj.constructor == Array)
{
var t=[];
for(var i=0;i< obj.length;i++)
t[i]=clone(obj[i]);
return t;
}
var temp = {};
for(var key in obj)
if(key=="Parent"||key=="DrawingDocument"||key=="Document"||key=="DocumentContent" || key=="Container")//чтобы избежать бесконечной рекурсии копируем просто ссылки
temp[key]=obj[key];
else
temp[key] = clone(obj[key]);
return temp;
}
\ No newline at end of file
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 2/24/12
* Time: 12:41 PM
* To change this template use File | Settings | File Templates.
*/
/*function ColorToHSV(color)
{
var max = Math.max(color.R, Math.max(color.G, color.B));
var min = Math.min(color.R, Math.min(color.G, color.B));
hue = color.GetHue();
saturation = (max == 0) ? 0 : 1d - (1d * min / max);
value = max / 255d;
}*/
function CColor1(r, g, b){
this.r = r;
this.g = g;
this.b = b;
this.darken = function(a){
return 'rgba('+ Math.round(this.r*0.9) + ', '+ Math.round(this.g*0.9) + ', '+ Math.round(this.b*0.9) + ', '+ a*0.00390625 + ')';
};
this.darkenLess = function(a){
return 'rgba('+ Math.round(this.r*0.85) + ', '+ Math.round(this.g*0.85) + ', '+ Math.round(this.b*0.85) + ', '+ a*0.00390625 + ')';
};
this.lighten = function(a){
return 'rgba('+ Math.round(this.r*1.1) + ', '+ Math.round(this.g*1.1) + ', '+ Math.round(this.b*1.1) + ', '+ a*0.00390625 + ')';
};
this.lightenLess = function(a){
return 'rgba('+ Math.round(this.r*1.15) + ', '+ Math.round(this.g*1.15) + ', '+ Math.round(this.b*1.15) + ', '+ a*0.00390625 + ')';
};
this.norm = function(a){
return 'rgba('+ this.r + ', '+ this.g + ', '+ this.b + ', '+ a*0.00390625 + ')';
};
this.none = function(){
return 'rgba('+ 255 + ', '+ 255 + ', '+ 255 + ', '+ 0 + ')';
};
}
var ArColor = new Array();
ArColor.Black = new CColor1(0, 0, 0);
ArColor.Red = new CColor1(255, 0, 0);
ArColor.Lime = new CColor1(0, 255, 0);
ArColor.Blue = new CColor1(0, 0, 255);
ArColor.SkyBlue = new CColor1(135, 206, 235);
ArColor.White = new CColor1(255, 255, 255);
ArColor.Thistle = new CColor1(216, 191, 216);
ArColor.Plum = new CColor1(221, 160, 221);
ArColor.Violet = new CColor1(238, 130, 238);
ArColor.Orchid = new CColor1(218, 112, 214);
ArColor.Fuchsia = new CColor1(255, 0, 255);
ArColor.Magenta = new CColor1(255, 0, 255);
ArColor.MediumOrchid = new CColor1(186, 85, 211);
ArColor.MediumPurple = new CColor1(147, 112, 219);
ArColor.BlueViolet = new CColor1(138, 43, 226);
ArColor.DarkViolet = new CColor1(148, 0, 211);
ArColor.DarkOrchid = new CColor1(153, 50, 204);
ArColor.DarkMagenta = new CColor1(139, 0, 139);
ArColor.Purple = new CColor1(128, 0, 128);
ArColor.Indigo = new CColor1(75, 0, 130);
ArColor.SlateBlue = new CColor1(106, 90, 205);
ArColor.DarkSlateBlue = new CColor1(72, 61, 139);
ArColor.Aqua = new CColor1(0, 255, 255);
ArColor.Cyan = new CColor1(0, 255, 255);
ArColor.LightCyan = new CColor1(224, 255, 255);
ArColor.PaleTurquoise = new CColor1(175, 238, 238);
ArColor.Aquamarine = new CColor1(127, 255, 212);
ArColor.Turquoise = new CColor1(64, 224, 208);
ArColor.MediumTurquoise = new CColor1(72, 209, 204);
ArColor.DarkTurquoise = new CColor1(0, 206, 209);
ArColor.CadetBlue = new CColor1(95, 158, 160);
ArColor.SteelBlue = new CColor1(70, 130, 180);
ArColor.LightSteelBlue = new CColor1(176, 196, 222);
ArColor.PowderBlue = new CColor1(176, 224, 230);
ArColor.LightBlue = new CColor1(173, 216, 230);
ArColor.SkyBlue = new CColor1(135, 206, 235);
ArColor.LightSkyBlue = new CColor1(135, 206, 250);
ArColor.DeepSkyBlue = new CColor1(0, 191, 255);
ArColor.DodgerBlue = new CColor1(30, 144, 255);
ArColor.CornflowerBlue = new CColor1(100, 149, 237);
ArColor.MediumSlateBlue = new CColor1(123, 104, 238);
ArColor.RoyalBlue = new CColor1(65, 105, 225);
ArColor.MediumBlue = new CColor1(0, 0, 205);
ArColor.DarkBlue = new CColor1(0, 0, 139);
ArColor.Navy = new CColor1(0, 0, 128);
ArColor.MidnightBlue = new CColor1(25, 25, 112);
ArColor.Gold = new CColor1(255, 215, 0);
ArColor.Yellow = new CColor1(255, 255, 0);
ArColor.LightYellow = new CColor1(255, 255, 224);
ArColor.LemonChiffon = new CColor1(255, 250, 205);
ArColor.LightGoldenrodYellow = new CColor1(250, 250, 210);
ArColor.PapayaWhip = new CColor1(255, 239, 213);
ArColor.Moccasin = new CColor1(255, 228, 181);
ArColor.PeachPuff = new CColor1(255, 218, 185);
ArColor.PaleGoldenrod = new CColor1(238, 232, 170);
ArColor.Khaki = new CColor1(240, 230, 140);
ArColor.DarkKhaki = new CColor1(189, 183, 107);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 3/30/12
* Time: 5:21 PM
* To change graphics template use File | Settings | File Templates.
*/
function circle(graphics, xc, yc, r)
{
graphics._s();
Arc3(graphics, xc+r, yc, r, r, 0, 2*Math.PI);
graphics._z();
graphics.ds();
graphics.df();
}
function diamond(graphics, xc, yc, d)
{
d*=0.5;
graphics._s();
graphics._m(xc, yc-d);
graphics._l(xc+d, yc);
graphics._l(xc, yc+d);
graphics._l(xc-d, yc);
graphics._z();
graphics.ds();
graphics.df();
}
function square(graphics, xc, yc, d)
{
graphics._s();
graphics._m(xc-d, yc-d);
graphics._l(xc+d, yc-d);
graphics._l(xc+d, yc+d);
graphics._l(xc-d, yc+d);
graphics._z();
graphics.ds();
graphics.df();
}
This diff is collapsed.
function HitInLine(context, px, py, x0, y0, x1, y1)
{
var tx, ty, dx, dy, d;
tx=x1-x0;
ty=y1-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.lineTo(x1+dx, y1+dy);
context.lineTo(x1-dx, y1-dy);
context.lineTo(x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3)
{
var tx, ty, dx, dy, d;
tx=x3-x0;
ty=y3-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.bezierCurveTo(x1+dx, y1+dy, x2+dx, y2+dy, x3+dx, y3+dy);
context.lineTo(x3-dx, y3-dy);
context.bezierCurveTo(x2-dx, y2-dy, x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier3(context, px, py, x0, y0, x1, y1, x2, y2)
{
var tx, ty, dx, dy, d;
tx=x2-x0;
ty=y2-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.quadraticCurveTo(x1+dx, y1+dy, x2+dx, y2+dy);
context.lineTo(x2-dx, y2-dy);
context.quadraticCurveTo(x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitToArc4(context, px, py, xc, yc, wR, hR, stAng, swAng)
{
var bx0, by0, bx1, by1, bx2, by2, bx3, by3;
var ex1, ey1, ex2, ey2;
//определяем координаты крайних точек кривой
bx0=xc+wR*Math.cos(stAng);
by0=yc+hR*Math.sin(stAng);
bx3=xc+wR*Math.cos(stAng+swAng);
by3=yc+hR*Math.sin(stAng+swAng);
//координаты двух точек на дуге через которые должна проходить кривая Безье
var A1=stAng+0.3333333*swAng, A2=stAng+0.6666667*swAng;
ex1=xc+wR*Math.cos(A1);
ey1=yc+hR*Math.sin(A1);
ex2=xc+wR*Math.cos(A2);
ey2=yc+hR*Math.sin(A2);
//вычислим две оставшиеся опорные точки кривой Безье, так чтобы она проходила через точки (ex1, ey1), (ex2, ey2)
var tx1, ty1, tx2, ty2;
tx1=27*ex1-8*bx0-bx3;
ty1=27*ey1-8*by0-by3;
tx2=27*ex2-bx0-8*bx3;
ty2=27*ey2-by0-8*by3;
var d=1/108;
bx1=(12*tx1-6*tx2)*d;
by1=(12*ty1-6*ty2)*d;
bx2=(12*tx2-6*tx1)*d;
by2=(12*ty2-6*ty1)*d;
return HitInBezier4(context, px, py, bx0, by0, bx1, by1, bx2, by2, bx3, by3);
}
function HitToArc(context, px, py, lastX, lastY, wR, hR, stAng, swAng)
{
var xc, yc;
var sin1 = Math.sin(stAng);
var cos1 = Math.cos(stAng);
var __x = cos1 / wR;
var __y = sin1 / hR;
var l = 1 / Math.sqrt(__x * __x + __y * __y);
xc = lastX - l * cos1;
yc = lastY - l * sin1;
return HitToArc4(context, px, py, xc, yc, wR, hR, stAng, swAng*0.25)||
HitToArc4(context, px, py, xc, yc, wR, hR, stAng+swAng*0.25, swAng*0.25)||
HitToArc4(context, px, py, xc, yc, wR, hR, stAng+swAng*0.5, swAng*0.25)||
HitToArc4(context, px, py, xc, yc, wR, hR, stAng+swAng*0.75, swAng*0.25);
}
\ No newline at end of file
var min_distance_joined=2;
function JoinedH(shape1, shape2)
{
var l, r, l2, r2;
l=shape1.pH+shape1.off.x;
r=l+shape1.ext.cx;
l2=shape2.pH+shape2.off.x;
r2=l2+shape2.ext.cx;
var d=l-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=l-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=r-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=r-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedV(shape1, shape2)
{
var t, b, t2, b2;
t=shape1.pV+shape1.off.y;
b=t+shape1.ext.cy;
t2=shape2.pV+shape2.off.y;
b2=t2+shape2.ext.cy;
var d=t-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=t-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=b-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=b-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedPointH(X, shape2)
{
var l2, r2;
l2=shape2.pH+shape2.off.x;
r2=l2+shape2.ext.cx;
var d=X-l2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=X-r2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
function JoinedPointV(Y, shape2)
{
var t2, b2;
t2=shape2.pV+shape2.off.y;
b2=t2+shape2.ext.cy;
var d=Y-t2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
d=Y-b2;
if(Math.abs(d)<min_distance_joined)
{
return d;
}
return 0;
}
\ No newline at end of file
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 2/24/12
* Time: 10:06 AM
* To change this template use File | Settings | File Templates.
*/
var cToRad = Math.PI/(60000*180);
var cToDeg = 1/cToRad;
function Cos(angle)
{
return Math.cos(cToRad*angle);
}
function Sin(angle)
{
return Math.sin(cToRad*angle);
}
function Tan(angle)
{
return Math.tan(cToRad*angle);
}
function ATan(x)
{
return cToDeg*Math.atan(x);
}
function ATan2(y, x)
{
return cToDeg*Math.atan2(y, x);
}
function CAt2(x, y, z)
{
return x*(Cos(ATan2(z, y)));
}
function SAt2(x, y, z)
{
return x*(Sin(ATan2(z, y)));
}
\ No newline at end of file
This diff is collapsed.
/*function PolyLine()
{
this.ArrPoint=new Array();
this.Path = new Array();
this.Separation=new Array();
this.Separation.push(0);
this.PointStorage=new Array();
this.Path=new Path(false, false, true, 0,0);
this.Counter=0;
}
PolyLine.prototype=
{
AddPoint: function(x, y)
{
this.Counter++;
this.ArrPoint.push({x: x, y:y});
if(this.Counter%8==0)
{
this.Path.cubicBezTo()
this.Counter=0;
}
},
AddSeparator: function()
{
this.Separation.push(this.ArrPoint.length);
},
ChangeLastPoint: function(x, y)
{
this.ArrPoint[this.ArrPoint.length-1]={x: x, y:y};
},
DistanceToLastPoint: function(x, y)
{
if(this.ArrPoint.length>0)
{
var dx, dy;
dx=x-this.ArrPoint[this.ArrPoint.length-1].x;
dy=y-this.ArrPoint[this.ArrPoint.length-1].y;
return Math.sqrt(dx*dx+dy*dy);
}
else
return 0;
},
Draw: function(graphics)
{
graphics.SetIntegerGrid(true);
graphics.p_width(1000);
if(this.ArrPoint.length>0)
{
graphics._m(this.ArrPoint[0].x*100, this.ArrPoint[0].y*100);
for(var i=1; i<this.ArrPoint.length; i++)
{
graphics._l(this.ArrPoint[i].x*100, this.ArrPoint[i].y*100)
}
graphics.ds();
}
},
CreateShape: function(DrawingDocument, Parent)
{
this.Separation.push(0);
var shape=new CShape(DrawingDocument, Parent);
var Xmin, Xmax, Ymin, Ymax;
Xmin=this.ArrPoint[0].x;
Ymin=this.ArrPoint[0].y;
Xmax=Xmin;
Ymax=Ymin;
for(var i=1; i<this.ArrPoint.length; i++)
{
if(Xmax<this.ArrPoint[i].x)
Xmax=this.ArrPoint[i].x;
if(Ymax<this.ArrPoint[i].y)
Ymax=this.ArrPoint[i].y;
if(Xmin>this.ArrPoint[i].x)
Xmin=this.ArrPoint[i].x;
if(Ymin>this.ArrPoint[i].y)
Ymin=this.ArrPoint[i].y;
}
var j, t, s, r;
for(i=0; i<this.Separation.length-1;i++)
{
t =this.Separation[i+1]-this.Separation[i];
s=Math.floor(t/4);
r=t%4;
for(j=0; j<s; j++)
{
}
}
}
};*/
function PolyLine()
{
this.ArrPoint=new Array();
}
PolyLine.prototype=
{
AddPoint: function(x, y)
{
this.ArrPoint.push({x: x, y:y});
},
CreateShape: function(DrawingDocument, Parent)
{
var Xmin, Xmax, Ymin, Ymax;
Xmin=this.ArrPoint[0].x;
Ymin=this.ArrPoint[0].y;
Xmax=Xmin;
Ymax=Ymin;
for(var i=1; i<this.ArrPoint.length; i++)
{
if(Xmax<this.ArrPoint[i].x)
Xmax=this.ArrPoint[i].x;
if(Ymax<this.ArrPoint[i].y)
Ymax=this.ArrPoint[i].y;
if(Xmin>this.ArrPoint[i].x)
Xmin=this.ArrPoint[i].x;
if(Ymin>this.ArrPoint[i].y)
Ymin=this.ArrPoint[i].y;
}
var geometry=new Geometry(), dx, dy, points=this.ArrPoint;
dx=this.ArrPoint[0].x-this.ArrPoint[this.ArrPoint.length-1].x;
dy=this.ArrPoint[0].y-this.ArrPoint[this.ArrPoint.length-1].y;
if(Math.sqrt(dx*dx+dy*dy)<3)
geometry.AddPathCommand(0,false, undefined, undefined, Xmax-Xmin, Ymax-Ymin);
else
geometry.AddPathCommand(0,false, 'none', undefined, Xmax-Xmin, Ymax-Ymin);
geometry.AddPathCommand(1, (points[0].x-Xmin)+'', (points[0].y-Ymin)+'');
var n=Math.floor(this.ArrPoint.length/4);
for(i=0; i<n; i++)
geometry.AddPathCommand(5, (points[i*4+1].x-Xmin)+'', (points[i*4+1].y-Ymin)+'', (points[i*4+2].x-Xmin)+'', (points[i*4+2].y-Ymin)+'', (points[i*4+3].x-Xmin)+'', (points[i*4+3].y-Ymin)+'');
n=this.ArrPoint.length-1;
for(i=this.ArrPoint.length%4; i>0;i--)
geometry.AddPathCommand(2, (points[n-(i-1)].x-Xmin)+'', (points[n-(i-1)].y-Ymin)+'');
if(Math.sqrt(dx*dx+dy*dy)<3)
geometry.AddPathCommand(6);
geometry.AddRect('l', 't', 'r', 'b');
geometry.Init(Xmax-Xmin, Ymax-Ymin);
var shape=new CShape(DrawingDocument, Parent);
shape.AddGeometry(geometry);
shape.Init(undefined, Xmin, Ymin, {x:0, y:0}, {cx: Xmax-Xmin, cy: Ymax-Ymin});
shape.AddDocumentContent();
shape.Recalculate();
return shape;
},
Draw: function(graphics)
{
graphics.SetIntegerGrid(true);
graphics.p_width(100);
if(this.ArrPoint.length>0)
{
graphics._s();
graphics._m(this.ArrPoint[0].x*100, this.ArrPoint[0].y*100);
for(var i=0; i< this.ArrPoint.length; i++)
graphics._l(this.ArrPoint[i].x*100, this.ArrPoint[i].y*100);
graphics.ds();
}
},
DistanceToLastPoint: function(x, y)
{
if(this.ArrPoint.length>0)
{
var dx, dy;
dx=x-this.ArrPoint[this.ArrPoint.length-1].x;
dy=y-this.ArrPoint[this.ArrPoint.length-1].y;
return Math.sqrt(dx*dx+dy*dy);
}
else
return 0;
},
Clear: function()
{
this.ArrPoint.length=0;
}
};
\ No newline at end of file
/**
* Created by JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 4/5/12
* Time: 11:38 AM
* To change this template use File | Settings | File Templates.
*/
function PolyLine2()
{
this.ArrPointBlock=new Array();
this.ArrPointBlock[0]= new Array();
}
PolyLine2.prototype=
{
AddPoint: function(x, y)
{
this.ArrPointBlock[this.ArrPointBlock.length-1].push({x: x, y: y});
this.LastPoint={x: x, y: y};
},
AddSeparator: function()
{
this.ArrPointBlock[this.ArrPointBlock.length]= new Array();
},
ChangeLastPoint: function(x, y)
{
this.ArrPointBlock[this.ArrPointBlock.length-1][this.ArrPointBlock[this.ArrPointBlock.length-1].length-1]={x: x, y:y};
this.LastPoint={x: x, y: y};
},
Draw: function(graphics)
{
graphics.SetIntegerGrid(true);
graphics.p_width(1000);
graphics.p_color(0, 0, 0, 255);
if(this.ArrPointBlock[0].length>0)
graphics._m(this.ArrPointBlock[0][0].x*100, this.ArrPointBlock[0][0].y*100);
for(var i=0; i<this.ArrPointBlock.length; i++)
for(var j=0; j<this.ArrPointBlock[i].length; j++)
graphics._l(this.ArrPointBlock[i][j].x*100, this.ArrPointBlock[i][j].y*100);
graphics.ds();
},
DistanceToLastPoint: function(x, y)
{
var dx, dy;
dx=x-this.LastPoint.x;
dy=y-this.LastPoint.y;
return Math.sqrt(dx*dx+dy*dy);
},
Clear: function()
{
this.ArrPointBlock.length=0;
this.ArrPointBlock[0]= new Array();
},
CreateShape: function(DrawingDocument, Parent)
{
if(this.ArrPointBlock[0].length>0)
{
var Xmin, Xmax, Ymin, Ymax;
Xmin=this.ArrPointBlock[0][0].x;
Ymin=this.ArrPointBlock[0][0].y;
Xmax=Xmin;
Ymax=Ymin;
//Находим габариты коробки
var ArrP;
for(var i=0; i<this.ArrPointBlock.length; i++)
{
ArrP=this.ArrPointBlock[i];
for(var j=0; j<ArrP.length; j++)
{
if(Xmax<ArrP[j].x)
Xmax=ArrP[j].x;
if(Ymax<ArrP[j].y)
Ymax=ArrP[j].y;
if(Xmin>ArrP[j].x)
Xmin=ArrP[j].x;
if(Ymin>ArrP[j].y)
Ymin=ArrP[j].y;
}
}
var geometry=new Geometry(), dx, dy;
dx=this.ArrPointBlock[0][0].x-this.LastPoint.x;
dy=this.ArrPointBlock[0][0].y-this.LastPoint.y;
var IsClosed=Math.sqrt(dx*dx+dy*dy)<3;
if(IsClosed)
geometry.AddPathCommand(0,false, undefined, undefined, Xmax-Xmin, Ymax-Ymin);
else
geometry.AddPathCommand(0,false, 'none', undefined, Xmax-Xmin, Ymax-Ymin);
geometry.AddPathCommand(1, (this.ArrPointBlock[0][0].x-Xmin)+'', (this.ArrPointBlock[0][0].y-Ymin)+'');
for(i=0; i<this.ArrPointBlock.length; i++)
{
ArrP=this.ArrPointBlock[i];
if(ArrP.length==1)
geometry.AddPathCommand(2, (ArrP[0].x-Xmin)+'', (ArrP[0].y-Ymin)+'');
else if(ArrP.length>1)
{
var n=Math.floor(ArrP.length/6);
for(j=0; j<n; j++)
geometry.AddPathCommand(5, (ArrP[j*6+1].x-Xmin)+'', (ArrP[j*6+1].y-Ymin)+'', (ArrP[j*6+3].x-Xmin)+'', (ArrP[j*6+3].y-Ymin)+'', (ArrP[j*6+5].x-Xmin)+'', (ArrP[j*6+5].y-Ymin)+'');
n=ArrP.length-1;
for(j=ArrP.length%6; j>0;j--)
geometry.AddPathCommand(2, (ArrP[n-(j-1)].x-Xmin)+'', (ArrP[n-(j-1)].y-Ymin)+'');
}
}
if(IsClosed)
geometry.AddPathCommand(6);
geometry.AddRect('l', 't', 'r', 'b');
geometry.Init(Xmax-Xmin, Ymax-Ymin);
var shape=new CShape(DrawingDocument, Parent);
shape.AddGeometry(geometry);
shape.Init(undefined, Xmin, Ymin, {x:0, y:0}, {cx: Xmax-Xmin, cy: Ymax-Ymin});
shape.AddDocumentContent();
shape.Recalculate();
return shape;
}
else
return null;
}
};
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment