【发布时间】:2014-06-10 13:00:32
【问题描述】:
我正在尝试获取 NSGradient 并将其保存为 RubyMotion 中的图像,但我无法让它工作。这是我到目前为止的代码:
gradient = NSGradient.alloc.initWithColors(colors,
atLocations: locations.to_pointer(:double),
colorSpace: NSColorSpace.genericRGBColorSpace
)
size = Size(width, height)
image = NSImage.imageWithSize(size, flipped: false, drawingHandler: lambda do |rect|
gradient.drawInRect(rect, angle: angle)
true
end)
data = image.TIFFRepresentation
data.writeToFile('output.tif', atomically: false)
运行正常,但保存的文件为空白,没有图像数据。谁能帮我指出正确的方向?
【问题讨论】:
标签: macos rubymotion nsimage nsgradient