1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-13 01:03:07 +00:00

Add files via upload

This commit is contained in:
NIyue 2024-11-21 19:10:57 +08:00 committed by GitHub
parent 9c3e84a41a
commit 892e4fd4dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -175,7 +175,48 @@ func resize_bitmap_values(
else: else:
project.selection_offset.y = 0 project.selection_offset.y = 0
clear() clear()
smaller_image.resize(new_size.x, new_size.y, Image.INTERPOLATE_NEAREST)
var is_ellipse_select := true
var w := smaller_image.get_width()
var h := smaller_image.get_height()
var ellipse_select := DrawingAlgos.get_ellipse_points(Vector2.ZERO, Vector2i(w,h))
var x_min := []
var x_max := []
x_min.resize(h)
x_max.resize(h)
# Determine x_min and x_max of y
for i in ellipse_select.size()/2:
i*=2
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 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:
x_min[y] = xmin
x_max[y] = xmax
else:
if x_min[y] != null && x_min[y] > xmin:
x_min[y] = xmin
if x_max[y] != null && x_max[y] < xmax:
x_max[y] = xmax
# Determine whether the selection is an ellipse selection
for y in range(h):
if !is_ellipse_select:
break
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]):
is_ellipse_select = false
break
# if selection is an ellipse selection, resized as standard ellipse
if !is_ellipse_select:
smaller_image.resize(new_size.x, new_size.y, Image.INTERPOLATE_BILINEAR)
else:
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))
for p in new_ellipse_select:
resized_img.set_pixel(p.x, p.y, Color(1, 1, 1, 1))
smaller_image = resized_img
if flip_hor: if flip_hor:
smaller_image.flip_x() smaller_image.flip_x()
if flip_ver: if flip_ver: