/Frameworks/Debug/AppKit/browser.platform/CPBezierPath.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 162 lines · 161 code · 1 blank · 0 comment · 0 complexity · 17be5c506ed4c8e981934a7fed7122e1 MD5 · raw file

  1. I;26;AppKit/CPGraphicsContext.jI;21;Foundation/CPObject.jc;6211;
  2. var DefaultLineWidth = 1.0;
  3. {var the_class = objj_allocateClassPair(CPObject, "CPBezierPath"),
  4. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_path"), new objj_ivar("_lineWidth")]);
  5. objj_registerClassPair(the_class);
  6. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPBezierPath__init(self, _cmd)
  8. { with(self)
  9. {
  10. if (self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init"))
  11. {
  12. _path = CGPathCreateMutable();
  13. _lineWidth = objj_msgSend(objj_msgSend(self, "class"), "defaultLineWidth");
  14. }
  15. return self;
  16. }
  17. }), new objj_method(sel_getUid("moveToPoint:"), function $CPBezierPath__moveToPoint_(self, _cmd, point)
  18. { with(self)
  19. {
  20. CGPathMoveToPoint(_path, nil, point.x, point.y);
  21. }
  22. }), new objj_method(sel_getUid("lineToPoint:"), function $CPBezierPath__lineToPoint_(self, _cmd, point)
  23. { with(self)
  24. {
  25. CGPathAddLineToPoint(_path, nil, point.x, point.y);
  26. }
  27. }), new objj_method(sel_getUid("curveToPoint:controlPoint1:controlPoint2:"), function $CPBezierPath__curveToPoint_controlPoint1_controlPoint2_(self, _cmd, endPoint, controlPoint1, controlPoint2)
  28. { with(self)
  29. {
  30. CGPathAddCurveToPoint(_path, nil, controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, endPoint.x, endPoint.y);
  31. }
  32. }), new objj_method(sel_getUid("closePath"), function $CPBezierPath__closePath(self, _cmd)
  33. { with(self)
  34. {
  35. CGPathCloseSubpath(_path);
  36. }
  37. }), new objj_method(sel_getUid("stroke"), function $CPBezierPath__stroke(self, _cmd)
  38. { with(self)
  39. {
  40. var ctx = objj_msgSend(objj_msgSend(CPGraphicsContext, "currentContext"), "graphicsPort");
  41. CGContextBeginPath(ctx);
  42. CGContextAddPath(ctx, _path);
  43. CGContextSetLineWidth(ctx, objj_msgSend(self, "lineWidth"));
  44. CGContextClosePath(ctx);
  45. CGContextStrokePath(ctx);
  46. }
  47. }), new objj_method(sel_getUid("fill"), function $CPBezierPath__fill(self, _cmd)
  48. { with(self)
  49. {
  50. var ctx = objj_msgSend(objj_msgSend(CPGraphicsContext, "currentContext"), "graphicsPort");
  51. CGContextBeginPath(ctx);
  52. CGContextAddPath(ctx, _path);
  53. CGContextSetLineWidth(ctx, objj_msgSend(self, "lineWidth"));
  54. CGContextClosePath(ctx);
  55. CGContextFillPath(ctx);
  56. }
  57. }), new objj_method(sel_getUid("lineWidth"), function $CPBezierPath__lineWidth(self, _cmd)
  58. { with(self)
  59. {
  60. return _lineWidth;
  61. }
  62. }), new objj_method(sel_getUid("setLineWidth:"), function $CPBezierPath__setLineWidth_(self, _cmd, lineWidth)
  63. { with(self)
  64. {
  65. _lineWidth = lineWidth;
  66. }
  67. }), new objj_method(sel_getUid("elementCount"), function $CPBezierPath__elementCount(self, _cmd)
  68. { with(self)
  69. {
  70. return _path.count;
  71. }
  72. }), new objj_method(sel_getUid("isEmpty"), function $CPBezierPath__isEmpty(self, _cmd)
  73. { with(self)
  74. {
  75. return CGPathIsEmpty(_path);
  76. }
  77. }), new objj_method(sel_getUid("currentPoint"), function $CPBezierPath__currentPoint(self, _cmd)
  78. { with(self)
  79. {
  80. return CGPathGetCurrentPoint(_path);
  81. }
  82. }), new objj_method(sel_getUid("appendBezierPathWithPoints:count:"), function $CPBezierPath__appendBezierPathWithPoints_count_(self, _cmd, points, count)
  83. { with(self)
  84. {
  85. CGPathAddLines(_path, nil, points, count);
  86. }
  87. }), new objj_method(sel_getUid("appendBezierPathWithRect:"), function $CPBezierPath__appendBezierPathWithRect_(self, _cmd, rect)
  88. { with(self)
  89. {
  90. CGPathAddRect(_path, nil, rect);
  91. }
  92. }), new objj_method(sel_getUid("appendBezierPathWithOvalInRect:"), function $CPBezierPath__appendBezierPathWithOvalInRect_(self, _cmd, rect)
  93. { with(self)
  94. {
  95. CGPathAddPath(_path, nil, CGPathWithEllipseInRect(rect));
  96. }
  97. }), new objj_method(sel_getUid("appendBezierPathWithRoundedRect:xRadius:yRadius:"), function $CPBezierPath__appendBezierPathWithRoundedRect_xRadius_yRadius_(self, _cmd, rect, xRadius, yRadius)
  98. { with(self)
  99. {
  100. CGPathAddPath(_path, nil, CGPathWithRoundedRectangleInRect(rect, xRadius, yRadius, YES, YES, YES, YES));
  101. }
  102. }), new objj_method(sel_getUid("appendBezierPath:"), function $CPBezierPath__appendBezierPath_(self, _cmd, other)
  103. { with(self)
  104. {
  105. CGPathAddPath(_path, nil, other._path);
  106. }
  107. }), new objj_method(sel_getUid("removeAllPoints"), function $CPBezierPath__removeAllPoints(self, _cmd)
  108. { with(self)
  109. {
  110. _path = CGPathCreateMutable();
  111. }
  112. })]);
  113. class_addMethods(meta_class, [new objj_method(sel_getUid("bezierPath"), function $CPBezierPath__bezierPath(self, _cmd)
  114. { with(self)
  115. {
  116. return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "init");
  117. }
  118. }), new objj_method(sel_getUid("bezierPathWithOvalInRect:"), function $CPBezierPath__bezierPathWithOvalInRect_(self, _cmd, rect)
  119. { with(self)
  120. {
  121. var path = objj_msgSend(objj_msgSend(self, "class"), "bezierPath");
  122. objj_msgSend(path, "appendBezierPathWithOvalInRect:", rect);
  123. return path;
  124. }
  125. }), new objj_method(sel_getUid("bezierPathWithRect:"), function $CPBezierPath__bezierPathWithRect_(self, _cmd, rect)
  126. { with(self)
  127. {
  128. var path = objj_msgSend(objj_msgSend(self, "class"), "bezierPath");
  129. objj_msgSend(path, "appendBezierPathWithRect:", rect);
  130. return path;
  131. }
  132. }), new objj_method(sel_getUid("defaultLineWidth"), function $CPBezierPath__defaultLineWidth(self, _cmd)
  133. { with(self)
  134. {
  135. return DefaultLineWidth;
  136. }
  137. }), new objj_method(sel_getUid("setDefaultLineWidth:"), function $CPBezierPath__setDefaultLineWidth_(self, _cmd, width)
  138. { with(self)
  139. {
  140. DefaultLineWidth = width;
  141. }
  142. }), new objj_method(sel_getUid("fillRect:"), function $CPBezierPath__fillRect_(self, _cmd, rect)
  143. { with(self)
  144. {
  145. objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "bezierPathWithRect:", rect), "fill");
  146. }
  147. }), new objj_method(sel_getUid("strokeRect:"), function $CPBezierPath__strokeRect_(self, _cmd, rect)
  148. { with(self)
  149. {
  150. objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "bezierPathWithRect:", rect), "stroke");
  151. }
  152. }), new objj_method(sel_getUid("strokeLineFromPoint:toPoint:"), function $CPBezierPath__strokeLineFromPoint_toPoint_(self, _cmd, point1, point2)
  153. { with(self)
  154. {
  155. var path = objj_msgSend(objj_msgSend(self, "class"), "bezierPath");
  156. objj_msgSend(path, "moveToPoint:", point1);
  157. objj_msgSend(path, "lineToPoint:", point2);
  158. objj_msgSend(path, "stroke");
  159. }
  160. })]);
  161. }