mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:27:34 +00:00
PixelPaint: Add radial gradient support
This patch adds radial gradients to the gradients tool.
This commit is contained in:
parent
abcfaca3da
commit
cd33f271b1
2 changed files with 222 additions and 42 deletions
|
@ -32,12 +32,29 @@ protected:
|
|||
virtual StringView tool_name() const override { return "Gradient Tool"sv; }
|
||||
|
||||
private:
|
||||
enum class GradientMode {
|
||||
Linear,
|
||||
Radial,
|
||||
__Count,
|
||||
};
|
||||
|
||||
enum class IconStyle {
|
||||
None,
|
||||
ChangeWidthAndAngle,
|
||||
RadialWidth,
|
||||
};
|
||||
|
||||
RefPtr<GUI::Widget> m_properties_widget;
|
||||
Optional<Gfx::IntPoint> m_gradient_start;
|
||||
Optional<Gfx::IntPoint> m_gradient_center;
|
||||
Optional<Gfx::IntPoint> m_gradient_end;
|
||||
Optional<Gfx::IntPoint> m_gradient_transversal_a;
|
||||
Optional<Gfx::IntPoint> m_gradient_transversal_b;
|
||||
Gfx::IntPoint m_perpendicular_point;
|
||||
|
||||
GradientMode m_mode = GradientMode::Linear;
|
||||
int m_hardness = 25;
|
||||
|
||||
float m_gradient_half_length = 0;
|
||||
float m_physical_diagonal_layer_length = 0;
|
||||
bool m_button_pressed = false;
|
||||
|
@ -45,19 +62,23 @@ private:
|
|||
bool m_hover_over_drag_handle = false;
|
||||
bool m_hover_over_start_handle = false;
|
||||
bool m_hover_over_end_handle = false;
|
||||
bool m_hover_over_transversal_a_handle = false;
|
||||
bool m_hover_over_transversal_b_handle = false;
|
||||
int m_opacity = 100;
|
||||
bool m_use_secondary_color { false };
|
||||
Gfx::FloatLine m_gradient_begin_line;
|
||||
Gfx::FloatLine m_gradient_center_line;
|
||||
Gfx::FloatLine m_gradient_end_line;
|
||||
|
||||
void reset();
|
||||
void draw_gradient(GUI::Painter&, bool with_guidelines = false, const Gfx::FloatPoint drawing_offset = { 0.0f, 0.0f }, float scale = 1, Optional<Gfx::IntRect const&> gradient_clip = {});
|
||||
void rasterize_gradient();
|
||||
void calculate_gradient_lines();
|
||||
void update_gradient_end_and_derive_start(Gfx::IntPoint const);
|
||||
void translate_gradient_start_end(Gfx::IntPoint const delta, bool update_start_counterwise = true);
|
||||
bool has_gradient_start_end() { return m_gradient_center.has_value() && m_gradient_end.has_value() && m_gradient_start.has_value(); }
|
||||
void calculate_transversal_points(float scale_fraction);
|
||||
void draw_gradient(GUI::Painter&, bool with_guidelines = false, const Gfx::FloatPoint drawing_offset = { 0.0f, 0.0f }, float scale = 1, Optional<Gfx::IntRect const&> gradient_clip = {});
|
||||
bool has_gradient_data() { return m_gradient_center.has_value() && m_gradient_end.has_value() && m_gradient_start.has_value(); }
|
||||
void move_gradient_position(Gfx::IntPoint const movement_delta);
|
||||
void rasterize_gradient();
|
||||
void reset();
|
||||
void rotate_gradient_points(Gfx::IntPoint const delta);
|
||||
void update_gradient_with_initial_values(Gfx::IntPoint const);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue