Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Improve TextureProgress.set_radial_initial_angle() by removing loops #99434

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/classes/TextureProgress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</member>
<member name="radial_initial_angle" type="float" setter="set_radial_initial_angle" getter="get_radial_initial_angle" default="0.0">
Starting angle for the fill of [member texture_progress] if [member fill_mode] is [constant FILL_CLOCKWISE] or [constant FILL_COUNTER_CLOCKWISE]. When the node's [code]value[/code] is equal to its [code]min_value[/code], the texture doesn't show up at all. When the [code]value[/code] increases, the texture fills and tends towards [member radial_fill_degrees].
[b]Note:[/b] [member radial_initial_angle] is wrapped between [code]0[/code] and [code]360[/code] degrees (inclusive).
</member>
<member name="stretch_margin_bottom" type="int" setter="set_stretch_margin" getter="get_stretch_margin" default="0">
The height of the 9-patch's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders.
Expand Down
11 changes: 6 additions & 5 deletions scene/gui/texture_progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "texture_progress.h"

#include "core/engine.h"
#include "math.h"

void TextureProgress::set_under_texture(const Ref<Texture> &p_texture) {
under = p_texture;
Expand Down Expand Up @@ -577,12 +578,12 @@ int TextureProgress::get_fill_mode() {
}

void TextureProgress::set_radial_initial_angle(float p_angle) {
while (p_angle > 360) {
p_angle -= 360;
}
while (p_angle < 0) {
p_angle += 360;
ERR_FAIL_COND_MSG(!isfinite(p_angle), "Angle is non-finite.");

if (p_angle < 0.0 || p_angle > 360.0) {
p_angle = Math::fposmod(p_angle, 360.0f);
}

rad_init_angle = p_angle;
update();
}
Expand Down
Loading