@@ -89,9 +89,12 @@ Texture GetAsepriteTexture(Aseprite aseprite); // Retrieve
89
89
int GetAsepriteWidth (Aseprite aseprite ); // Get the width of the sprite
90
90
int GetAsepriteHeight (Aseprite aseprite ); // Get the height of the sprite
91
91
void DrawAseprite (Aseprite aseprite , int frame , int posX , int posY , Color tint );
92
+ void DrawAsepriteFlipped (Aseprite aseprite , int frame , int posX , int posY , bool horizontalFlip , bool verticalFlip , Color tint );
92
93
void DrawAsepriteV (Aseprite aseprite , int frame , Vector2 position , Color tint );
93
- void DrawAsepriteEx (Aseprite aseprite , int frame , Vector2 position , float rotation , float scale , Color tint );
94
+ void DrawAsepriteVFlipped (Aseprite aseprite , int frame , Vector2 position , bool horizontalFlip , bool verticalFlip , Color tint );
95
+ void DrawAsepriteExFlipped (Aseprite aseprite , int frame , Vector2 position , float rotation , float scale , bool horizontalFlip , bool verticalFlip , Color tint );
94
96
void DrawAsepritePro (Aseprite aseprite , int frame , Rectangle dest , Vector2 origin , float rotation , Color tint );
97
+ void DrawAsepriteProFlipped (Aseprite aseprite , int frame , Rectangle dest , Vector2 origin , float rotation , bool horizontalFlip , bool verticalFlip , Color tint );
95
98
96
99
// Aseprite Tag functions
97
100
AsepriteTag LoadAsepriteTag (Aseprite aseprite , const char * name ); // Load an Aseprite tag animation sequence
@@ -101,9 +104,13 @@ bool IsAsepriteTagReady(AsepriteTag tag); // Check if
101
104
void UpdateAsepriteTag (AsepriteTag * tag ); // Update the tag animation frame
102
105
AsepriteTag GenAsepriteTagDefault (); // Generate an empty Tag with sane defaults
103
106
void DrawAsepriteTag (AsepriteTag tag , int posX , int posY , Color tint );
107
+ void DrawAsepriteTagFlipped (AsepriteTag tag , int posX , int posY , bool horizontalFlip , bool verticalFlip , Color tint );
104
108
void DrawAsepriteTagV (AsepriteTag tag , Vector2 position , Color tint );
109
+ void DrawAsepriteTagVFlipped (AsepriteTag tag , Vector2 position , bool horizontalFlip , bool verticalFlip , Color tint );
105
110
void DrawAsepriteTagEx (AsepriteTag tag , Vector2 position , float rotation , float scale , Color tint );
111
+ void DrawAsepriteTagExFlipped (AsepriteTag tag , Vector2 position , float rotation , float scale , bool horizontalFlip , bool verticalFlip , Color tint );
106
112
void DrawAsepriteTagPro (AsepriteTag tag , Rectangle dest , Vector2 origin , float rotation , Color tint );
113
+ void DrawAsepriteTagProFlipped (AsepriteTag tag , Rectangle dest , Vector2 origin , float rotation , bool horizontalFlip , bool verticalFlip , Color tint );
107
114
void SetAsepriteTagFrame (AsepriteTag * tag , int frameNumber ); // Sets which frame the tag is currently displaying.
108
115
int GetAsepriteTagFrame (AsepriteTag tag );
109
116
@@ -362,41 +369,57 @@ void UnloadAseprite(Aseprite aseprite) {
362
369
}
363
370
364
371
void DrawAseprite (Aseprite aseprite , int frame , int posX , int posY , Color tint ) {
372
+ DrawAsepriteFlipped (aseprite , frame , posX , posY , false, false, tint );
373
+ }
374
+
375
+ void DrawAsepriteFlipped (Aseprite aseprite , int frame , int posX , int posY , bool horizontalFlip , bool verticalFlip , Color tint ) {
365
376
Vector2 position = {(float )posX , (float )posY };
366
- DrawAsepriteV (aseprite , frame , position , tint );
377
+ DrawAsepriteVFlipped (aseprite , frame , position , horizontalFlip , verticalFlip , tint );
367
378
}
368
379
369
380
void DrawAsepriteV (Aseprite aseprite , int frame , Vector2 position , Color tint ) {
381
+ DrawAsepriteVFlipped (aseprite , frame , position , false, false, tint );
382
+ }
383
+
384
+ void DrawAsepriteVFlipped (Aseprite aseprite , int frame , Vector2 position , bool horizontalFlip , bool verticalFlip , Color tint ) {
370
385
ase_t * ase = aseprite .ase ;
371
386
if (ase == 0 || frame < 0 || frame >= ase -> frame_count ) {
372
387
return ;
373
388
}
374
389
375
- Rectangle source = {(float )(frame * ase -> w ), 0 , (float )ase -> w , (float )ase -> h };
390
+ Rectangle source = {(float )(frame * ase -> w ), 0 , horizontalFlip ? (float )- ase -> w : ase -> w , verticalFlip ? ( float ) - ase -> h : (float )ase -> h };
376
391
Texture2D texture = GetAsepriteTexture (aseprite );
377
392
DrawTextureRec (texture , source , position , tint );
378
393
}
379
394
380
395
void DrawAsepriteEx (Aseprite aseprite , int frame , Vector2 position , float rotation , float scale , Color tint ) {
396
+ DrawAsepriteExFlipped (aseprite , frame , position , rotation , scale , false, false, tint );
397
+ }
398
+
399
+ void DrawAsepriteExFlipped (Aseprite aseprite , int frame , Vector2 position , float rotation , float scale , bool horizontalFlip , bool verticalFlip , Color tint ) {
381
400
ase_t * ase = aseprite .ase ;
382
401
if (ase == 0 || frame < 0 || frame >= ase -> frame_count ) {
383
402
return ;
384
403
}
385
404
386
- Rectangle source = {(float )(frame * ase -> w ), 0 , (float )ase -> w , (float )ase -> h };
405
+ Rectangle source = {(float )(frame * ase -> w ), 0 , horizontalFlip ? (float )- ase -> w : ase -> w , verticalFlip ? ( float ) - ase -> h : (float )ase -> h };
387
406
Texture2D texture = GetAsepriteTexture (aseprite );
388
407
Rectangle dest = {(float )position .x , (float )position .y , (float )ase -> w * scale , (float )ase -> h * scale };
389
408
Vector2 origin = {0 , 0 };
390
409
DrawTexturePro (texture , source , dest , origin , rotation , tint ); // Draw a part of a texture defined by a rectangle with 'pro' parameters
391
410
}
392
411
393
412
void DrawAsepritePro (Aseprite aseprite , int frame , Rectangle dest , Vector2 origin , float rotation , Color tint ) {
413
+ DrawAsepriteProFlipped (aseprite , frame , dest , origin , rotation , false, false, tint );
414
+ }
415
+
416
+ void DrawAsepriteProFlipped (Aseprite aseprite , int frame , Rectangle dest , Vector2 origin , float rotation , bool horizontalFlip , bool verticalFlip , Color tint ) {
394
417
ase_t * ase = aseprite .ase ;
395
418
if (ase == 0 || frame < 0 || frame >= ase -> frame_count ) {
396
419
return ;
397
420
}
398
421
399
- Rectangle source = {(float )(frame * ase -> w ), 0 , (float )ase -> w , (float )ase -> h };
422
+ Rectangle source = {(float )(frame * ase -> w ), 0 , horizontalFlip ? (float )- ase -> w : ase -> w , verticalFlip ? ( float ) - ase -> h : (float )ase -> h };
400
423
Texture2D texture = GetAsepriteTexture (aseprite );
401
424
DrawTexturePro (texture , source , dest , origin , rotation , tint );
402
425
}
@@ -544,18 +567,34 @@ void DrawAsepriteTag(AsepriteTag tag, int posX, int posY, Color tint) {
544
567
DrawAseprite (tag .aseprite , tag .currentFrame , posX , posY , tint );
545
568
}
546
569
570
+ void DrawAsepriteTagFlipped (AsepriteTag tag , int posX , int posY , bool horizontalFlip , bool verticalFlip , Color tint ) {
571
+ DrawAsepriteFlipped (tag .aseprite , tag .currentFrame , posX , posY , horizontalFlip , verticalFlip , tint );
572
+ }
573
+
547
574
void DrawAsepriteTagV (AsepriteTag tag , Vector2 position , Color tint ) {
548
575
DrawAsepriteV (tag .aseprite , tag .currentFrame , position , tint );
549
576
}
550
577
578
+ void DrawAsepriteTagVFlipped (AsepriteTag tag , Vector2 position , bool horizontalFlip , bool verticalFlip , Color tint ) {
579
+ DrawAsepriteVFlipped (tag .aseprite , tag .currentFrame , position , horizontalFlip , verticalFlip , tint );
580
+ }
581
+
551
582
void DrawAsepriteTagEx (AsepriteTag tag , Vector2 position , float rotation , float scale , Color tint ) {
552
583
DrawAsepriteEx (tag .aseprite , tag .currentFrame , position , rotation , scale , tint );
553
584
}
554
585
586
+ void DrawAsepriteTagExFlipped (AsepriteTag tag , Vector2 position , float rotation , float scale , bool horizontalFlip , bool verticalFlip , Color tint ) {
587
+ DrawAsepriteExFlipped (tag .aseprite , tag .currentFrame , position , rotation , scale , horizontalFlip , verticalFlip , tint );
588
+ }
589
+
555
590
void DrawAsepriteTagPro (AsepriteTag tag , Rectangle dest , Vector2 origin , float rotation , Color tint ) {
556
591
DrawAsepritePro (tag .aseprite , tag .currentFrame , dest , origin , rotation , tint );
557
592
}
558
593
594
+ void DrawAsepriteTagProFlipped (AsepriteTag tag , Rectangle dest , Vector2 origin , float rotation , bool horizontalFlip , bool verticalFlip , Color tint ) {
595
+ DrawAsepriteProFlipped (tag .aseprite , tag .currentFrame , dest , origin , rotation , horizontalFlip , verticalFlip , tint );
596
+ }
597
+
559
598
/**
560
599
* Generate an aseprite tag with sane defaults.
561
600
*
0 commit comments