@@ -84,26 +84,24 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
8484
8585 var commands = src . commandBuffer ;
8686 var alpha = camera . alpha * src . alpha ;
87- var lineAlpha = 1.0 ;
88- var fillAlpha = 1.0 ;
89- var lineColor = 0 ;
90- var fillColor = 0 ;
91- var lineWidth = 1.0 ;
92- var lastPath = null ;
93- var iteration = 0 ;
94- var iterStep = 0.01 ;
87+
88+ var lineWidth = 1 ;
89+ var fillTint = pipeline . fillTint ;
90+ var strokeTint = pipeline . strokeTint ;
91+
9592 var tx = 0 ;
9693 var ty = 0 ;
9794 var ta = 0 ;
98- var x = 0 ;
99- var y = 0 ;
100- var radius = 0 ;
101- var startAngle = 0 ;
102- var endAngle = 0 ;
95+ var iterStep = 0.01 ;
96+
10397 var cmd ;
98+
10499 var path = [ ] ;
105100 var pathIndex = 0 ;
106101 var pathOpen = false ;
102+ var lastPath = null ;
103+
104+ var getTint = Utils . getTintAppendFloatAlphaAndSwap ;
107105
108106 for ( var cmdIndex = 0 ; cmdIndex < commands . length ; cmdIndex ++ )
109107 {
@@ -154,27 +152,51 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
154152
155153 case Commands . LINE_STYLE :
156154 lineWidth = commands [ ++ cmdIndex ] ;
157- lineColor = commands [ ++ cmdIndex ] ;
158- lineAlpha = commands [ ++ cmdIndex ] ;
159- pipeline . strokeTint = Utils . getTintAppendFloatAlphaAndSwap ( lineColor , lineAlpha * alpha ) ;
155+ var strokeColor = commands [ ++ cmdIndex ] ;
156+ var strokeAlpha = commands [ ++ cmdIndex ] * alpha ;
157+ var strokeTintColor = getTint ( strokeColor , strokeAlpha ) ;
158+ strokeTint . TL = strokeTintColor ;
159+ strokeTint . TR = strokeTintColor ;
160+ strokeTint . BL = strokeTintColor ;
161+ strokeTint . BR = strokeTintColor ;
160162 break ;
161163
162164 case Commands . FILL_STYLE :
163- fillColor = commands [ ++ cmdIndex ] ;
164- fillAlpha = commands [ ++ cmdIndex ] ;
165- pipeline . fillTint = Utils . getTintAppendFloatAlphaAndSwap ( fillColor , fillAlpha * alpha ) ;
165+ var fillColor = commands [ ++ cmdIndex ] ;
166+ var fillAlpha = commands [ ++ cmdIndex ] * alpha ;
167+ var fillTintColor = getTint ( fillColor , fillAlpha ) ;
168+ fillTint . TL = fillTintColor ;
169+ fillTint . TR = fillTintColor ;
170+ fillTint . BL = fillTintColor ;
171+ fillTint . BR = fillTintColor ;
172+ break ;
173+
174+ case Commands . GRADIENT_FILL_STYLE :
175+ var gradientFillAlpha = commands [ ++ cmdIndex ] * alpha ;
176+ fillTint . TL = getTint ( commands [ ++ cmdIndex ] , gradientFillAlpha ) ;
177+ fillTint . TR = getTint ( commands [ ++ cmdIndex ] , gradientFillAlpha ) ;
178+ fillTint . BL = getTint ( commands [ ++ cmdIndex ] , gradientFillAlpha ) ;
179+ fillTint . BR = getTint ( commands [ ++ cmdIndex ] , gradientFillAlpha ) ;
180+ break ;
181+
182+ case Commands . GRADIENT_LINE_STYLE :
183+ lineWidth = commands [ ++ cmdIndex ] ;
184+ var gradientLineAlpha = commands [ ++ cmdIndex ] * alpha ;
185+ strokeTint . TL = getTint ( commands [ ++ cmdIndex ] , gradientLineAlpha ) ;
186+ strokeTint . TR = getTint ( commands [ ++ cmdIndex ] , gradientLineAlpha ) ;
187+ strokeTint . BL = getTint ( commands [ ++ cmdIndex ] , gradientLineAlpha ) ;
188+ strokeTint . BR = getTint ( commands [ ++ cmdIndex ] , gradientLineAlpha ) ;
166189 break ;
167190
168191 case Commands . ARC :
169- iteration = 0 ;
170- x = commands [ ++ cmdIndex ] ;
171- y = commands [ ++ cmdIndex ] ;
172- radius = commands [ ++ cmdIndex ] ;
173- startAngle = commands [ ++ cmdIndex ] ;
174- endAngle = commands [ ++ cmdIndex ] ;
192+ var iteration = 0 ;
193+ var x = commands [ ++ cmdIndex ] ;
194+ var y = commands [ ++ cmdIndex ] ;
195+ var radius = commands [ ++ cmdIndex ] ;
196+ var startAngle = commands [ ++ cmdIndex ] ;
197+ var endAngle = commands [ ++ cmdIndex ] ;
175198
176- // var anticlockwise
177- cmdIndex ++ ;
199+ cmdIndex ++ ; // anticlockwise (canvas only)
178200
179201 if ( lastPath === null )
180202 {
@@ -243,20 +265,18 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
243265 case Commands . LINE_TO :
244266 if ( lastPath !== null )
245267 {
246- lastPath . points . push ( new Point ( commands [ cmdIndex + 1 ] , commands [ cmdIndex + 2 ] , lineWidth ) ) ;
268+ lastPath . points . push ( new Point ( commands [ ++ cmdIndex ] , commands [ ++ cmdIndex ] , lineWidth ) ) ;
247269 }
248270 else
249271 {
250- lastPath = new Path ( commands [ cmdIndex + 1 ] , commands [ cmdIndex + 2 ] , lineWidth ) ;
272+ lastPath = new Path ( commands [ ++ cmdIndex ] , commands [ ++ cmdIndex ] , lineWidth ) ;
251273 path . push ( lastPath ) ;
252274 }
253- cmdIndex += 2 ;
254275 break ;
255276
256277 case Commands . MOVE_TO :
257- lastPath = new Path ( commands [ cmdIndex + 1 ] , commands [ cmdIndex + 2 ] , lineWidth ) ;
278+ lastPath = new Path ( commands [ ++ cmdIndex ] , commands [ ++ cmdIndex ] , lineWidth ) ;
258279 path . push ( lastPath ) ;
259- cmdIndex += 2 ;
260280 break ;
261281
262282 case Commands . SAVE :
@@ -280,8 +300,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
280300 break ;
281301
282302 case Commands . ROTATE :
283- var r = commands [ ++ cmdIndex ] ;
284- currentMatrix . rotate ( r ) ;
303+ currentMatrix . rotate ( commands [ ++ cmdIndex ] ) ;
285304 break ;
286305
287306 case Commands . SET_TEXTURE :
@@ -291,14 +310,12 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
291310 pipeline . currentFrame = frame ;
292311 renderer . setTexture2D ( frame . glTexture , 0 ) ;
293312 pipeline . tintEffect = mode ;
294-
295313 break ;
296314
297315 case Commands . CLEAR_TEXTURE :
298316 pipeline . currentFrame = renderer . blankTexture ;
299317 renderer . setTexture2D ( renderer . blankTexture . glTexture , 0 ) ;
300318 pipeline . tintEffect = 2 ;
301-
302319 break ;
303320
304321 }
0 commit comments