//
//  GSRadialGradient.h
//  GlyphsCore
//
//  Created by Florian Pircher on 17.03.23.
//  Copyright © 2023 schriftgestaltung.de. All rights reserved.
//

#import <GlyphsCore/GSGradient.h>

NS_ASSUME_NONNULL_BEGIN

/// A radial (circular/angular) gradient.
@interface GSRadialGradient : GSGradient

/// The center of the start circle, relative to the drawing bounds.
@property (nonatomic) NSPoint startCenter;
/// The center of the end circle, relative to the drawing bounds.
@property (nonatomic) NSPoint endCenter;
/// The radius of the start circle, relative to the drawing bounds.
///
/// The value is relative to the bounding rectangle in which the gradient drawn.
/// To get the absolute value, multiple the stored value by the square root of the product of the side lengths of the bounding rectangle.
@property (nonatomic) CGFloat startRadius;
/// The radius of the end circle, relative to the drawing bounds.
///
/// The value is relative to the bounding rectangle in which the gradient drawn.
/// To get the absolute value, multiple the stored value by the square root of the product of the side lengths of the bounding rectangle.
@property (nonatomic) CGFloat endRadius;
/// The rotation angle (in degrees counter-clockwise from the x-axis).
@property (nonatomic) CGFloat angle;

/// Creates a radial gradient with the given start and end circle.
- (instancetype)initWithStartCenter:(NSPoint)startCenter startRadius:(CGFloat)startRadius endCenter:(NSPoint)endCenter endRadius:(CGFloat)endRadius angle:(CGFloat)angle colorLine:(GSColorLine *)colorLine extendMode:(GSGradientExtendMode)extendMode;
/// Creates a simple radial gradient with the given center and radius.
///
/// Both circles share the same center and the start circle has a radius of 0.
- (instancetype)initWithCenter:(NSPoint)center radius:(CGFloat)radius angle:(CGFloat)angle colorLine:(GSColorLine *)colorLine extendMode:(GSGradientExtendMode)extendMode;

/// The behavior of radial gradients has changed from Glyphs 3 to Glyphs 4.
///
/// If the gradient has a parent and contains legacy values, this method normalizes `startRadius`, `endCenter`, and `endRadius`.
/// Otherwise, this method does nothing.
- (void)upgradeFromLegacyRepresentation;

@end

NS_ASSUME_NONNULL_END
