Skip to content

Commit

Permalink
Expanded Screenshot Calculus to drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
andremcorreia committed Jan 30, 2025
1 parent dbc39eb commit 222402c
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions tangran/Scenes/Main_scene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,12 @@ func get_board_screen():
var height = 540

var image = get_viewport().get_texture().get_image()

var _width = image.get_width()
var _height = image.get_height()

var multH = (_height/1080.0)
var multW = (_width/1920.0)
print("Width:", _width, " Height:", _height)
print("MultH:", multH, " MultW:", multW)

print(abs(multH-multW)/2)
var region

if multH > multW:
Expand All @@ -317,14 +314,36 @@ func get_board_screen():
return image

func get_piece_drawer_screen():
var pos_x = get_node("Arena/ArenaPieceDrawer/VOrigin").global_position.x
var pos_y = get_node("Arena/ArenaPieceDrawer/VOrigin").global_position.y
var width = abs(get_node("Arena/ArenaPieceDrawer/VUpperRightCorner").global_position.x - pos_x)
var height = abs(get_node("Arena/ArenaPieceDrawer/VBottomLeftCorner").global_position.y - pos_y)
var pos_x = 1600
var pos_y = 425
var width = 210
var height = 210

var region = Rect2(pos_x*1.67,pos_y*1.67,width*1.67,height*1.67)
var image = get_viewport().get_texture().get_image()

var image = get_viewport().get_texture().get_image().get_region(region)
var _width = image.get_width()
var _height = image.get_height()
var multH = (_height/1080.0)
var multW = (_width/1920.0)

var region

if multH > multW:
region = Rect2(0, _height*(abs(multH-multW)/2), _width, _height - _height*(abs(multH-multW)))
image = image.get_region(region)
if multW > multH:
region = Rect2(_width*(abs(multH-multW)/2), 0, _width - _width*(abs(multH-multW)), _height)
image = image.get_region(region)

_width = image.get_width()
_height = image.get_height()
multH = (_height/1080.0)
multW = (_width/1920.0)

region = Rect2(pos_x*multW, pos_y*multH, width*multW, height*multH)

image = image.get_region(region)


return image

Expand Down

0 comments on commit 222402c

Please sign in to comment.