/Frameworks/AppKit/rhino.platform/CGContext.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 680 lines · 680 code · 0 blank · 0 comment · 0 complexity · bba763f062dd2491225f26ab36777526 MD5 · raw file

  1. i;12;CGGeometry.ji;19;CGAffineTransform.ji;8;CGPath.jc;20322;
  2. kCGLineCapButt=0;
  3. kCGLineCapRound=1;
  4. kCGLineCapSquare=2;
  5. kCGLineJoinMiter=0;
  6. kCGLineJoinRound=1;
  7. kCGLineJoinBevel=2;
  8. kCGPathFill=0;
  9. kCGPathEOFill=1;
  10. kCGPathStroke=2;
  11. kCGPathFillStroke=3;
  12. kCGPathEOFillStroke=4;
  13. kCGBlendModeNormal=0;
  14. kCGBlendModeMultiply=1;
  15. kCGBlendModeScreen=2;
  16. kCGBlendModeOverlay=3;
  17. kCGBlendModeDarken=4;
  18. kCGBlendModeLighten=5;
  19. kCGBlendModeColorDodge=6;
  20. kCGBlendModeColorBurn=7;
  21. kCGBlendModeSoftLight=8;
  22. kCGBlendModeHardLight=9;
  23. kCGBlendModeDifference=10;
  24. kCGBlendModeExclusion=11;
  25. kCGBlendModeHue=12;
  26. kCGBlendModeSaturation=13;
  27. kCGBlendModeColor=14;
  28. kCGBlendModeLuminosity=15;
  29. kCGBlendModeClear=16;
  30. kCGBlendModeCopy=17;
  31. kCGBlendModeSourceIn=18;
  32. kCGBlendModeSourceOut=19;
  33. kCGBlendModeSourceAtop=20;
  34. kCGBlendModeDestinationOver=21;
  35. kCGBlendModeDestinationIn=22;
  36. kCGBlendModeDestinationOut=23;
  37. kCGBlendModeDestinationAtop=24;
  38. kCGBlendModeXOR=25;
  39. kCGBlendModePlusDarker=26;
  40. kCGBlendModePlusLighter=27;
  41. CGContextRelease=function(){
  42. };
  43. CGContextRetain=function(_1){
  44. return _1;
  45. };
  46. if(!CPFeatureIsCompatible(CPHTMLCanvasFeature)){
  47. CGGStateCreate=function(){
  48. return {alpha:1,strokeStyle:"#000",fillStyle:"#ccc",lineWidth:1,lineJoin:kCGLineJoinMiter,lineCap:kCGLineCapButt,miterLimit:10,globalAlpha:1,blendMode:kCGBlendModeNormal,shadowOffset:{width:0,height:0},shadowBlur:0,shadowColor:NULL,CTM:{a:1,b:0,c:0,d:1,tx:0,ty:0}};
  49. };
  50. CGGStateCreateCopy=function(_2){
  51. return {alpha:_2.alpha,strokeStyle:_2.strokeStyle,fillStyle:_2.fillStyle,lineWidth:_2.lineWidth,lineJoin:_2.lineJoin,lineCap:_2.lineCap,miterLimit:_2.miterLimit,globalAlpha:_2.globalAlpha,blendMode:_2.blendMode,shadowOffset:_2.shadowOffset,shadowBlur:_2.shadowBlur,shadowColor:_2.shadowColor,CTM:{a:_2.CTM.a,b:_2.CTM.b,c:_2.CTM.c,d:_2.CTM.d,tx:_2.CTM.tx,ty:_2.CTM.ty}};
  52. };
  53. CGBitmapGraphicsContextCreate=function(){
  54. return {DOMElement:document.createElement("div"),path:NULL,gState:CGGStateCreate(),gStateStack:[]};
  55. };
  56. CGContextSaveGState=function(_3){
  57. _3.gStateStack.push(CGGStateCreateCopy(_3.gState));
  58. };
  59. CGContextRestoreGState=function(_4){
  60. _4.gState=_4.gStateStack.pop();
  61. };
  62. CGContextSetLineCap=function(_5,_6){
  63. _5.gState.lineCap=_6;
  64. };
  65. CGContextSetLineJoin=function(_7,_8){
  66. _7.gState.lineJoin=_8;
  67. };
  68. CGContextSetLineWidth=function(_9,_a){
  69. _9.gState.lineWidth=_a;
  70. };
  71. CGContextSetMiterLimit=function(_b,_c){
  72. _b.gState.miterLimit=_c;
  73. };
  74. CGContextSetBlendMode=function(_d,_e){
  75. _d.gState.blendMode=_e;
  76. };
  77. CGContextAddArc=function(_f,x,y,_12,_13,_14,_15){
  78. CGPathAddArc(_f.path,_f.gState.CTM,x,y,_12,_13,_14,_15);
  79. };
  80. CGContextAddArcToPoint=function(_16,x1,y1,x2,y2,_1b){
  81. CGPathAddArcToPoint(_16.path,_16.gState.CTM,x1,y1,x2,y2,_1b);
  82. };
  83. CGContextAddCurveToPoint=function(_1c,_1d,_1e,_1f,_20,x,y){
  84. CGPathAddCurveToPoint(_1c.path,_1c.gState.CTM,_1d,_1e,_1f,_20,x,y);
  85. };
  86. CGContextAddLines=function(_23,_24,_25){
  87. CGPathAddLines(_23.path,_23.gState.CTM,_24,_25);
  88. };
  89. CGContextAddLineToPoint=function(_26,x,y){
  90. CGPathAddLineToPoint(_26.path,_26.gState.CTM,x,y);
  91. };
  92. CGContextAddPath=function(_29,_2a){
  93. if(!_29||CGPathIsEmpty(_2a)){
  94. return;
  95. }
  96. if(!_29.path){
  97. _29.path=CGPathCreateMutable();
  98. }
  99. CGPathAddPath(_29.path,_29.gState.CTM,_2a);
  100. };
  101. CGContextAddQuadCurveToPoint=function(_2b,cpx,cpy,x,y){
  102. CGPathAddQuadCurveToPoint(_2b.path,_2b.gState.CTM,cpx,cpy,x,y);
  103. };
  104. CGContextAddRect=function(_30,_31){
  105. CGPathAddRect(_30.path,_30.gState.CTM,_31);
  106. };
  107. CGContextAddRects=function(_32,_33,_34){
  108. CGPathAddRects(_32.path,_32.gState.CTM,_33,_34);
  109. };
  110. CGContextBeginPath=function(_35){
  111. _35.path=CGPathCreateMutable();
  112. };
  113. CGContextClosePath=function(_36){
  114. CGPathCloseSubpath(_36.path);
  115. };
  116. CGContextMoveToPoint=function(_37,x,y){
  117. if(!_37.path){
  118. _37.path=CGPathCreateMutable();
  119. }
  120. CGPathMoveToPoint(_37.path,_37.gState.CTM,x,y);
  121. };
  122. CGContextFillRect=function(_3a,_3b){
  123. CGContextFillRects(_3a,[_3b],1);
  124. };
  125. CGContextFillRects=function(_3c,_3d,_3e){
  126. if(arguments[2]===undefined){
  127. var _3e=_3d.length;
  128. }
  129. CGContextBeginPath(_3c);
  130. CGContextAddRects(_3c,_3d,_3e);
  131. CGContextClosePath(_3c);
  132. CGContextDrawPath(_3c,kCGPathFill);
  133. };
  134. CGContextStrokeRect=function(_3f,_40){
  135. CGContextBeginPath(_3f);
  136. CGContextAddRect(_3f,_40);
  137. CGContextClosePath(_3f);
  138. CGContextDrawPath(_3f,kCGPathStroke);
  139. };
  140. CGContextStrokeRectWithWidth=function(_41,_42,_43){
  141. CGContextSaveGState(_41);
  142. CGContextSetLineWidth(_41,_43);
  143. CGContextStrokeRect(_41,_42);
  144. CGContextRestoreGState(_41);
  145. };
  146. CGContextConcatCTM=function(_44,_45){
  147. var CTM=_44.gState.CTM;
  148. var tx=CTM.tx*_45.a+CTM.ty*_45.c+_45.tx;
  149. CTM.ty=CTM.tx*_45.b+CTM.ty*_45.d+_45.ty;
  150. CTM.tx=tx;
  151. var a=CTM.a*_45.a+CTM.b*_45.c,b=CTM.a*_45.b+CTM.b*_45.d,c=CTM.c*_45.a+CTM.d*_45.c;
  152. CTM.d=CTM.c*_45.b+CTM.d*_45.d;
  153. CTM.a=a;
  154. CTM.b=b;
  155. CTM.c=c;
  156. };
  157. CGContextGetCTM=function(_4b){
  158. return _4b.gState.CTM;
  159. };
  160. CGContextRotateCTM=function(_4c,_4d){
  161. var _4e=_4c.gState;
  162. _4e.CTM=CGAffineTransformRotate(_4e.CTM,_4d);
  163. };
  164. CGContextScaleCTM=function(_4f,sx,sy){
  165. var _52=_4f.gState;
  166. _52.CTM={a:_52.CTM.a*sx,b:_52.CTM.b*sx,c:_52.CTM.c*sy,d:_52.CTM.d*sy,tx:_52.CTM.tx,ty:_52.CTM.ty};
  167. };
  168. CGContextTranslateCTM=function(_53,tx,ty){
  169. var _56=_53.gState;
  170. _56.CTM={a:_56.CTM.a,b:_56.CTM.b,c:_56.CTM.c,d:_56.CTM.d,tx:_56.CTM.tx+_56.CTM.a*tx+_56.CTM.c*ty,ty:_56.CTM.ty+_56.CTM.b*tx+_56.CTM.d*ty};
  171. };
  172. CGContextSetShadow=function(_57,_58,_59){
  173. var _5a=_57.gState;
  174. _5a.shadowOffset={width:_58.width,height:_58.height};
  175. _5a.shadowBlur=_59;
  176. _5a.shadowColor=objj_msgSend(CPColor,"shadowColor");
  177. };
  178. CGContextSetShadowWithColor=function(_5b,_5c,_5d,_5e){
  179. var _5f=_5b.gState;
  180. _5f.shadowOffset={width:_5c.width,height:_5c.height};
  181. _5f.shadowBlur=_5d;
  182. _5f.shadowColor=_5e;
  183. };
  184. CGContextSetAlpha=function(_60,_61){
  185. _60.gState.alpha=MAX(MIN(_61,1),0);
  186. };
  187. }
  188. CGContextEOFillPath=function(_62){
  189. CGContextDrawPath(_62,kCGPathEOFill);
  190. };
  191. CGContextFillPath=function(_63){
  192. CGContextDrawPath(_63,kCGPathFill);
  193. };
  194. var _64=4*((SQRT2-1)/3);
  195. CGContextAddEllipseInRect=function(_65,_66){
  196. CGContextAddPath(_65,CGPathWithEllipseInRect(_66));
  197. };
  198. CGContextFillEllipseInRect=function(_67,_68){
  199. CGContextBeginPath(_67);
  200. CGContextAddEllipseInRect(_67,_68);
  201. CGContextClosePath(_67);
  202. CGContextFillPath(_67);
  203. };
  204. CGContextStrokeEllipseInRect=function(_69,_6a){
  205. CGContextBeginPath(_69);
  206. CGContextAddEllipseInRect(_69,_6a);
  207. CGContextClosePath(_69);
  208. CGContextStrokePath(_69);
  209. };
  210. CGContextStrokePath=function(_6b){
  211. CGContextDrawPath(_6b,kCGPathStroke);
  212. };
  213. CGContextStrokeLineSegments=function(_6c,_6d,_6e){
  214. var i=0;
  215. if(arguments["count"]==NULL){
  216. var _6e=_6d.length;
  217. }
  218. CGContextBeginPath(_6c);
  219. for(;i<_6e;i+=2){
  220. CGContextMoveToPoint(_6c,_6d[i].x,_6d[i].y);
  221. CGContextAddLineToPoint(_6c,_6d[i+1].x,_6d[i+1].y);
  222. }
  223. CGContextStrokePath(_6c);
  224. };
  225. CGContextSetFillColor=function(_70,_71){
  226. if(_71){
  227. _70.gState.fillStyle=objj_msgSend(_71,"cssString");
  228. }
  229. };
  230. CGContextSetStrokeColor=function(_72,_73){
  231. if(_73){
  232. _72.gState.strokeStyle=objj_msgSend(_73,"cssString");
  233. }
  234. };
  235. CGContextFillRoundedRectangleInRect=function(_74,_75,_76,ne,se,sw,nw){
  236. CGContextAddPath(_74,CGPathWithRoundedRectangleInRect(_75,_76,_76,ne,se,sw,nw));
  237. CGContextFillPath(_74);
  238. };
  239. CGContextStrokeRoundedRectangleInRect=function(_7b,_7c,_7d,ne,se,sw,nw){
  240. CGContextAddPath(_7b,CGPathWithRoundedRectangleInRect(_7c,_7d,_7d,ne,se,sw,nw));
  241. CGContextStrokePath(_7b);
  242. };
  243. if(CPFeatureIsCompatible(CPHTMLCanvasFeature)){
  244. var _82=["butt","round","square"],_83=["miter","round","bevel"],_84=["source-over","source-over","source-over","source-over","darker","lighter","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","copy","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","xor","source-over","source-over"];
  245. CGContextSaveGState=function(_85){
  246. _85.save();
  247. };
  248. CGContextRestoreGState=function(_86){
  249. _86.restore();
  250. };
  251. CGContextSetLineCap=function(_87,_88){
  252. _87.lineCap=_82[_88];
  253. };
  254. CGContextSetLineJoin=function(_89,_8a){
  255. _89.lineJoin=_83[_8a];
  256. };
  257. CGContextSetLineWidth=function(_8b,_8c){
  258. _8b.lineWidth=_8c;
  259. };
  260. CGContextSetMiterLimit=function(_8d,_8e){
  261. _8d.miterLimit=_8e;
  262. };
  263. CGContextSetBlendMode=function(_8f,_90){
  264. _8f.globalCompositeOperation=_84[_90];
  265. };
  266. CGContextAddArc=function(_91,x,y,_94,_95,_96,_97){
  267. _91.arc(x,y,_94,_95,_96,!_97);
  268. };
  269. CGContextAddArcToPoint=function(_98,x1,y1,x2,y2,_9d){
  270. _98.arcTo(x1,y1,x2,y2,_9d);
  271. };
  272. CGContextAddCurveToPoint=function(_9e,_9f,_a0,_a1,_a2,x,y){
  273. _9e.bezierCurveTo(_9f,_a0,_a1,_a2,x,y);
  274. };
  275. CGContextAddLineToPoint=function(_a5,x,y){
  276. _a5.lineTo(x,y);
  277. };
  278. CGContextAddPath=function(_a8,_a9){
  279. if(!_a8||CGPathIsEmpty(_a9)){
  280. return;
  281. }
  282. var _aa=_a9.elements,i=0,_ac=_a9.count;
  283. for(;i<_ac;++i){
  284. var _ad=_aa[i],_ae=_ad.type;
  285. switch(_ae){
  286. case kCGPathElementMoveToPoint:
  287. _a8.moveTo(_ad.x,_ad.y);
  288. break;
  289. case kCGPathElementAddLineToPoint:
  290. _a8.lineTo(_ad.x,_ad.y);
  291. break;
  292. case kCGPathElementAddQuadCurveToPoint:
  293. _a8.quadraticCurveTo(_ad.cpx,_ad.cpy,_ad.x,_ad.y);
  294. break;
  295. case kCGPathElementAddCurveToPoint:
  296. _a8.bezierCurveTo(_ad.cp1x,_ad.cp1y,_ad.cp2x,_ad.cp2y,_ad.x,_ad.y);
  297. break;
  298. case kCGPathElementCloseSubpath:
  299. _a8.closePath();
  300. break;
  301. case kCGPathElementAddArc:
  302. _a8.arc(_ad.x,_ad.y,_ad.radius,_ad.startAngle,_ad.endAngle,_ad.clockwise);
  303. break;
  304. case kCGPathElementAddArcTo:
  305. break;
  306. }
  307. }
  308. };
  309. CGContextAddRect=function(_af,_b0){
  310. _af.rect((_b0.origin.x),(_b0.origin.y),(_b0.size.width),(_b0.size.height));
  311. };
  312. CGContextAddRects=function(_b1,_b2,_b3){
  313. var i=0;
  314. if(arguments["count"]==NULL){
  315. var _b3=_b2.length;
  316. }
  317. for(;i<_b3;++i){
  318. var _b5=_b2[i];
  319. _b1.rect((_b5.origin.x),(_b5.origin.y),(_b5.size.width),(_b5.size.height));
  320. }
  321. };
  322. CGContextBeginPath=function(_b6){
  323. _b6.beginPath();
  324. };
  325. CGContextClosePath=function(_b7){
  326. _b7.closePath();
  327. };
  328. CGContextMoveToPoint=function(_b8,x,y){
  329. _b8.moveTo(x,y);
  330. };
  331. CGContextClearRect=function(_bb,_bc){
  332. _bb.clearRect((_bc.origin.x),(_bc.origin.y),(_bc.size.width),(_bc.size.height));
  333. };
  334. CGContextDrawPath=function(_bd,_be){
  335. if(_be==kCGPathFill||_be==kCGPathFillStroke){
  336. _bd.fill();
  337. }else{
  338. if(_be==kCGPathEOFill||_be==kCGPathEOFillStroke){
  339. alert("not implemented!!!");
  340. }
  341. }
  342. if(_be==kCGPathStroke||_be==kCGPathFillStroke||_be==kCGPathEOFillStroke){
  343. _bd.stroke();
  344. }
  345. };
  346. CGContextFillRect=function(_bf,_c0){
  347. _bf.fillRect((_c0.origin.x),(_c0.origin.y),(_c0.size.width),(_c0.size.height));
  348. };
  349. CGContextFillRects=function(_c1,_c2,_c3){
  350. var i=0;
  351. if(arguments["count"]==NULL){
  352. var _c3=_c2.length;
  353. }
  354. for(;i<_c3;++i){
  355. var _c5=_c2[i];
  356. _c1.fillRect((_c5.origin.x),(_c5.origin.y),(_c5.size.width),(_c5.size.height));
  357. }
  358. };
  359. CGContextStrokeRect=function(_c6,_c7){
  360. _c6.strokeRect((_c7.origin.x),(_c7.origin.y),(_c7.size.width),(_c7.size.height));
  361. };
  362. CGContextClip=function(_c8){
  363. _c8.clip();
  364. };
  365. CGContextClipToRect=function(_c9,_ca){
  366. _c9.beginPath();
  367. _c9.rect((_ca.origin.x),(_ca.origin.y),(_ca.size.width),(_ca.size.height));
  368. _c9.closePath();
  369. _c9.clip();
  370. };
  371. CGContextClipToRects=function(_cb,_cc,_cd){
  372. if(arguments["count"]==NULL){
  373. var _cd=_cc.length;
  374. }
  375. _cb.beginPath();
  376. CGContextAddRects(_cb,_cc,_cd);
  377. _cb.clip();
  378. };
  379. CGContextSetAlpha=function(_ce,_cf){
  380. _ce.globalAlpha=_cf;
  381. };
  382. CGContextSetFillColor=function(_d0,_d1){
  383. _d0.fillStyle=objj_msgSend(_d1,"cssString");
  384. };
  385. CGContextSetStrokeColor=function(_d2,_d3){
  386. _d2.strokeStyle=objj_msgSend(_d3,"cssString");
  387. };
  388. CGContextSetShadow=function(_d4,_d5,_d6){
  389. _d4.shadowOffsetX=_d5.width;
  390. _d4.shadowOffsetY=_d5.height;
  391. _d4.shadowBlur=_d6;
  392. };
  393. CGContextSetShadowWithColor=function(_d7,_d8,_d9,_da){
  394. _d7.shadowOffsetX=_d8.width;
  395. _d7.shadowOffsetY=_d8.height;
  396. _d7.shadowBlur=_d9;
  397. _d7.shadowColor=objj_msgSend(_da,"cssString");
  398. };
  399. CGContextRotateCTM=function(_db,_dc){
  400. _db.rotate(_dc);
  401. };
  402. CGContextScaleCTM=function(_dd,sx,sy){
  403. _dd.scale(sx,sy);
  404. };
  405. CGContextTranslateCTM=function(_e0,tx,ty){
  406. _e0.translate(tx,ty);
  407. };
  408. eigen=function(_e3){
  409. alert("IMPLEMENT ME!");
  410. };
  411. if(CPFeatureIsCompatible(CPJavaScriptCanvasTransformFeature)){
  412. CGContextConcatCTM=function(_e4,_e5){
  413. _e4.transform(_e5.a,_e5.b,_e5.c,_e5.d,_e5.tx,_e5.ty);
  414. };
  415. }else{
  416. CGContextConcatCTM=function(_e6,_e7){
  417. var a=_e7.a,b=_e7.b,c=_e7.c,d=_e7.d,tx=_e7.tx,ty=_e7.ty,sx=1,sy=1,a1=0,a2=0;
  418. if(b==0&&c==0){
  419. sx=a;
  420. sy=d;
  421. }else{
  422. if(a*b==-c*d){
  423. var _f2=(a*d<0||b*c>0)?-1:1,a2=(ATAN2(b,d)+ATAN2(-_f2*c,_f2*a))/2,cos=COS(a2),sin=SIN(a2);
  424. if(cos==0){
  425. sx=-c/sin;
  426. sy=b/sin;
  427. }else{
  428. if(sin==0){
  429. sx=a/cos;
  430. sy=d/cos;
  431. }else{
  432. abs_cos=ABS(cos);
  433. abs_sin=ABS(sin);
  434. sx=(abs_cos*a/cos+abs_sin*-c/sin)/(abs_cos+abs_sin);
  435. sy=(abs_cos*d/cos+abs_sin*b/sin)/(abs_cos+abs_sin);
  436. }
  437. }
  438. }else{
  439. if(a*c==-b*d){
  440. var _f2=(a*d<0||b*c>0)?-1:1;
  441. a1=(Math.atan2(_f2*b,_f2*a)+Math.atan2(-c,d))/2,cos=COS(a1),sin=SIN(a1);
  442. if(cos==0){
  443. sx=b/sin;
  444. sy=-c/sin;
  445. }else{
  446. if(sin==0){
  447. sx=a/cos;
  448. sy=d/cos;
  449. }else{
  450. abs_cos=ABS(cos);
  451. abs_sin=ABS(sin);
  452. sx=(abs_cos*a/cos+abs_sin*b/sin)/(abs_cos+abs_sin);
  453. sy=(abs_cos*d/cos+abs_sin*-c/sin)/(abs_cos+abs_sin);
  454. }
  455. }
  456. }else{
  457. var _f5=CGAffineTransformMake(a,c,b,d,0,0),u=eigen(CGAffineTransformConcat(_e7,_f5)),v=eigen(CGAffineTransformConcat(_f5,_e7)),U=CGAffineTransformMake(u.vector_1.x,u.vector_2.x,u.vector_1.y,u.vector_2.y,0,0),VT=CGAffineTransformMake(v.vector_1.x,v.vector_1.y,v.vector_2.x,v.vector_2.y,0,0),S=CGAffineTransformConcat(CGAffineTransformConcat(CGAffineTransformInvert(U),_e7),CGAffineTransformInvert(VT));
  458. a=VT.a;
  459. b=VT.b;
  460. c=VT.c;
  461. d=VT.d;
  462. var _f2=(a*d<0||b*c>0)?-1:1,a2=(ATAN2(b,d)+ATAN2(-_f2*c,_f2*a))/2,cos=COS(a2),sin=SIN(a2);
  463. if(cos==0){
  464. sx=-c/sin;
  465. sy=b/sin;
  466. }else{
  467. if(sin==0){
  468. sx=a/cos;
  469. sy=d/cos;
  470. }else{
  471. abs_cos=ABS(cos);
  472. abs_sin=ABS(sin);
  473. sx=(abs_cos*a/cos+abs_sin*-c/sin)/(abs_cos+abs_sin);
  474. sy=(abs_cos*d/cos+abs_sin*b/sin)/(abs_cos+abs_sin);
  475. }
  476. }
  477. S.a*=sx;
  478. S.d*=sy;
  479. a=U.a;
  480. b=U.b;
  481. c=U.c;
  482. d=U.d;
  483. var _f2=(a*d<0||b*c>0)?-1:1;
  484. a1=(Math.atan2(_f2*b,_f2*a)+Math.atan2(-c,d))/2,cos=COS(a1),sin=SIN(a1);
  485. if(cos==0){
  486. sx=b/sin;
  487. sy=-c/sin;
  488. }else{
  489. if(sin==0){
  490. sx=a/cos;
  491. sy=d/cos;
  492. }else{
  493. abs_cos=ABS(cos);
  494. abs_sin=ABS(sin);
  495. sx=(abs_cos*a/cos+abs_sin*b/sin)/(abs_cos+abs_sin);
  496. sy=(abs_cos*d/cos+abs_sin*-c/sin)/(abs_cos+abs_sin);
  497. }
  498. }
  499. sx=S.a*sx;
  500. sy=S.d*sy;
  501. }
  502. }
  503. }
  504. if(tx!=0||ty!=0){
  505. CGContextTranslateCTM(_e6,tx,ty);
  506. }
  507. if(a1!=0){
  508. CGContextRotateCTM(_e6,a1);
  509. }
  510. if(sx!=1||sy!=1){
  511. CGContextScaleCTM(_e6,sx,sy);
  512. }
  513. if(a2!=0){
  514. CGContextRotateCTM(_e6,a2);
  515. }
  516. };
  517. }
  518. CGContextDrawImage=function(_fb,_fc,_fd){
  519. _fb.drawImage(_fd._image,(_fc.origin.x),(_fc.origin.y),(_fc.size.width),(_fc.size.height));
  520. };
  521. to_string=function(_fe){
  522. return "rgba("+ROUND(_fe.components[0]*255)+", "+ROUND(_fe.components[1]*255)+", "+ROUND(255*_fe.components[2])+", "+_fe.components[3]+")";
  523. };
  524. CGContextDrawLinearGradient=function(_ff,_100,_101,_102,_103){
  525. var _104=_100.colors,_105=_104.length,_106=_ff.createLinearGradient(_101.x,_101.y,_102.x,_102.y);
  526. while(_105--){
  527. _106.addColorStop(_100.locations[_105],to_string(_104[_105]));
  528. }
  529. _ff.fillStyle=_106;
  530. _ff.fill();
  531. };
  532. CGBitmapGraphicsContextCreate=function(){
  533. var _107=document.createElement("canvas"),_108=_107.getContext("2d");
  534. _108.DOMElement=_107;
  535. return _108;
  536. };
  537. }else{
  538. if(CPFeatureIsCompatible(CPVMLFeature)){
  539. var _109=["f","t"],_10a=["flat","round","square"],_10b=["miter","round","bevel"],_10c=[" m "," l ","qb"," c "," x ",[" at "," wa "]];
  540. var _10d=CGBitmapGraphicsContextCreate;
  541. CGBitmapGraphicsContextCreate=function(){
  542. document.namespaces.add("cg_vml_","urn:schemas-microsoft-com:vml");
  543. document.createStyleSheet().cssText="cg_vml_\\:*{behavior:url(#default#VML)}";
  544. CGBitmapGraphicsContextCreate=_10d;
  545. return _10d();
  546. };
  547. CGContextClearRect=function(_10e,_10f){
  548. if(_10e.buffer!=nil){
  549. _10e.buffer="";
  550. }else{
  551. _10e.DOMElement.innerHTML="";
  552. }
  553. _10e.path=NULL;
  554. };
  555. var W=10,H=10,Z=10,Z_2=Z/2;
  556. CGContextDrawImage=function(_114,_115,_116){
  557. var _117="";
  558. if(_116.buffer!=nil){
  559. _117=_116.buffer;
  560. }else{
  561. var ctm=_114.gState.CTM,_119=CGPointApplyAffineTransform(_115.origin,ctm),_11a=ctm.a==ctm.d&&ctm.b==-ctm.c,vml=["<cg_vml_:group coordsize=\"1,1\" coordorigin=\"0,0\" style=\"width:1;height:1;position:absolute"];
  562. var _11c=CGRectApplyAffineTransform(_115,ctm);
  563. vml.push(";padding:0 ",ROUND((_11c.origin.x+_11c.size.width)),"px ",ROUND((_11c.origin.y+_11c.size.height)),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(","M11='",ctm.a,"',M12='",ctm.c,"',M21='",ctm.b,"',M22='",ctm.d,"',","Dx='",ROUND(_119.x),"', Dy='",ROUND(_119.y),"', sizingmethod='clip');");
  564. vml.push("\"><cg_vml_:image src=\"",_116._image.src,"\" style=\"width:",(_115.size.width),"px;height:",(_115.size.height),"px;\"/></g_vml_:group>");
  565. _117=vml.join("");
  566. }
  567. if(_114.buffer!=nil){
  568. _114.buffer+=_117;
  569. }else{
  570. _114.DOMElement.insertAdjacentHTML("BeforeEnd",_117);
  571. }
  572. };
  573. CGContextDrawPath=function(_11d,_11e){
  574. if(!_11d||CGPathIsEmpty(_11d.path)){
  575. return;
  576. }
  577. var _11f=_11d.path.elements,i=0,_121=_11d.path.count,_122=_11d.gState,fill=(_11e==kCGPathFill||_11e==kCGPathFillStroke)?1:0,_124=(_11e==kCGPathStroke||_11e==kCGPathFillStroke)?1:0,_125=_122.alpha,vml=["<cg_vml_:shape"," fillcolor=\"",_122.fillStyle,"\" filled=\"",_109[fill],"\" style=\"position:absolute;width:",W,";height:",H,";\" coordorigin=\"0 0\" coordsize=\"",Z*W," ",Z*H,"\" stroked=\"",_109[_124],"\" strokeweight=\"",_122.lineWidth,"\" strokecolor=\"",_122.strokeStyle,"\" path=\""];
  578. for(;i<_121;++i){
  579. var _127=_11f[i],type=_127.type;
  580. switch(type){
  581. case kCGPathElementMoveToPoint:
  582. case kCGPathElementAddLineToPoint:
  583. vml.push(_10c[type],(ROUND(Z*(_127.x)-Z_2)),",",(ROUND(Z*(_127.y)-Z_2)));
  584. break;
  585. case kCGPathElementAddQuadCurveToPoint:
  586. vml.push(_10c[type],(ROUND(Z*(_127.cpx)-Z_2)),",",(ROUND(Z*(_127.cpy)-Z_2)),",",(ROUND(Z*(_127.x)-Z_2)),",",(ROUND(Z*(_127.y)-Z_2)));
  587. break;
  588. case kCGPathElementAddCurveToPoint:
  589. vml.push(_10c[type],(ROUND(Z*(_127.cp1x)-Z_2)),",",(ROUND(Z*(_127.cp1y)-Z_2)),",",(ROUND(Z*(_127.cp2x)-Z_2)),",",(ROUND(Z*(_127.cp2y)-Z_2)),",",(ROUND(Z*(_127.x)-Z_2)),",",(ROUND(Z*(_127.y)-Z_2)));
  590. break;
  591. case kCGPathElementCloseSubpath:
  592. vml.push(_10c[type]);
  593. break;
  594. case kCGPathElementAddArc:
  595. var x=_127.x,y=_127.y,_12b=_127.radius,_12c=_127.clockwise?1:0,_12d=_127.endAngle,_12e=_127.startAngle,_12f={x:x+_12b*COS(_12e),y:y+_12b*SIN(_12e)};
  596. if(_12e==_12d&&!_12c){
  597. vml.push(_10c[kCGPathElementMoveToPoint],(ROUND(Z*(_12f.x)-Z_2)),",",(ROUND(Z*(_12f.y)-Z_2)));
  598. continue;
  599. }
  600. var end={x:x+_12b*COS(_12d),y:y+_12b*SIN(_12d)};
  601. if(_12c&&_12e!=_12d&&(_12f.x==end.x&&_12f.y==end.y)){
  602. if(_12f.x>=x){
  603. if(_12f.y<y){
  604. _12f.x+=0.125;
  605. }else{
  606. _12f.y+=0.125;
  607. }
  608. }else{
  609. if(end.y<=y){
  610. end.x+=0.125;
  611. }else{
  612. end.y+=0.125;
  613. }
  614. }
  615. }
  616. vml.push(_10c[type][_12c],(ROUND(Z*(x-_12b)-Z_2)),",",(ROUND(Z*(y-_12b)-Z_2))," ",(ROUND(Z*(x+_12b)-Z_2)),",",(ROUND(Z*(y+_12b)-Z_2))," ",(ROUND(Z*(_12f.x)-Z_2)),",",(ROUND(Z*(_12f.y)-Z_2))," ",(ROUND(Z*(end.x)-Z_2)),",",(ROUND(Z*(end.y)-Z_2)));
  617. break;
  618. case kCGPathElementAddArcTo:
  619. break;
  620. }
  621. }
  622. vml.push("\">");
  623. if(_122.gradient){
  624. vml.push(_122.gradient);
  625. }else{
  626. if(fill){
  627. vml.push("<cg_vml_:fill color=\"",_122.fillStyle,"\" opacity=\"",_125,"\" />");
  628. }
  629. }
  630. if(_124){
  631. vml.push("<cg_vml_:stroke opacity=\"",_125,"\" joinstyle=\"",_10b[_122.lineJoin],"\" miterlimit=\"",_122.miterLimit,"\" endcap=\"",_10a[_122.lineCap],"\" weight=\"",_122.lineWidth,"","px\" color=\"",_122.strokeStyle,"\" />");
  632. }
  633. var _131=_122.shadowColor;
  634. if(_131){
  635. var _132=_122.shadowOffset;
  636. vml.push("<cg_vml_:shadow on=\"t\" offset=\"",_132.width,"pt ",_132.height,"pt\" opacity=\"",objj_msgSend(_131,"alphaComponent"),"\" color=black />");
  637. }
  638. vml.push("</cg_vml_:shape>");
  639. _11d.path=NULL;
  640. if(_11d.buffer!=nil){
  641. _11d.buffer+=vml.join("");
  642. }else{
  643. _11d.DOMElement.insertAdjacentHTML("BeforeEnd",vml.join(""));
  644. }
  645. };
  646. to_string=function(_133){
  647. return "rgb("+ROUND(_133.components[0]*255)+", "+ROUND(_133.components[1]*255)+", "+ROUND(255*_133.components[2])+")";
  648. };
  649. CGContextDrawLinearGradient=function(_134,_135,_136,_137,_138){
  650. if(!_134||!_135){
  651. return;
  652. }
  653. var vml=nil;
  654. if(_135.vml_gradient){
  655. var _13a=objj_msgSend(objj_msgSend(_135.vml_gradient,"stops"),"sortedArrayUsingSelector:",sel_getUid("comparePosition:")),_13b=objj_msgSend(_13a,"count");
  656. vml=["<cg_vml_:fill type=\"gradient\" method=\"linear sigma\" "];
  657. vml.push("angle=\""+(objj_msgSend(_135.vml_gradient,"angle")+90)+"\" ");
  658. vml.push("colors=\"");
  659. for(var i=0;i<_13b;i++){
  660. vml.push((objj_msgSend(_13a[i],"position")*100).toFixed(0)+"% ");
  661. vml.push(objj_msgSend(objj_msgSend(objj_msgSend(_13a[i],"color"),"colorForSlideBase:",nil),"cssString"));
  662. if(i<_13b-1){
  663. vml.push(",");
  664. }
  665. }
  666. vml.push("\" />");
  667. }else{
  668. var _13d=_135.colors,_13b=_13d.length;
  669. vml=["<cg_vml_:fill type=\"gradient\" "];
  670. vml.push("colors=\"");
  671. for(var i=0;i<_13b;i++){
  672. vml.push((_135.locations[i]*100).toFixed(0)+"% "+to_string(_13d[i])+(i<_13b-1?",":""));
  673. }
  674. vml.push("\" />");
  675. }
  676. _134.gState.gradient=vml.join("");
  677. console.log(vml.join(""));
  678. };
  679. }
  680. }