mirror of
https://github.com/dsward2/macSVG.git
synced 2026-03-02 18:23:58 +01:00
A few bugs were fixed for getBbox and updating selection rects and handles during animation.
81 lines
2.1 KiB
Objective-C
81 lines
2.1 KiB
Objective-C
|
|
#import "GradientView.h"
|
|
|
|
@implementation GradientView
|
|
|
|
// ============================================================================
|
|
|
|
- (void)initGradient
|
|
{
|
|
angle = 90;
|
|
NSColor * color1 = [NSColor colorWithCalibratedRed:0.7 green:0.7 blue:0.7 alpha:1.0];
|
|
NSColor * color2 = [NSColor colorWithCalibratedRed:0.75 green:0.75 blue:0.75 alpha:1.0];
|
|
NSColor * color3 = [NSColor colorWithCalibratedRed:0.8 green:0.8 blue:0.8 alpha:1.0];
|
|
NSColor * color4 = [NSColor colorWithCalibratedRed:0.85 green:0.85 blue:0.85 alpha:1.0];
|
|
NSArray * colorArray = @[color1, color2, color3, color4, color4, color3, color2, color1];
|
|
gradient = [[NSGradient alloc] initWithColors:colorArray];
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)decoder
|
|
{
|
|
self = [super initWithCoder:decoder];
|
|
if (self)
|
|
{
|
|
[self initGradient];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (instancetype)initWithFrame:(NSRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self)
|
|
{
|
|
[self initGradient];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (void)setTopColor:(NSColor *)topColor bottomColor:(NSColor *)bottomColor
|
|
{
|
|
gradient = [[NSGradient alloc] initWithStartingColor:topColor endingColor:bottomColor];
|
|
|
|
[self setNeedsDisplay:YES];
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (void)setColorStopsArray:(NSArray *)colorStopsArray
|
|
{
|
|
gradient = [[NSGradient alloc] initWithColors:colorStopsArray];
|
|
|
|
[self setNeedsDisplay:YES];
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[self setNeedsDisplay:YES];
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
- (void)drawRect:(NSRect)rect
|
|
{
|
|
[gradient drawInRect:self.bounds angle:angle];
|
|
}
|
|
|
|
// ============================================================================
|
|
|
|
@end
|
|
|
|
|
|
|