ebiten/examples/vector/main.go

78 lines
1.6 KiB
Go
Raw Normal View History

2019-04-13 17:16:18 +02:00
// Copyright 2019 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build example jsgo
package main
import (
"image/color"
"log"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/vector"
)
const (
screenWidth = 640
screenHeight = 480
)
2019-04-14 08:48:17 +02:00
func drawEbitenText(screen *ebiten.Image) {
2019-04-13 17:16:18 +02:00
var path vector.Path
2019-04-13 18:58:20 +02:00
// E
path.MoveTo(20, 20)
path.LineTo(20, 70)
path.LineTo(70, 70)
path.LineTo(70, 60)
path.LineTo(30, 60)
path.LineTo(30, 50)
path.LineTo(70, 50)
path.LineTo(70, 40)
path.LineTo(30, 40)
path.LineTo(30, 30)
path.LineTo(70, 30)
path.LineTo(70, 20)
// B
path.MoveTo(80, 20)
path.LineTo(80, 70)
path.LineTo(100, 70)
path.QuadraticCurveTo(130, 57.5, 100, 45)
path.QuadraticCurveTo(130, 32.5, 100, 20)
// TODO: Draw other letters like I, T, E, N
path.Fill(screen, color.White)
}
var counter = 0
2019-04-14 08:48:17 +02:00
func update(screen *ebiten.Image) error {
counter++
2019-04-14 08:48:17 +02:00
if ebiten.IsDrawingSkipped() {
return nil
}
2019-04-14 08:48:17 +02:00
drawEbitenText(screen)
2019-04-13 17:16:18 +02:00
return nil
}
func main() {
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Vector (Ebiten Demo)"); err != nil {
log.Fatal(err)
}
}