...
This commit is contained in:
parent
c535efe56b
commit
cc02da52f8
3 changed files with 32 additions and 6 deletions
|
@ -143,7 +143,7 @@ func main() {
|
|||
gx.MaxColorV,
|
||||
},
|
||||
Visible: true,
|
||||
//Shader: gx.SolidWhiteColorShader,
|
||||
Shader: gx.SolidWhiteColorShader,
|
||||
})
|
||||
e.Run()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
`))
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue