-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Wrong Rendering When Input-Sprite Is Non-Square + Added Support…
… For Separate Border Width/Height
- Loading branch information
1 parent
0031566
commit 6b9866f
Showing
6 changed files
with
32 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,50 @@ | ||
// Draw Sprite Nine Sliced | ||
function draw_niceslice(sprite,subimg,x,y,width,height,border,internal_scale,color=c_white,alpha=1) | ||
/// @arg {Asset.GMSprite} sprite | ||
/// @arg {Real} subimg | ||
/// @arg {Real} x | ||
/// @arg {Real} y | ||
/// @arg {Real} width | ||
/// @arg {Real} height | ||
/// @arg {Real} border_width | ||
/// @arg {Real} border_height | ||
/// @arg {Real} internal_scale | ||
/// @arg {Asset.GMColor} color | ||
/// @arg {Real} alpha | ||
/// @pure | ||
function draw_niceslice(sprite,subimg,x,y,width,height,border_width,border_height,internal_scale,color=c_white,alpha=1) | ||
{ | ||
var scale = internal_scale; | ||
var sprite_w = sprite_get_width(sprite); | ||
var sprite_h = sprite_get_height(sprite); | ||
var side_length_raw_w = sprite_h-(border*2); | ||
var side_length_raw_h = sprite_w-(border*2); | ||
var side_scale_factor_w = (1/side_length_raw_w)*(width-((border*scale)*2)); | ||
var side_scale_factor_h = (1/side_length_raw_h)*(height-((border*scale)*2)); | ||
var side_length_raw_w = sprite_w-(border_width*2); | ||
var side_length_raw_h = sprite_h-(border_height*2); | ||
var side_scale_factor_w = (1/side_length_raw_w)*(width-((border_width*scale)*2)); | ||
var side_scale_factor_h = (1/side_length_raw_h)*(height-((border_height*scale)*2)); | ||
|
||
// Top Left | ||
draw_sprite_part_ext(sprite,subimg,0,0,border,border,x,y,scale,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,0,0,border_width,border_height,x,y,scale,scale,color,alpha); | ||
|
||
// Top Right | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border,0,border,border,x+width-(border*scale),y,scale,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border_width,0,border_width,border_height,x+width-(border_width*scale),y,scale,scale,color,alpha); | ||
|
||
// Bottom Left | ||
draw_sprite_part_ext(sprite,subimg,0,sprite_h-border,border,border,x,y+height-(border*scale),scale,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,0,sprite_h-border_height,border_width,border_height,x,y+height-(border_height*scale),scale,scale,color,alpha); | ||
|
||
// Bottom Right | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border,sprite_h-border,border,border,x+width-(border*scale),y+height-(border*scale),scale,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border_width,sprite_h-border_height,border_width,border_height,x+width-(border_width*scale),y+height-(border_height*scale),scale,scale,color,alpha); | ||
|
||
// Left | ||
draw_sprite_part_ext(sprite,subimg,0,border,border,side_length_raw_h,x,y+(border*scale),scale,side_scale_factor_h,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,0,border_height,border_width,side_length_raw_h,x,y+(border_height*scale),scale,side_scale_factor_h,color,alpha); | ||
|
||
// Right | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border,border,border,side_length_raw_h,x+width-(border*scale),y+(border*scale),scale,side_scale_factor_h,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,sprite_w-border_width,border_height,border_width,side_length_raw_h,x+width-(border_width*scale),y+(border_height*scale),scale,side_scale_factor_h,color,alpha); | ||
|
||
// Top | ||
draw_sprite_part_ext(sprite,subimg,border,0,side_length_raw_w,border,x+(border*scale),y,side_scale_factor_w,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,border_width,0,side_length_raw_w,border_height,x+(border_width*scale),y,side_scale_factor_w,scale,color,alpha); | ||
|
||
// Bottom | ||
draw_sprite_part_ext(sprite,subimg,border,sprite_h-border,side_length_raw_w,border,x+(border*scale),y+height-(border*scale),side_scale_factor_w,scale,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,border_width,sprite_h-border_height,side_length_raw_w,border_height,x+(border_width*scale),y+height-(border_height*scale),side_scale_factor_w,scale,color,alpha); | ||
|
||
// Inside | ||
draw_sprite_part_ext(sprite,subimg,border,border,side_length_raw_w,side_length_raw_h,x+(border*scale),y+(border*scale),side_scale_factor_w,side_scale_factor_h,color,alpha); | ||
draw_sprite_part_ext(sprite,subimg,border_width,border_height,side_length_raw_w,side_length_raw_h,x+(border_width*scale),y+(border_height*scale),side_scale_factor_w,side_scale_factor_h,color,alpha); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5 Bytes
(100%)
...s/0a1cd7ff-d8e6-4fbb-adaf-2f23a9d93b8c/51a137eb-68e1-4c5e-96ac-2def137bfae0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.