Exemple #1
1
func update(screen *ebiten.Image) error {
	if ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
		count++
	}

	mx, my := ebiten.CursorPosition()

	if ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) {
		op := &ebiten.DrawImageOptions{}
		op.GeoM.Translate(float64(mx), float64(my))
		op.ColorM.Scale(1.0, 0.25, 0.25, 1.0)
		theta := 2.0 * math.Pi * float64(count%60) / 60.0
		op.ColorM.Concat(ebiten.RotateHue(theta))
		if err := canvasImage.DrawImage(brushImage, op); err != nil {
			return err
		}
	}

	if err := screen.DrawImage(canvasImage, nil); err != nil {
		return err
	}

	if err := ebitenutil.DebugPrint(screen, fmt.Sprintf("(%d, %d)", mx, my)); err != nil {
		return err
	}
	return nil
}
Exemple #2
0
func update(screen *ebiten.Image) error {
	count++
	w, h := gophersImage.Size()
	op := &ebiten.DrawImageOptions{}
	op.GeoM.Translate(float64(screenWidth-w)/2, float64(screenHeight-h)/2)
	op.ColorM.Concat(ebiten.RotateHue(float64(count%360) * 2 * math.Pi / 360))
	if err := screen.DrawImage(gophersImage, op); err != nil {
		return err
	}
	return nil
}