Reduce usages of Gosu.clip_to in Background

This commit is contained in:
2026-03-27 11:18:55 -05:00
parent dfb9378c6d
commit 3b5902fef5

View File

@@ -21,19 +21,27 @@ module CyberarmEngine
end end
def draw def draw
Gosu.clip_to(@x, @y, @width, @height) do if @angle.zero?
Gosu.draw_quad( render
@top_left.x, @top_left.y, @paint.top_left, else
@top_right.x, @top_right.y, @paint.top_right, Gosu.clip_to(@x, @y, @width, @height) do
@bottom_right.x, @bottom_right.y, @paint.bottom_right, render
@bottom_left.x, @bottom_left.y, @paint.bottom_left, end
@z
)
end end
debug_outline if @debug debug_outline if @debug
end end
def render
Gosu.draw_quad(
@top_left.x, @top_left.y, @paint.top_left,
@top_right.x, @top_right.y, @paint.top_right,
@bottom_right.x, @bottom_right.y, @paint.bottom_right,
@bottom_left.x, @bottom_left.y, @paint.bottom_left,
@z
)
end
def update def update
@top_left.x = @x @top_left.x = @x
@top_left.y = @y @top_left.y = @y
@@ -146,13 +154,3 @@ module CyberarmEngine
end end
end end
end end
# Add <=> method to support Range based gradients
# NOTE: Disabled, causes stack overflow 🙃
# module Gosu
# class Color
# def <=>(_other)
# self
# end
# end
# end