/* * Copyright (c) 2023, MacDue * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Gfx { struct ColorStop { Color color; float position = AK::NaN; Optional transition_hint = {}; }; class GradientLine; inline float normalized_gradient_angle_radians(float gradient_angle) { // Adjust angle so 0 degrees is bottom float real_angle = 90 - gradient_angle; return real_angle * (AK::Pi / 180); } template inline float calculate_gradient_length(Size gradient_size, float sin_angle, float cos_angle) { return AK::fabs(static_cast(gradient_size.height()) * sin_angle) + AK::fabs(static_cast(gradient_size.width()) * cos_angle); } template inline float calculate_gradient_length(Size gradient_size, float gradient_angle) { float angle = normalized_gradient_angle_radians(gradient_angle); float sin_angle, cos_angle; AK::sincos(angle, sin_angle, cos_angle); return calculate_gradient_length(gradient_size, sin_angle, cos_angle); } }