mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-13 01:03:07 +00:00
Update SelectionMap.gd
This commit is contained in:
parent
ccf4d6ffd2
commit
6c37c68acf
|
@ -179,17 +179,25 @@ func resize_bitmap_values(
|
||||||
var is_ellipse_select := true
|
var is_ellipse_select := true
|
||||||
var w := smaller_image.get_width()
|
var w := smaller_image.get_width()
|
||||||
var h := smaller_image.get_height()
|
var h := smaller_image.get_height()
|
||||||
var ellipse_select := DrawingAlgos.get_ellipse_points(Vector2.ZERO, Vector2i(w,h))
|
var ellipse_select := DrawingAlgos.get_ellipse_points(Vector2.ZERO, Vector2i(w, h))
|
||||||
var x_min := []
|
var x_min := []
|
||||||
var x_max := []
|
var x_max := []
|
||||||
x_min.resize(h)
|
x_min.resize(h)
|
||||||
x_max.resize(h)
|
x_max.resize(h)
|
||||||
# Determine x_min and x_max of y
|
# Determine x_min and x_max of y
|
||||||
for i in ellipse_select.size()/2:
|
for i in ellipse_select.size() / 2:
|
||||||
i*=2
|
i *= 2
|
||||||
var y := ellipse_select[i].y
|
var y := ellipse_select[i].y
|
||||||
var xmin := ellipse_select[i].x if ellipse_select[i].x < ellipse_select[i+1].x else ellipse_select[i+1].x
|
var xmin := (
|
||||||
var xmax := ellipse_select[i].x if ellipse_select[i].x >= ellipse_select[i+1].x else ellipse_select[i+1].x
|
ellipse_select[i].x
|
||||||
|
if ellipse_select[i].x < ellipse_select[i + 1].x
|
||||||
|
else ellipse_select[i + 1].x
|
||||||
|
)
|
||||||
|
var xmax := (
|
||||||
|
ellipse_select[i].x
|
||||||
|
if ellipse_select[i].x >= ellipse_select[i + 1].x
|
||||||
|
else ellipse_select[i + 1].x
|
||||||
|
)
|
||||||
|
|
||||||
if x_min[y] == null && x_max[y] == null:
|
if x_min[y] == null && x_max[y] == null:
|
||||||
x_min[y] = xmin
|
x_min[y] = xmin
|
||||||
|
@ -200,7 +208,7 @@ func resize_bitmap_values(
|
||||||
if x_max[y] != null && x_max[y] < xmax:
|
if x_max[y] != null && x_max[y] < xmax:
|
||||||
x_max[y] = xmax
|
x_max[y] = xmax
|
||||||
# too small to be rectangular selection
|
# too small to be rectangular selection
|
||||||
if x_min[0] == 0 && x_max[0] == w-1:
|
if x_min[0] == 0 && x_max[0] == w - 1:
|
||||||
is_ellipse_select = false
|
is_ellipse_select = false
|
||||||
# if ellipse is too small, ellipse_select doesn't quite cover the true elliptical selection
|
# if ellipse is too small, ellipse_select doesn't quite cover the true elliptical selection
|
||||||
for y in range(h):
|
for y in range(h):
|
||||||
|
@ -211,7 +219,7 @@ func resize_bitmap_values(
|
||||||
if !is_ellipse_select:
|
if !is_ellipse_select:
|
||||||
break
|
break
|
||||||
for x in range(w):
|
for x in range(w):
|
||||||
if smaller_image.get_pixel(x,y) == Color(1,1,1,1) && (x < x_min[y] || x > x_max[y]):
|
if smaller_image.get_pixel(x, y) == Color(1, 1, 1, 1) && (x < x_min[y] || x > x_max[y]):
|
||||||
is_ellipse_select = false
|
is_ellipse_select = false
|
||||||
break
|
break
|
||||||
# if selection is an ellipse selection, resized as standard ellipse
|
# if selection is an ellipse selection, resized as standard ellipse
|
||||||
|
@ -219,7 +227,9 @@ func resize_bitmap_values(
|
||||||
smaller_image.resize(new_size.x, new_size.y, Image.INTERPOLATE_BILINEAR)
|
smaller_image.resize(new_size.x, new_size.y, Image.INTERPOLATE_BILINEAR)
|
||||||
else:
|
else:
|
||||||
var resized_img := Image.create(new_size.x, new_size.y, false, smaller_image.get_format())
|
var resized_img := Image.create(new_size.x, new_size.y, false, smaller_image.get_format())
|
||||||
var new_ellipse_select := DrawingAlgos.get_ellipse_points_filled(Vector2.ZERO, Vector2i(new_size.x,new_size.y))
|
var new_ellipse_select := DrawingAlgos.get_ellipse_points_filled(
|
||||||
|
Vector2.ZERO, Vector2i(new_size.x, new_size.y)
|
||||||
|
)
|
||||||
for p in new_ellipse_select:
|
for p in new_ellipse_select:
|
||||||
resized_img.set_pixel(p.x, p.y, Color(1, 1, 1, 1))
|
resized_img.set_pixel(p.x, p.y, Color(1, 1, 1, 1))
|
||||||
smaller_image = resized_img
|
smaller_image = resized_img
|
||||||
|
|
Loading…
Reference in a new issue