英文:
Draw transparent Gtk.Window
问题
我正在尝试创建一个透明的GTK窗口来进行绘制;然而,我似乎无法弄清楚如何使用Go和go-cairo以及go-gtk来实现这一点。有人知道如何实现吗?
英文:
I'm trying to make a transparent GTK window to draw on; however, I can't seem to figure out how to implement this with Go using go-cairo and go-gtk. Does anyone know how this can be accomplished?
答案1
得分: 2
go-gtk目前还没有窗口不透明度功能,除非你自己实现它们,否则任务是不可能完成的。这可以通过gtk.go的第1392行和第1393行来证明。
至于go-cairo(我个人没有使用过),如果你查看这个链接,你会看到与这个链接兼容的功能。问题中的Go函数是:
func (self *Surface) SetSourceRGBA(red, green, blue, alpha float64) {
C.cairo_set_source_rgba(self.context, C.double(red), C.double(green), C.double(blue), C.double(alpha))
}
这是cairo_set_source_rgba的包装器。这个功能的基于C的示例可以通过plan99.net获得。
我认为目前在go-cairo中使用alpha通道来实现所需效果是最好的选择。
英文:
go-gtk doesn't have any window opacity functionality yet, making the task impossible unless you implement them yourself. This is evidenced by lines 1392 and 1393 of gtk.go.
As for go-cairo(which I haven't personally used) if you look at this, you'll see the functionality that is compatible with this. The Go function in questions is:
func (self *Surface) SetSourceRGBA(red, green, blue, alpha float64) {
C.cairo_set_source_rgba(self.context, C.double(red), C.double(green), C.double(blue), C.double(alpha))
}
which is the wrapper for cairo_set_source_rgba. A C-based example of this in action is available through plan99.net.
I would say that playing with alpha channels in go-cairo is the best bet right now to get the desired effect.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论