PageRenderTime 17ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/Frameworks/AppKit/rhino.platform/CGPath.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 215 lines | 215 code | 0 blank | 0 comment | 0 complexity | 41fc5ea3ff07e3de493fd55b3d78eeff MD5 | raw file
  1i;12;CGGeometry.ji;19;CGAffineTransform.jc;7022;
  2kCGPathElementMoveToPoint=0;
  3kCGPathElementAddLineToPoint=1;
  4kCGPathElementAddQuadCurveToPoint=2;
  5kCGPathElementAddCurveToPoint=3;
  6kCGPathElementCloseSubpath=4;
  7kCGPathElementAddArc=5;
  8kCGPathElementAddArcToPoint=6;
  9CGPathCreateMutable=function(){
 10return {count:0,start:NULL,current:NULL,elements:[]};
 11};
 12CGPathCreateMutableCopy=function(_1){
 13var _2=CGPathCreateMutable();
 14CGPathAddPath(_2,_1);
 15return _2;
 16};
 17CGPathCreateCopy=function(_3){
 18return CGPathCreateMutableCopy(_3);
 19};
 20CGPathRelease=function(_4){
 21};
 22CGPathRetain=function(_5){
 23return _5;
 24};
 25CGPathAddArc=function(_6,_7,x,y,_a,_b,_c,_d){
 26if(_7&&!(_7.a==1&&_7.b==0&&_7.c==0&&_7.d==1&&_7.tx==0&&_7.ty==0)){
 27var _e={x:x,y:y},_f={x:COS(_c),y:SIN(_c)},_10={x:COS(_b),y:SIN(_b)};
 28_f={x:_f.x*_7.a+_f.y*_7.c+_7.tx,y:_f.x*_7.b+_f.y*_7.d+_7.ty};
 29_10={x:_10.x*_7.a+_10.y*_7.c+_7.tx,y:_10.x*_7.b+_10.y*_7.d+_7.ty};
 30_e={x:_e.x*_7.a+_e.y*_7.c+_7.tx,y:_e.x*_7.b+_e.y*_7.d+_7.ty};
 31x=_e.x;
 32y=_e.y;
 33var _11=_c,_12=_b;
 34_c=ATAN2(_f.y-_7.ty,_f.x-_7.tx);
 35_b=ATAN2(_10.y-_7.ty,_10.x-_7.tx);
 36if(_c==_b&&_11!=_12){
 37if(_12>_11){
 38_c=_c-PI2;
 39}else{
 40_b=_b-PI2;
 41}
 42}
 43_a={width:_a,height:0};
 44_a={width:_a.width*_7.a+_a.height*_7.c,height:_a.width*_7.b+_a.height*_7.d};
 45_a=SQRT(_a.width*_a.width+_a.height*_a.height);
 46}
 47_6.current={x:x+_a*COS(_c),y:y+_a*SIN(_c)};
 48_6.elements[_6.count++]={type:kCGPathElementAddArc,x:x,y:y,radius:_a,startAngle:_b,endAngle:_c};
 49};
 50CGPathAddArcToPoint=function(_13,_14,x1,y1,x2,y2,_19){
 51};
 52CGPathAddCurveToPoint=function(_1a,_1b,_1c,_1d,_1e,_1f,x,y){
 53var cp1={x:_1c,y:_1d},cp2={x:_1e,y:_1f},end={x:x,y:y};
 54if(_1b){
 55cp1={x:cp1.x*_1b.a+cp1.y*_1b.c+_1b.tx,y:cp1.x*_1b.b+cp1.y*_1b.d+_1b.ty};
 56cp2={x:cp2.x*_1b.a+cp2.y*_1b.c+_1b.tx,y:cp2.x*_1b.b+cp2.y*_1b.d+_1b.ty};
 57end={x:end.x*_1b.a+end.y*_1b.c+_1b.tx,y:end.x*_1b.b+end.y*_1b.d+_1b.ty};
 58}
 59_1a.current=end;
 60_1a.elements[_1a.count++]={type:kCGPathElementAddCurveToPoint,cp1x:cp1.x,cp1y:cp1.y,cp2x:cp2.x,cp2y:cp2.y,x:end.x,y:end.y};
 61};
 62CGPathAddLines=function(_25,_26,_27,_28){
 63var i=1;
 64if(arguments["count"]==NULL){
 65var _28=_27.length;
 66}
 67if(!_25||_28<2){
 68return;
 69}
 70CGPathMoveToPoint(_25,_26,_27[0].x,_27[0].y);
 71for(;i<_28;++i){
 72CGPathAddLineToPoint(_25,_26,_27[i].x,_27[i].y);
 73}
 74};
 75CGPathAddLineToPoint=function(_2a,_2b,x,y){
 76var _2e={x:x,y:y};
 77if(_2b!=NULL){
 78_2e={x:_2e.x*_2b.a+_2e.y*_2b.c+_2b.tx,y:_2e.x*_2b.b+_2e.y*_2b.d+_2b.ty};
 79}
 80_2a.elements[_2a.count++]={type:kCGPathElementAddLineToPoint,x:_2e.x,y:_2e.y};
 81_2a.current=_2e;
 82};
 83CGPathAddPath=function(_2f,_30,_31){
 84var i=0,_33=_31.count;
 85for(;i<_33;++i){
 86var _34=_31.elements[i];
 87_2f.elements[_2f.count]={type:_34.type,x:_34.x,y:_34.y,cpx:_34.cpx,cpy:_34.cpy,radius:_34.radius,startAngle:_34.startAngle,endAngle:_34.endAngle,cp1x:_34.cp1x,cp1y:_34.cp1y,cp2x:_34.cp2x,cp2y:_34.cp2y,points:_34.points?_34.points.slice():nil};
 88_2f.count++;
 89}
 90_2f.current=_31.current;
 91};
 92CGPathAddQuadCurveToPoint=function(_35,_36,cpx,cpy,x,y){
 93var cp={x:cpx,y:cpy},end={x:x,y:y};
 94if(_36){
 95cp={x:control.x*_36.a+control.y*_36.c+_36.tx,y:control.x*_36.b+control.y*_36.d+_36.ty};
 96end={x:end.x*_36.a+end.y*_36.c+_36.tx,y:end.x*_36.b+end.y*_36.d+_36.ty};
 97}
 98_35.elements[_35.count++]={type:kCGPathElementAddQuadCurveToPoint,cpx:cp.x,cpy:cp.y,x:end.x,y:end.y};
 99_35.current=end;
100};
101CGPathAddRect=function(_3d,_3e,_3f){
102CGPathAddRects(_3d,_3e,[_3f],1);
103};
104CGPathAddRects=function(_40,_41,_42,_43){
105var i=0;
106if(arguments["count"]==NULL){
107var _43=_42.length;
108}
109for(;i<_43;++i){
110var _45=_42[i];
111CGPathMoveToPoint(_40,_41,(_45.origin.x),(_45.origin.y));
112CGPathAddLineToPoint(_40,_41,(_45.origin.x+_45.size.width),(_45.origin.y));
113CGPathAddLineToPoint(_40,_41,(_45.origin.x+_45.size.width),(_45.origin.y+_45.size.height));
114CGPathAddLineToPoint(_40,_41,(_45.origin.x),(_45.origin.y+_45.size.height));
115CGPathCloseSubpath(_40);
116}
117};
118CGPathMoveToPoint=function(_46,_47,x,y){
119var _4a={x:x,y:y},_4b=_46.count;
120if(_47!=NULL){
121_4a={x:_4a.x*_47.a+_4a.y*_47.c+_47.tx,y:_4a.x*_47.b+_4a.y*_47.d+_47.ty};
122}
123_46.start=_4a;
124_46.current=_4a;
125var _4c=_46.elements[_4b-1];
126if(_4b!=0&&_4c.type==kCGPathElementMoveToPoint){
127_4c.x=_4a.x;
128_4c.y=_4a.y;
129}else{
130_46.elements[_46.count++]={type:kCGPathElementMoveToPoint,x:_4a.x,y:_4a.y};
131}
132};
133CGPathWithEllipseInRect=function(_4d){
134var _4e=CGPathCreateMutable();
135if((_4d.size.width)==(_4d.size.height)){
136CGPathAddArc(_4e,nil,(_4d.origin.x+(_4d.size.width)/2),(_4d.origin.y+(_4d.size.height)/2),(_4d.size.width)/2,0,2*PI,YES);
137}else{
138var _4f={width:(_4d.size.width)/2,height:(_4d.size.height)/2},_50={x:(_4d.origin.x)+_4f.width,y:(_4d.origin.y)+_4f.height};
139CGPathMoveToPoint(_4e,nil,_50.x,_50.y-_4f.height);
140CGPathAddCurveToPoint(_4e,nil,_50.x+(KAPPA*_4f.width),_50.y-_4f.height,_50.x+_4f.width,_50.y-(KAPPA*_4f.height),_50.x+_4f.width,_50.y);
141CGPathAddCurveToPoint(_4e,nil,_50.x+_4f.width,_50.y+(KAPPA*_4f.height),_50.x+(KAPPA*_4f.width),_50.y+_4f.height,_50.x,_50.y+_4f.height);
142CGPathAddCurveToPoint(_4e,nil,_50.x-(KAPPA*_4f.width),_50.y+_4f.height,_50.x-_4f.width,_50.y+(KAPPA*_4f.height),_50.x-_4f.width,_50.y);
143CGPathAddCurveToPoint(_4e,nil,_50.x-_4f.width,_50.y-(KAPPA*_4f.height),_50.x-(KAPPA*_4f.width),_50.y-_4f.height,_50.x,_50.y-_4f.height);
144}
145CGPathCloseSubpath(_4e);
146return _4e;
147};
148CGPathWithRoundedRectangleInRect=function(_51,_52,_53,ne,se,sw,nw){
149var _58=CGPathCreateMutable(),_59=(_51.origin.x),_5a=(_51.origin.x+_51.size.width),_5b=(_51.origin.y),_5c=(_51.origin.y+_51.size.height);
150CGPathMoveToPoint(_58,nil,_59+_52,_5b);
151if(ne){
152CGPathAddLineToPoint(_58,nil,_5a-_52,_5b);
153CGPathAddCurveToPoint(_58,nil,_5a-_52,_5b,_5a,_5b,_5a,_5b+_52);
154}else{
155CGPathAddLineToPoint(_58,nil,_5a,_5b);
156}
157if(se){
158CGPathAddLineToPoint(_58,nil,_5a,_5c-_52);
159CGPathAddCurveToPoint(_58,nil,_5a,_5c-_52,_5a,_5c,_5a-_52,_5c);
160}else{
161CGPathAddLineToPoint(_58,nil,_5a,_5c);
162}
163if(sw){
164CGPathAddLineToPoint(_58,nil,_59+_52,_5c);
165CGPathAddCurveToPoint(_58,nil,_59+_52,_5c,_59,_5c,_59,_5c-_52);
166}else{
167CGPathAddLineToPoint(_58,nil,_59,_5c);
168}
169if(nw){
170CGPathAddLineToPoint(_58,nil,_59,_5b+_52);
171CGPathAddCurveToPoint(_58,nil,_59,_5b+_52,_59,_5b,_59+_52,_5b);
172}else{
173CGPathAddLineToPoint(_58,nil,_59,_5b);
174}
175CGPathCloseSubpath(_58);
176return _58;
177};
178CGPathCloseSubpath=function(_5d){
179var _5e=_5d.count;
180if(_5e==0||_5d.elements[_5e-1].type==kCGPathElementCloseSubpath){
181return;
182}
183_5d.elements[_5d.count++]={type:kCGPathElementCloseSubpath,points:[_5d.start]};
184};
185CGPathEqualToPath=function(_5f,_60){
186if(_5f==_60){
187return YES;
188}
189if(_5f.count!=_60.count||!(_5f.start.x==_60.start.x&&_5f.start.y==_60.start.y)||!(_5f.current.x==_60.current.x&&_5f.current.y==_60.current.y)){
190return NO;
191}
192var i=0,_62=_5f.count;
193for(;i<_62;++i){
194var _63=_5f[i],_64=_60[i];
195if(_63.type!=_64.type){
196return NO;
197}
198if((_63.type==kCGPathElementAddArc||_63.type==kCGPathElementAddArcToPoint)&&_63.radius!=_64.radius){
199return NO;
200}
201var j=_63.points.length;
202while(j--){
203if(!(_63.points[j].x==_64.points[j].x&&_63.points[j].y==_64.points[j].y)){
204return NO;
205}
206}
207}
208return YES;
209};
210CGPathGetCurrentPoint=function(_66){
211return {x:_66.current.x,y:_66.current.y};
212};
213CGPathIsEmpty=function(_67){
214return !_67||_67.count==0;
215};