From 8919bc809aa68706b59047a83e7b901ba8326a59 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 31 Oct 2022 23:36:07 +0900 Subject: [PATCH] ebiten: refactoring: compile-time check --- image.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/image.go b/image.go index 3edb15ebf..88e7eea18 100644 --- a/image.go +++ b/image.go @@ -527,12 +527,8 @@ type DrawTrianglesShaderOptions struct { AntiAlias bool } -func init() { - var op DrawTrianglesShaderOptions - if got, want := len(op.Images), graphics.ShaderImageCount; got != want { - panic(fmt.Sprintf("ebiten: len((DrawTrianglesShaderOptions{}).Images) must be %d but %d", want, got)) - } -} +// Check the number of images. +var _ [len(DrawTrianglesShaderOptions{}.Images)]int = [graphics.ShaderImageCount]int{} // DrawTrianglesShader draws triangles with the specified vertices and their indices with the specified shader. // @@ -673,12 +669,8 @@ type DrawRectShaderOptions struct { Images [4]*Image } -func init() { - var op DrawRectShaderOptions - if got, want := len(op.Images), graphics.ShaderImageCount; got != want { - panic(fmt.Sprintf("ebiten: len((DrawRectShaderOptions{}).Images) must be %d but %d", want, got)) - } -} +// Check the number of images. +var _ [len(DrawRectShaderOptions{}.Images)]int = [graphics.ShaderImageCount]int{} // DrawRectShader draws a rectangle with the specified width and height with the specified shader. //