Questions tagged [nsgradient]

The NSGradient class provides support for drawing gradient fill colors, also known as shadings in Quartz. This class provides convenience methods for drawing radial or linear (axial) gradients for rectangles and NSBezierPath objects. It also supports primitive methods that let you customize the shape of the gradient fill.

18 questions
2
votes
1 answer

NSImage +imageWithPatternColor: and NSGradient - Cocoa/Mac

I am drawing on a custom view an NSGradient like this: - (void)drawRect: (NSRect)dirtyRect { NSGradient* g = [[NSGradient alloc] initWithStartingColor: _color endingColor: [NSColor clearColor]]; [g drawInRect: [self bounds] angle:…
Alex
  • 5,009
  • 3
  • 39
  • 73
2
votes
2 answers

NSScrollView messes up NSGradient (corruption)

I have a custom box that I've made that is a subclass of NSBox. I override the drawRect: method and draw a gradient in it like this (assuming I already have a start & end color): -(void)drawRect:(NSRect)dirtyRect { NSGradient *gradient =…
sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
1
vote
1 answer

CGContextSetFill with gradient

I currently have a function where I draw a QR code + (void)drawQRCode:(QRcode *)code context:(CGContextRef)ctx size:(CGFloat)size {} Currently, I can set the color including the colorspace using the following: CGContextSetFillColorWithColor(ctx,…
1
vote
1 answer

Textured NSWindow Background Gradient

I am trying to generate my own textured NSWindow so it appears with a different gradient to the default metallic appearing one. So far I've subclassed NSWindow with no success as below. import Cocoa class PSWindow: NSWindow { override…
Kristian Matthews
  • 800
  • 3
  • 14
  • 28
1
vote
2 answers

How do I draw NSGradient to NSImage?

I'm trying to take an NSGradient and save it as an image in RubyMotion, but I can't get it to work. This is the code I have so far: gradient = NSGradient.alloc.initWithColors(colors, atLocations: locations.to_pointer(:double), colorSpace:…
Ryan LeFevre
  • 643
  • 4
  • 12
1
vote
4 answers

Creating An Array of CGFloat for Gradient Locations

I'm trying to create a gradient color out of an array of dictionary (colorArray2). This dictionary contains 5 keys: r, g, b, a, p. r, g, b, a are component values (strings), p being the location. I'm trying to create a gradient color with…
El Tomato
  • 6,479
  • 6
  • 46
  • 75
1
vote
2 answers

Convert NSGradient to NSColor

Is it possible to convert an NSGradient to an NSColor - (void) viewWillDraw { NSGradient *grad = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]]; [super…
benj9a4
  • 101
  • 2
  • 8
0
votes
1 answer

NSGradient problem with deleting color - Cocoa/Objective-C

I'm using an NSGradient for some stuff and at some point I need to add/change/delete colors. Now NSGradient is immutable as far as I know so the only way I know how to do this is by creating a new gradient and changing the colors and their locations…
Alex
  • 5,009
  • 3
  • 39
  • 73
0
votes
1 answer

Turn NSGradient into NSColor in Swift

I am trying to make an MKPolyline for a SwiftUI map where it shows a persons location for a day and I want a gradient changing from blue to green from the first point in their location to the last point in blue. I have this code renderer.strokeColor…
WilliamD47
  • 129
  • 6
0
votes
1 answer

Button with gradient like tint color for segmented control

I should to reproduce this behavior I've tried using NSGradient with a simple linear gradient in order to fill it but it's a poor result. What kind of gradient is it?
danielemm
  • 1,636
  • 1
  • 14
  • 24
0
votes
1 answer

How can I create a NSGradient from an array of colors and floats?

I have an array of NSColors, and an array of CGFloats signifying gradient stops. I can't figure out how to use these arrays to initialize a NSGradient. I tried making these into an array of (NSColor, CGFloat)s, but NSGradient(colorsAndLocations:…
Ky -
  • 30,724
  • 51
  • 192
  • 308
0
votes
1 answer

NSGradient into NSColor

OK, long story short: I'm using (embedded into the bundle) FontAwesome I'm using it as the font in some custom NSButtons In the NSButton subclass I want to colour them, exactly the way the Xcode tab items are coloured This is how I'm setting the…
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
0
votes
2 answers

Change NSGradient colors in OSX 10.7 and 10.8

I have a NSView subclass named OneView with the following code: #import "OneView.h" @interface OneView () @property (strong, nonatomic) NSGradient *gradient; @end @implementation OneView - (void)drawRect:(NSRect)dirtyRect { [super…
wigging
  • 8,492
  • 12
  • 75
  • 117
0
votes
2 answers

Interpolating gradient colors (as with NSGradient) on iOS?

AppKit is not available in iOS, so I was looking for a replacement. Specifically, I was looking for a replacement method for: - (NSColor *)interpolatedColorAtLocation: (CGFloat)location I need a way to define a gradient, and lookup a colour value…
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
0
votes
1 answer

What is "index" in NSGradient getColor:location:atIndex?

In the following NSGradient method: - (void)getColor:(NSColor **)color location:(CGFloat *)location atIndex:(NSInteger)index What is index? The documentation says index of the colour I want. But I thought the point of this method is that it tells…
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
1
2