當前位置: 首頁>>代碼示例>>Golang>>正文


Golang draw.Display類代碼示例

本文整理匯總了Golang中code/google/com/p/goplan9/draw.Display的典型用法代碼示例。如果您正苦於以下問題:Golang Display類的具體用法?Golang Display怎麽用?Golang Display使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Display類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: redraw

/*
 *	Redraws the world. (What world we have.)
 *	This is the "view" code.
 */
func redraw(d *draw.Display, resized bool) {
	if resized {
		if err := d.Attach(draw.Refmesg); err != nil {
			log.Fatalf("can't reattach to window: %v", err)
		}
	}

	// draw coloured rects at mouse positions
	// first param is the clip rectangle. which can be 0. meaning no clip?
	var clipr image.Rectangle
	fmt.Printf("empty clip? %v\n", clipr)
	d.ScreenImage.Draw(clipr, d.White, nil, image.ZP)
	d.Flush(true)
}
開發者ID:rjkroege,項目名稱:paint,代碼行數:18,代碼來源:main.go

示例2: fixfont

func (w *awin) fixfont() {
	ctl := make([]byte, 1000)
	w.Seek("ctl", 0, 0)
	n, err := w.Read("ctl", ctl)
	if err != nil {
		return
	}
	f := strings.Fields(string(ctl[:n]))
	if len(f) < 8 {
		return
	}
	w.tab, _ = strconv.Atoi(f[7])
	if w.tab == 0 {
		return
	}
	name := f[6]
	if w.fontName == name {
		return
	}
	all.Lock()
	defer all.Unlock()
	if font := all.f[name]; font != nil {
		w.font = font
		w.fontName = name
		return
	}
	var disp *draw.Display = nil
	font, err := disp.OpenFont(name)
	if err != nil {
		return
	}
	if all.f == nil {
		all.f = make(map[string]*draw.Font)
	}
	all.f[name] = font
	w.font = font
}
開發者ID:amrhassan,項目名稱:rsc,代碼行數:37,代碼來源:acme.go

示例3: Play

func Play(pp []Piece, d *draw.Display) {
	pieces = pp
	N = len(pieces[0].d)
	initPieces()
	display = d
	screen = d.ScreenImage

	mousectl = d.InitMouse()
	kbdctl = d.InitKeyboard()
	rand.Seed(int64(time.Now().UnixNano() % (1e9 - 1)))
	for i, col := range txpix {
		tx[i], _ = d.AllocImage(image.Rect(0, 0, 1, 1), screen.Pix, true, col)
	}
	whitemask, _ = display.AllocImage(image.Rect(0, 0, 1, 1), draw.ARGB32, true, 0x7F7F7F7F)
	tsleep = 50
	timerc = time.Tick(time.Duration(tsleep/2) * time.Millisecond)
	suspc = make(chan bool)
	mousec = make(chan draw.Mouse)
	kbdc = make(chan rune)
	go suspproc()
	redraw(false)
	play()
}
開發者ID:hualet,項目名稱:golang-workspace,代碼行數:23,代碼來源:xs.go

示例4: Init

func (m *SpacewarPDP1) Init(d *draw.Display) {
	m.disp = d
	m.mc = d.InitMouse()
	m.kc = d.InitKeyboard()
	m.screen = d.ScreenImage
	m.dx = m.screen.R.Dx()
	m.dy = m.screen.R.Dy()
	m.pix = make([][]uint8, m.dy)
	m.oldpix = make([][]uint8, m.dy)
	for i := range m.pix {
		m.pix[i] = make([]uint8, m.dx)
		m.oldpix[i] = make([]uint8, m.dx)
	}
	m.cmap = make([]*draw.Image, 256)
	for i := range m.cmap {
		var r, g, b draw.Color
		r = draw.Color(min(0, 255))
		g = draw.Color(min(i*2, 255))
		b = draw.Color(min(0, 255))
		m.cmap[i], _ = d.AllocImage(image.Rect(0, 0, 1, 1), d.ScreenImage.Pix, true, r<<24|g<<16|b<<8|0xff)
	}
	m.screen.Draw(m.screen.R, d.Black, nil, image.ZP)
}
開發者ID:postfix,項目名稱:GoProxyHunt,代碼行數:23,代碼來源:spacewar.go


注:本文中的code/google/com/p/goplan9/draw.Display類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。