Skip to content

How to implement image stroke function??? #2941

Closed Answered by lsq51201314
lsq51201314 asked this question in Q&A
Discussion options

You must be logged in to vote
 //着色器测试
opts := &ebiten.DrawRectShaderOptions{}
opts.Uniforms = make(map[string]interface{})
opts.Uniforms["OutLine"] = []int32{1}                      //描边
opts.Uniforms["LineWidth"] = []float32{0.001}              //线宽(左上角有问题,0.001可消除)
opts.Uniforms["LineColor"] = []float32{1.0, 1.0, 1.0, 1.0} //白色

opts.Images[0] = i.image
w, h := i.GetSize()
screen.DrawRectShader(w, h, i.shader, opts)
package main

var OutLine int
var LineWidth float
var LineColor vec4

func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
	col := imageSrc0UnsafeAt(srcPos).rgba
	if OutLine == 1 && col.a == 0.0 {
        a := imageSrc0UnsafeAt(vec2(srcPos.x + LineWidth, srcPos.y)).a +
			imageSrc0UnsafeAt(vec2(sr…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lsq51201314
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #2940 on March 26, 2024 10:40.