@@ -203,7 +203,11 @@ class Graphics
203203public static inline var TILE_ROTATION = 0x0002 ;
204204public static inline var TILE_RGB = 0x0004 ;
205205public static inline var TILE_ALPHA = 0x0008 ;
206-
206+ public static inline var TILE_TRANS_2x2 = 0x0010 ;
207+
208+ public static inline var TILE_BLEND_NORMAL = 0x00000000 ;
209+ public static inline var TILE_BLEND_ADD = 0x00010000 ;
210+
207211public var jeashSurface (default , null ): HTMLCanvasElement ;
208212private var jeashChanged : Bool ;
209213
@@ -671,31 +675,20 @@ class Graphics
671675{
672676var useScale = (flags & TILE_SCALE ) > 0 ;
673677var useRotation = (flags & TILE_ROTATION ) > 0 ;
678+ var useTransform = (flags & TILE_TRANS_2x2 ) > 0 ;
674679var useRGB = (flags & TILE_RGB ) > 0 ;
675680var useAlpha = (flags & TILE_ALPHA ) > 0 ;
676681
682+ if (useTransform ) { useScale = false ; useRotation = false ; }
683+
677684var index = 0 ;
678685var numValues = 3 ;
679686
680- if (useScale )
681- {
682- numValues ++ ;
683- }
684-
685- if (useRotation )
686- {
687- numValues ++ ;
688- }
689-
690- if (useRGB )
691- {
692- numValues + = 3 ;
693- }
694-
695- if (useAlpha )
696- {
697- numValues ++ ;
698- }
687+ if (useScale ) numValues ++ ;
688+ if (useRotation ) numValues ++ ;
689+ if (useTransform ) numValues + = 4 ;
690+ if (useRGB ) numValues + = 3 ;
691+ if (useAlpha ) numValues ++ ;
699692
700693while (index < tileData .length ) {
701694
@@ -712,38 +705,25 @@ class Graphics
712705
713706var useScale = (flags & TILE_SCALE ) > 0 ;
714707var useRotation = (flags & TILE_ROTATION ) > 0 ;
708+ var useTransform = (flags & TILE_TRANS_2x2 ) > 0 ;
715709var useRGB = (flags & TILE_RGB ) > 0 ;
716710var useAlpha = (flags & TILE_ALPHA ) > 0 ;
717711
712+ if (useTransform ) { useScale = false ; useRotation = false ; }
713+
718714var scaleIndex = 0 ;
719715var rotationIndex = 0 ;
720716var rgbIndex = 0 ;
721717var alphaIndex = 0 ;
722- var numValues = 3 ;
723-
724- if (useScale )
725- {
726- scaleIndex = numValues ;
727- numValues ++ ;
728- }
718+ var transformIndex = 0 ;
729719
730- if (useRotation )
731- {
732- rotationIndex = numValues ;
733- numValues ++ ;
734- }
735-
736- if (useRGB )
737- {
738- rgbIndex = numValues ;
739- numValues + = 3 ;
740- }
720+ var numValues = 3 ;
741721
742- if (useAlpha )
743- {
744- alphaIndex = numValues ;
745- numValues ++ ;
746- }
722+ if (useScale ) { scaleIndex = numValues ; numValues ++ ; }
723+ if ( useRotation ) { rotationIndex = numValues ; numValues ++ ; }
724+ if ( useTransform ) { transformIndex = numValues ; numValues + = 4 ; }
725+ if ( useRGB ) { rgbIndex = numValues ; numValues + = 3 ; }
726+ if ( useAlpha ) { alphaIndex = numValues ; numValues ++ ; }
747727
748728var totalCount = tileData .length ;
749729var itemCount = Std .int (totalCount / numValues );
@@ -771,27 +751,37 @@ class Graphics
771751
772752}
773753
774- ctx .save ();
775- ctx .translate (tileData [index ], tileData [index + 1 ]);
776-
777- if (useRotation ) {
754+ if (rect != null && center != null ) {
778755
779- ctx .rotate (- tileData [index + rotationIndex ]);
756+ ctx .save ();
757+ ctx .translate (tileData [index ], tileData [index + 1 ]);
780758
781- }
782-
783- var scale = 1.0 ;
784-
785- if (useScale ) {
759+ if (useRotation && ! useTransform ) {
760+
761+ ctx .rotate (- tileData [index + rotationIndex ]);
762+
763+ }
764+
765+ var scale = 1.0 ;
786766
787- scale = tileData [index + scaleIndex ];
767+ if (useScale && ! useTransform ) {
768+
769+ scale = tileData [index + scaleIndex ];
770+
771+ }
772+
773+ if (useTransform ) {
774+
775+ ctx .transform (tileData [index + transformIndex ], tileData [index + transformIndex + 1 ], tileData [index + transformIndex + 2 ], tileData [index + transformIndex + 3 ], 0 , 0 );
776+
777+ }
778+
779+ ctx .drawImage (surface , rect .x , rect .y , rect .width , rect .height , - center .x * scale , - center .y * scale , rect .width * scale , rect .height * scale );
780+ ctx .restore ();
788781
789782}
790783
791- ctx .drawImage (surface , rect .x , rect .y , rect .width , rect .height , - center .x * scale , - center .y * scale , rect .width * scale , rect .height * scale );
792-
793784index + = numValues ;
794- ctx .restore ();
795785
796786}
797787
0 commit comments