dongmi19720408 2013-03-09 19:06
浏览 121
已采纳

使用go-cairo绘画到屏幕

I'm using http://github.com/ungerik/go-cairo as a cairo library to paint to the screen. I'm completely unfamiliar with this library and cairo in general; however, I've been scouring over documentation for both this library and various cairo bindings for other languages hoping to understand how to paint to screen (unfortunately, I haven't been able to find many tutorials for painting to the screen--only for saving images as .PNGs).

This is what I have so far, and it's not producing any effect (nothing displays). Any help would be appreciated.

package main

import (
    "github.com/ungerik/go-cairo"
    "time"
)

func main() {
    surface := cairo.NewSurface (cairo.FORMAT_ARGB32, 240, 80)
    surface.SelectFontFace ("serif", cairo.FONT_SLANT_NORMAL,
        cairo.FONT_WEIGHT_BOLD)
    surface.SetFontSize(32.0)
    surface.SetSourceRGB(0.0, 0.0, 1.0)
    surface.MoveTo (10.0, 50.0)
    surface.ShowText ("Hello World")

    for {
        surface.Paint ()
        time.Sleep (1000)
    }
    //surface.Finish()
}
  • 写回答

1条回答 默认 最新

  • dslfq06464 2013-03-09 20:55
    关注

    If you are using Linux
    here's an example https://github.com/Joker/go-cairo/blob/master/example/xcb_joy.go
    you have to use a go-cairo fork https://github.com/Joker/go-cairo
    and XCB must be installed

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类