问题标签 [nsgradient]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1712 浏览

ios - 在 iOS 上插入渐变颜色(与 NSGradient 一样)?

AppKit 在 iOS 中不可用,所以我一直在寻找替代品。

具体来说,我正在寻找一种替代方法:

我需要一种方法来定义渐变,并根据输入位置 ( float) 查找颜色值。

0 投票
2 回答
1046 浏览

macos - 如何将 NSGradient 绘制到 NSImage?

我正在尝试获取 NSGradient 并将其保存为 RubyMotion 中的图像,但我无法让它工作。这是我到目前为止的代码:

它运行没有错误,但保存的文件是空白的并且没有图像数据。谁能帮我指出正确的方向?

0 投票
2 回答
208 浏览

objective-c - Change NSGradient colors in OSX 10.7 and 10.8

I have a NSView subclass named OneView with the following code:

In my AppDelegate (or could be any other class), I am trying to change the colors of the gradient by calling the changeGradient method of the OneView class:

When the view is first loaded the gradient is initialized as expected but I am unable to change the gradient from the IBAction method. I have achieved this using layer backed views but I am trying to find a way that doesn't rely on layers for backwards compatibility.

Any thoughts on why the IBAction is not changing the gradient?

enter image description here

0 投票
1 回答
703 浏览

objective-c - 将 NSGradient 转换为 NSColor

好的,长话短说:

  • 我正在使用(嵌入到包中)FontAwesome
  • 我将它用作某些自定义NSButtons中的字体
  • NSButton我想为它们着色的子类中,与 Xcode 选项卡项的着色方式完全相同

颜色渐变 Xcode

这就是我设置颜色的方式(作为简单的 NSColor):

如何将其设置为NSGradient

0 投票
1 回答
1072 浏览

swift - 纹理 NSWindow 背景渐变

我正在尝试生成我自己的纹理 NSWindow,以便它以与默认金属外观不同的渐变出现。

到目前为止,我已经将 NSWindow 子类化,但没有成功,如下所示。

我什至会以正确的方式解决这个问题吗?

0 投票
1 回答
525 浏览

swift - 如何从一组颜色和浮点数创建 NSGradient?

我有一个NSColors 数组,还有一个 s 数组CGFloat表示梯度停止。我不知道如何使用这些数组来初始化NSGradient.

我尝试将它们制作成一个 s 数组(NSColor, CGFloat),但NSGradient(colorsAndLocations:不会接受它,因为它需要可变参数:

代码 <code>let gradient = NSGradient(colorsAndLocations: colorsAndLocations)</code> 产生错误 <code>Cannot convert value of type '[(NSColor, CGFloat)]' to expected argument type '(NSColor, CGFloat)'< /代码>

并且NSGradient(colors:, atLocations:, colorSpace:)期望一个UnsafePointer我不知道如何在 Swift 中正确处理的,如果有的话。

0 投票
1 回答
74 浏览

objective-c - CGContextSetFill 渐变

我目前有一个绘制二维码的功能

目前,我可以使用以下方法设置颜色,包括颜色空间:

我正在尝试实现创建渐变的能力,我已经将两个转换NSColors为一个NSGradient- 似乎没有任何方法可以获得渐变,NSColor所以我想知道设置填充的最佳方法是什么渐变的上下文?

在此先感谢您的任何建议!