2022-03-08 03:13:53 -05:00
|
|
|
package funkin.shaderslmfao;
|
2021-12-04 22:38:33 -05:00
|
|
|
|
|
|
|
import flixel.system.FlxAssets.FlxShader;
|
|
|
|
import flixel.util.FlxColor;
|
|
|
|
|
|
|
|
class StrokeShader extends FlxShader
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
// MOSTLY STOLEN FROM AUSTIN EAST LOL!
|
|
|
|
// https://gist.github.com/AustinEast/d3892fdf6a6079366fffde071f0c2bae
|
|
|
|
public var width(default, set):Float = 0;
|
|
|
|
public var height(default, set):Float = 0;
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public var col(default, set):FlxColor = 0xFFFFFFFF;
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_width(val):Float
|
|
|
|
{
|
|
|
|
size.value = [val, height];
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
return val;
|
|
|
|
}
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_height(val):Float
|
|
|
|
{
|
|
|
|
size.value = [width, val];
|
|
|
|
return val;
|
|
|
|
}
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function set_col(val:FlxColor):FlxColor
|
|
|
|
{
|
|
|
|
color.value = [val.red, val.green, val.blue, val.alpha];
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
return val;
|
|
|
|
}
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
@:glFragmentSource('
|
2021-12-04 22:38:33 -05:00
|
|
|
#pragma header
|
|
|
|
|
|
|
|
uniform vec2 size;
|
|
|
|
uniform vec4 color;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 sample = flixel_texture2D(bitmap, openfl_TextureCoordv);
|
|
|
|
if (sample.a == 0.) {
|
|
|
|
float w = size.x / openfl_TextureSize.x;
|
|
|
|
float h = size.y / openfl_TextureSize.y;
|
2023-06-08 16:30:45 -04:00
|
|
|
|
2021-12-04 22:38:33 -05:00
|
|
|
if (flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x + w, openfl_TextureCoordv.y)).a != 0.
|
|
|
|
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x - w, openfl_TextureCoordv.y)).a != 0.
|
|
|
|
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x, openfl_TextureCoordv.y + h)).a != 0.
|
|
|
|
|| flixel_texture2D(bitmap, vec2(openfl_TextureCoordv.x, openfl_TextureCoordv.y - h)).a != 0.)
|
|
|
|
sample = color;
|
|
|
|
}
|
|
|
|
gl_FragColor = sample;
|
|
|
|
}
|
|
|
|
')
|
2023-01-22 22:25:45 -05:00
|
|
|
public function new(color:FlxColor = 0xFFFFFFFF, width:Float = 1, height:Float = 1)
|
|
|
|
{
|
|
|
|
super();
|
2021-12-04 22:38:33 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
col = color;
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
}
|
2021-12-04 22:38:33 -05:00
|
|
|
}
|