本文整理汇总了Golang中github.com/krig/Go-SDL2/sdl.Renderer类的典型用法代码示例。如果您正苦于以下问题:Golang Renderer类的具体用法?Golang Renderer怎么用?Golang Renderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Renderer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Texture
func (cfg *Config) Texture(rend *sdl.Renderer, key string) *sdl.Texture {
surface := sdl.Load(cfg.data[key])
if surface == nil {
log.Fatal("Failed to load " + cfg.data[key])
}
defer surface.Free()
return rend.CreateTextureFromSurface(surface)
}
开发者ID:krig,项目名称:podcast-studio,代码行数:8,代码来源:config.go
示例2: DrawLink
func (node *Node) DrawLink(rend *sdl.Renderer) {
if node.next != nil {
rend.SetDrawColor(hexcolor(0x15f0e1))
p0 := node.Pos
p1 := node.next.Pos
rend.DrawLine(p0.X+p0.W/2, p0.Y+p0.H/2, p1.X+p1.W/2, p1.Y+p1.H/2)
}
}
开发者ID:krig,项目名称:podcast-studio,代码行数:8,代码来源:studio.go
示例3: Draw
func (button *Button) Draw(rend *sdl.Renderer) {
w := button.Pos.W
state := button.State
if state > 2 {
state = 2
}
rend.Copy(button.texture, &sdl.Rect{int32(state) * w, 0, button.Pos.W, button.Pos.H}, &button.Pos)
}
开发者ID:krig,项目名称:podcast-studio,代码行数:8,代码来源:ui.go
示例4: RenderTextToTexture
func RenderTextToTexture(r *sdl.Renderer, f *ttf.Font, text string, color sdl.Color) (*sdl.Texture, int, int) {
textw, texth, err := f.SizeText(text)
if err != nil {
log.Fatal(err)
}
txt_surface := f.RenderText_Blended(text, color)
txt_tex := r.CreateTextureFromSurface(txt_surface)
txt_surface.Free()
return txt_tex, textw, texth
}
开发者ID:jbondeson,项目名称:Go-SDL2,代码行数:10,代码来源:test.go
示例5: Update
func (label *Label) Update(rend *sdl.Renderer) {
textw, texth, err := label.Font.SizeText(label.Text)
if err != nil {
log.Fatal(err)
}
txt_surface := label.Font.RenderText_Blended(label.Text, label.Color)
if label.texture != nil {
label.texture.Destroy()
}
label.texture = rend.CreateTextureFromSurface(txt_surface)
txt_surface.Free()
label.texwidth = int32(textw)
label.texheight = int32(texth)
}
开发者ID:krig,项目名称:podcast-studio,代码行数:14,代码来源:ui.go
示例6: studioUpdate
func studioUpdate(window *sdl.Window, rend *sdl.Renderer, screen *Screen) bool {
var event sdl.Event
running := true
for (&event).Poll() {
switch e := (&event).Get().(type) {
case sdl.QuitEvent:
running = false
case sdl.KeyboardEvent:
if e.Keysym.Keycode == sdl.K_ESCAPE {
running = false
}
case sdl.MouseMotionEvent:
screen.stack.OnMouseMotionEvent(&e)
case sdl.MouseButtonEvent:
screen.stack.OnMouseButtonEvent(&e)
}
}
neww, newh := window.GetSize()
screen.UpdateLayout(sdl.Rect{0, 0, int32(neww), int32(newh)})
//screen.UpdateAnimations(framerate.Delta())
rend.SetDrawBlendMode(sdl.BLENDMODE_NONE)
rend.SetDrawColor(screen.rsc.BackgroundColor)
rend.Clear()
rend.SetDrawBlendMode(sdl.BLENDMODE_BLEND)
screen.Draw(rend)
rend.Present()
screen.framerate.FramerateDelay()
return running
}
开发者ID:krig,项目名称:podcast-studio,代码行数:36,代码来源:studio.go
示例7: Draw
func (node *Node) Draw(rend *sdl.Renderer) {
if node.dragging {
node.curr.X += (node.goal.X - node.curr.X) * (15.0 / 30.0)
node.curr.Y += (node.goal.Y - node.curr.Y) * (15.0 / 30.0)
node.Pos.X = int32(node.curr.X)
node.Pos.Y = int32(node.curr.Y)
node.label.Pos = node.Pos
}
clr := node.color
if !node.dragging {
rend.SetDrawColor(clr)
rend.FillRect(&node.Pos)
}
rend.SetDrawColor(lighten(clr, 19))
rend.DrawRect(&node.Pos)
node.label.Draw(rend)
if node.menu.Visible {
node.menu.Draw(rend)
}
}
开发者ID:krig,项目名称:podcast-studio,代码行数:22,代码来源:studio.go
注:本文中的github.com/krig/Go-SDL2/sdl.Renderer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论