diff --git a/src/cmd/test/main.go b/src/cmd/test/main.go index 7c4820d..3937340 100644 --- a/src/cmd/test/main.go +++ b/src/cmd/test/main.go @@ -143,7 +143,7 @@ func main() { gx.MaxColorV, }, Visible: true, - //Shader: gx.SolidWhiteColorShader, + Shader: gx.SolidWhiteColorShader, }) e.Run() } diff --git a/src/gx/rect.go b/src/gx/rect.go index e224e73..13dfbb2 100644 --- a/src/gx/rect.go +++ b/src/gx/rect.go @@ -79,10 +79,11 @@ func (r DrawableRectangle) Draw( return } + v := 1 opts := &ebiten.DrawRectShaderOptions{ GeoM: m, Images: [4]*Image{ - NewImage(1, 1), + NewImage(v, v), nil, nil, nil, @@ -92,6 +93,6 @@ func (r DrawableRectangle) Draw( //w := int(r.W * r.T.S.X) //h := int(r.H * r.T.S.Y) - i.DrawRectShader(1, 1, r.Shader, opts) + i.DrawRectShader(v, v, r.Shader, opts) } diff --git a/src/gx/shader.go b/src/gx/shader.go index 1cf7980..c60e23b 100644 --- a/src/gx/shader.go +++ b/src/gx/shader.go @@ -8,12 +8,37 @@ import ( type Shader = ebiten.Shader var ( - // The shader does not + // The shader is for example only. SolidWhiteColorShader = MustNewShader([]byte(` package main - func Fragment(p vec4, coord vec2, color vec4) vec4 { - return vec4(1, 1, 1, 1) + func Fragment(position vec4, texCoord vec2, color vec4) vec4 { + //ts := imageSrcTextureSize() + + _, size := imageSrcRegionOnTexture() + /*return vec4( + position.y/size.y, + position.y/size.y, + position.y/size.y, + position.y/size.y, + )*/ + py := int(position.y / size.y) % 5 + px := int(position.x / size.x) % 5 + if py >= 1 && px >= 1 { + return vec4( + 1, + 0, + 0, + 1, + ) + } + + return vec4( + 0, + 1, + 0, + 1, + ) } `)) )