Constructor
@:value({ rightbottom : 16, leftbottom : 16, righttop : 16, lefttop : 16 })@:glFragmentSource("#pragma header\nuniform vec4 u_px;\nbool checkRound(float x, float y, float size){\n\treturn distance(vec2(x, y) * openfl_TextureSize, openfl_TextureCoordv.xy * openfl_TextureSize) < size * openfl_TextureSize.x;\n}\nvoid main(void){\n\t#pragma body\n\tfloat xsize = u_px.x / openfl_TextureSize.x;\n\tfloat xsize_y = u_px.x / openfl_TextureSize.y;\n\tfloat ysize = u_px.y / openfl_TextureSize.x;\n\tfloat ysize_y = u_px.y / openfl_TextureSize.y;\n\tfloat zsize = u_px.z / openfl_TextureSize.x;\n\tfloat zsize_y = u_px.z / openfl_TextureSize.y;\n\tfloat wsize = u_px.w / openfl_TextureSize.x;\n\tfloat wsize_y = u_px.w / openfl_TextureSize.y;\n\tgl_FragColor = vec4(0.);\n\tif((openfl_TextureCoordv.x > xsize || openfl_TextureCoordv.y > xsize_y) && openfl_TextureCoordv.x < 0.5 && openfl_TextureCoordv.y < 0.5){\n\t\tgl_FragColor = color;\n\t}\n\tif((openfl_TextureCoordv.x < 1. - ysize || openfl_TextureCoordv.y > ysize_y) && openfl_TextureCoordv.x > 0.5 && openfl_TextureCoordv.y < 0.5){\n\t\tgl_FragColor = color;\n\t}\n\tif((openfl_TextureCoordv.x > zsize || openfl_TextureCoordv.y < 1. - zsize_y) && openfl_TextureCoordv.x < 0.5 && openfl_TextureCoordv.y > 0.5){\n\t\tgl_FragColor = color;\n\t}\n\tif((openfl_TextureCoordv.x < 1. - wsize || openfl_TextureCoordv.y < 1. - wsize_y) && openfl_TextureCoordv.x > 0.5 && openfl_TextureCoordv.y > 0.5){\n\t\tgl_FragColor = color;\n\t}\n\tif(checkRound(xsize, xsize_y, xsize) || checkRound(1. - ysize, ysize_y, ysize) || checkRound(zsize, 1. - zsize_y, zsize) || checkRound(1. - wsize, 1. - wsize_y, wsize)){\n\t\tgl_FragColor = color;\n\t}\n}")new (lefttop:Float = 16, righttop:Float = 16, leftbottom:Float = 16, rightbottom:Float = 16)
圆角遮罩
Parameters:
lefttop | 左上 |
---|
righttop | 右上 |
---|
leftbottom | 左下 |
---|
rightbottom | 右下 |
---|
Variables
@:keepu_px:ShaderParameter<Float>
Methods
@:glslcheckRound (x:Float, y:Float, size:Float):Bool
检查点是否在圆的范围内
Parameters:
Returns: