本文整理匯總了Golang中github.com/hajimehoshi/ebiten/ebitenutil.NewImageFromFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewImageFromFile函數的具體用法?Golang NewImageFromFile怎麽用?Golang NewImageFromFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewImageFromFile函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
var err error
gophersImage, _, err = ebitenutil.NewImageFromFile("_resources/images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
fiveyearsImage, _, err = ebitenutil.NewImageFromFile("_resources/images/fiveyears.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
maskImage, err = ebiten.NewImage(screenWidth, screenHeight, ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
as := image.Point{128, 128}
a := image.NewAlpha(image.Rectangle{image.ZP, as})
for j := 0; j < as.Y; j++ {
for i := 0; i < as.X; i++ {
r := as.X / 2
d := math.Sqrt(float64((i-r)*(i-r) + (j-r)*(j-r)))
b := uint8(max(0, min(0xff, 3*0xff-int(d*3*0xff)/r)))
a.SetAlpha(i, j, color.Alpha{b})
}
}
spotLightImage, err = ebiten.NewImageFromImage(a, ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Masking (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}
示例2: init
func init() {
var err error
imageBlocks, _, err = ebitenutil.NewImageFromFile("images/blocks/blocks.png", ebiten.FilterNearest)
if err != nil {
panic(err)
}
}
示例3: init
func init() {
var err error
keyboardImage, _, err = ebitenutil.NewImageFromFile("images/keyboard/keyboard.png", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
}
示例4: init
func init() {
var err error
imageBackground, _, err = ebitenutil.NewImageFromFile("_resources/images/blocks/background.png", ebiten.FilterNearest)
if err != nil {
panic(err)
}
}
示例5: init
func init() {
dir := ""
arcadeFontPath := filepath.Join(dir, "images", "arcadefont.png")
arcadeFontImage, _, err := ebitenutil.NewImageFromFile(arcadeFontPath, ebiten.FilterNearest)
if err != nil {
panic(err)
}
ArcadeFont = &Font{arcadeFontImage, 32, 16, 8, 8}
}
示例6: main
func main() {
var err error
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
if err != nil {
log.Fatal(err)
}
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Rotate (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}
示例7: init
func init() {
var err error
// Background
imageGameBG, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterLinear)
if err != nil {
panic(err)
}
// Windows
imageWindows, err = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
if err != nil {
panic(err)
}
// Windows: Field
x, y := fieldWindowPosition()
if err := drawWindow(imageWindows, x, y, fieldWidth, fieldHeight); err != nil {
panic(err)
}
// Windows: Next
x, y = nextWindowLabelPosition()
if err := common.ArcadeFont.DrawTextWithShadow(imageWindows, "NEXT", x, y, 1, fontColor); err != nil {
panic(err)
}
x, y = nextWindowPosition()
if err := drawWindow(imageWindows, x, y, 5*blockWidth, 5*blockHeight); err != nil {
panic(err)
}
// Windows: Score
x, y = scoreTextBoxPosition()
if err := drawTextBox(imageWindows, "SCORE", x, y, textBoxWidth()); err != nil {
panic(err)
}
// Windows: Level
x, y = levelTextBoxPosition()
if err := drawTextBox(imageWindows, "LEVEL", x, y, textBoxWidth()); err != nil {
panic(err)
}
// Windows: Lines
x, y = linesTextBoxPosition()
if err := drawTextBox(imageWindows, "LINES", x, y, textBoxWidth()); err != nil {
panic(err)
}
// Gameover
imageGameover, err = ebiten.NewImage(ScreenWidth, ScreenHeight, ebiten.FilterNearest)
if err != nil {
panic(err)
}
imageGameover.Fill(color.NRGBA{0x00, 0x00, 0x00, 0x80})
y = (ScreenHeight - blockHeight) / 2
if err := drawTextWithShadowCenter(imageGameover, "GAME OVER", 0, y, 1, color.White, ScreenWidth); err != nil {
panic(err)
}
}
示例8: init
func init() {
dir := ""
if runtime.GOARCH != "js" {
// Get the path of this file (font.go).
_, path, _, _ := runtime.Caller(0)
path = filepath.Dir(path)
dir = filepath.Join(path, "..")
}
arcadeFontPath := filepath.Join(dir, "images", "arcadefont.png")
arcadeFontImage, _, err := ebitenutil.NewImageFromFile(arcadeFontPath, ebiten.FilterNearest)
if err != nil {
panic(err)
}
ArcadeFont = &Font{arcadeFontImage, 32, 16, 8, 8}
}