@@ -99,6 +99,26 @@ game.createClass('Graphics', 'Container', {
99
99
this . _drawShape ( shape ) ;
100
100
return this ;
101
101
} ,
102
+
103
+ /**
104
+ Draw bezier curve.
105
+ @method drawCurve
106
+ @param {Curve|Number } sx
107
+ @param {Number } sy
108
+ @param {Number } ex
109
+ @param {Number } ey
110
+ @param {Number } h1x
111
+ @param {Number } h1y
112
+ @param {Number } h2x
113
+ @param {Number } h2y
114
+ @chainable
115
+ **/
116
+ drawCurve : function ( sx , sy , ex , ey , h1x , h1y , h2x , h2y ) {
117
+ this . lineWidth = this . lineWidth || 1 ;
118
+ var shape = typeof sx === 'number' ? new game . Curve ( sx , sy , ex , ey , h1x , h1y , h2x , h2y ) : sx ;
119
+ this . _drawShape ( shape , true ) ;
120
+ return this ;
121
+ } ,
102
122
103
123
/**
104
124
@method drawLine
@@ -325,7 +345,7 @@ game.createClass('GraphicsShape', {
325
345
326
346
this . _renderShape ( context ) ;
327
347
328
- if ( this . fillColor && this . fillAlpha ) context . fill ( ) ;
348
+ if ( this . fillColor && this . fillAlpha && ! this . isLine ) context . fill ( ) ;
329
349
if ( this . lineWidth ) {
330
350
context . globalAlpha = this . lineAlpha * alpha ;
331
351
context . stroke ( ) ;
@@ -342,7 +362,18 @@ game.createClass('GraphicsShape', {
342
362
var x = shape . x * game . scale ;
343
363
var y = shape . y * game . scale ;
344
364
345
- if ( this . isLine ) {
365
+ if ( this . isLine && shape . start ) {
366
+ context . moveTo ( shape . start . x * game . scale , shape . start . y * game . scale ) ;
367
+ context . bezierCurveTo (
368
+ shape . handle1 . x * game . scale ,
369
+ shape . handle1 . y * game . scale ,
370
+ shape . handle2 . x * game . scale ,
371
+ shape . handle2 . y * game . scale ,
372
+ shape . end . x * game . scale ,
373
+ shape . end . y * game . scale
374
+ ) ;
375
+ }
376
+ else if ( this . isLine ) {
346
377
context . moveTo ( x , y ) ;
347
378
context . lineTo ( shape . width , shape . height ) ;
348
379
}
0 commit comments