{
	"connections": [
		{
			"from": "shape",
			"from_port": 0,
			"to": "gen_outputs",
			"to_port": 0
		},
		{
			"from": "dilate_pass_4",
			"from_port": 0,
			"to": "dilate_pass_3",
			"to_port": 0
		},
		{
			"from": "iterate_buffer",
			"from_port": 0,
			"to": "dilate_pass_3",
			"to_port": 1
		},
		{
			"from": "iterate_buffer",
			"from_port": 0,
			"to": "shader_1",
			"to_port": 0
		},
		{
			"from": "shader_1",
			"from_port": 0,
			"to": "dilate_pass_1",
			"to_port": 0
		},
		{
			"from": "switch",
			"from_port": 0,
			"to": "shape",
			"to_port": 0
		},
		{
			"from": "iterate_buffer",
			"from_port": 0,
			"to": "switch",
			"to_port": 0
		},
		{
			"from": "dilate_pass_1",
			"from_port": 0,
			"to": "buffer",
			"to_port": 0
		},
		{
			"from": "buffer",
			"from_port": 0,
			"to": "dilate_pass_4",
			"to_port": 0
		},
		{
			"from": "gen_inputs",
			"from_port": 0,
			"to": "fill_preprocess_2",
			"to_port": 0
		},
		{
			"from": "fill_preprocess_2",
			"from_port": 0,
			"to": "iterate_buffer",
			"to_port": 0
		},
		{
			"from": "iterate_buffer",
			"from_port": 1,
			"to": "fill_iterate_2",
			"to_port": 0
		},
		{
			"from": "fill_iterate_2",
			"from_port": 0,
			"to": "iterate_buffer",
			"to_port": 1
		},
		{
			"from": "dilate_pass_3",
			"from_port": 0,
			"to": "buffer_3",
			"to_port": 0
		},
		{
			"from": "buffer_3",
			"from_port": 0,
			"to": "switch",
			"to_port": 1
		}
	],
	"label": "Fill",
	"longdesc": "Fills areas defined by white outlines of its input",
	"name": "fill2",
	"node_position": {
		"x": 0,
		"y": 0
	},
	"nodes": [
		{
			"name": "iterate_buffer",
			"node_position": {
				"x": -134.86264,
				"y": -362.841705
			},
			"parameters": {
				"autostop": true,
				"filter": false,
				"iterations": 50,
				"mipmap": false,
				"shrink": false,
				"size": 8
			},
			"seed": 29168,
			"seed_locked": true,
			"type": "iterate_buffer"
		},
		{
			"name": "gen_inputs",
			"node_position": {
				"x": -542.307068,
				"y": -370.662445
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "The input image whose white outlines must be filled",
					"name": "port0",
					"shortdesc": "Input",
					"type": "f"
				}
			],
			"seed": 58064,
			"type": "ios"
		},
		{
			"name": "gen_outputs",
			"node_position": {
				"x": 831.267273,
				"y": -415.662445
			},
			"parameters": {

			},
			"ports": [
				{
					"group_size": 0,
					"longdesc": "Generates fill data, to be connected to a fill companion node",
					"name": "port0",
					"shortdesc": "Output",
					"type": "fill"
				}
			],
			"seed": -4244,
			"type": "ios"
		},
		{
			"name": "gen_parameters",
			"node_position": {
				"x": -122.110138,
				"y": -589.509705
			},
			"parameters": {
				"adjust": 0,
				"remove_edges": 0,
				"size": 8
			},
			"seed": 52136,
			"type": "remote",
			"widgets": [
				{
					"label": "",
					"linked_widgets": [
						{
							"node": "iterate_buffer",
							"widget": "size"
						},
						{
							"node": "fill_preprocess_2",
							"widget": "s"
						},
						{
							"node": "fill_iterate_2",
							"widget": "s"
						},
						{
							"node": "dilate_pass_1",
							"widget": "s"
						},
						{
							"node": "buffer",
							"widget": "size"
						},
						{
							"node": "dilate_pass_4",
							"widget": "s"
						},
						{
							"node": "buffer_3",
							"widget": "size"
						}
					],
					"longdesc": "The resolution of the input image",
					"name": "size",
					"shortdesc": "Size",
					"type": "linked_control"
				},
				{
					"configurations": {
						"False": [
							{
								"node": "switch",
								"value": 0,
								"widget": "source"
							}
						],
						"True": [
							{
								"node": "switch",
								"value": 1,
								"widget": "source"
							}
						]
					},
					"label": "Remove edges",
					"linked_widgets": [
						{
							"node": "switch",
							"widget": "source"
						}
					],
					"longdesc": "Grow filled areas to remove edges",
					"name": "remove_edges",
					"shortdesc": "Remove edge",
					"type": "config_control"
				},
				{
					"label": "Adjust",
					"linked_widgets": [
						{
							"node": "shape",
							"widget": "grow"
						}
					],
					"longdesc": "Adjust the size of the area's bounding box (to compensate for removed edges)",
					"name": "adjust",
					"shortdesc": "Adjust",
					"type": "linked_control"
				}
			]
		},
		{
			"name": "shape",
			"node_position": {
				"x": 636.919922,
				"y": -415.122955
			},
			"parameters": {
				"grow": 0
			},
			"seed_int": 0,
			"shader_model": {
				"code": [
					"vec4 $(name_uv)_v = $in($(uv));",
					"vec2 $(name_uv)_a = 1.0-step(vec2(1.0), $(name_uv)_v.zw);"
				],
				"inputs": [
					{
						"default": "vec4(0.0)",
						"label": "",
						"name": "in",
						"type": "rgba"
					}
				],
				"instance": "",
				"name": "Fill Convert",
				"outputs": [
					{
						"fill": "$in($(uv))+$grow*vec4(-1.0*$(name_uv)_a, 2.0*$(name_uv)_a)",
						"type": "fill"
					}
				],
				"parameters": [
					{
						"control": "None",
						"default": 0,
						"label": "",
						"max": 0.2,
						"min": 0,
						"name": "grow",
						"step": 0.01,
						"type": "float"
					}
				]
			},
			"type": "shader"
		},
		{
			"name": "dilate_pass_3",
			"node_position": {
				"x": 178.313049,
				"y": 71.671021
			},
			"parameters": {
				"amount": 1
			},
			"seed": 50311,
			"shader_model": {
				"code": "",
				"global": "",
				"inputs": [
					{
						"default": "vec3(0.0)",
						"label": "",
						"name": "distance",
						"type": "rgb"
					},
					{
						"default": "vec4(1.0)",
						"label": "",
						"name": "source",
						"type": "rgba"
					}
				],
				"instance": "",
				"name": "Dilate pass 3",
				"outputs": [
					{
						"rgba": "$source($distance($uv).yz)*mix($distance($uv).x, 1.0, $amount)",
						"type": "rgba"
					}
				],
				"parameters": [
					{
						"control": "None",
						"default": 0,
						"label": "",
						"max": 1,
						"min": 0,
						"name": "amount",
						"step": 0.01,
						"type": "float"
					}
				]
			},
			"type": "shader"
		},
		{
			"name": "dilate_pass_4",
			"node_position": {
				"x": 177.322388,
				"y": -37.537262
			},
			"parameters": {
				"d": 1,
				"distance": 0,
				"s": 8
			},
			"seed": 50297,
			"shader_model": {
				"code": "",
				"global": [
					"float dilate_distance_euclidian(float x, float y, float d) {",
					"\treturn 1.0-sqrt((1.0-x)*(1.0-x)+y*y/d/d);",
					"}",
					"",
					"float dilate_distance_manhattan(float x, float y, float d) {",
					"\treturn 1.0-(abs(1.0-x)+abs(y)/d);",
					"}",
					"",
					"float dilate_distance_chebyshev(float x, float y, float d) {",
					"\treturn 1.0-max(abs(1.0-x), abs(y)/d);",
					"}",
					"",
					""
				],
				"includes": [
					"pack_1x32_to_2x16"
				],
				"inputs": [
					{
						"default": "vec3(0.0)",
						"function": true,
						"label": "",
						"name": "in",
						"type": "rgba"
					}
				],
				"instance": [
					"vec3 $(name)_distance_v(vec2 uv) {",
					"\tvec2 e = vec2(0.0, 1.0/$s);",
					"\tint steps = int($s*$d);",
					"\tvec3 p = vec3(pack_4x16_to_2x32($in(uv)), uv.y);",
					"\tfor (int i = 0; i < steps; ++i) {",
					"\t\tvec2 dx = float(i)*e;",
					"\t\tvec2 uv2 = fract(uv+dx);",
					"\t\tvec3 p2 = vec3(pack_4x16_to_2x32($in(uv2)), uv2.y);",
					"\t\tif (p2.x > p.x) {",
					"\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);",
					"\t\t\tp = mix(p, p2, step(p.x, p2.x));",
					"\t\t}",
					"\t\tuv2 = fract(uv-dx);",
					"\t\tp2 = vec3(pack_4x16_to_2x32($in(uv2)), uv2.y);",
					"\t\tif (p2.x > p.x) {",
					"\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);",
					"\t\t\tp = mix(p, p2, step(p.x, p2.x));",
					"\t\t}",
					"\t}",
					"\treturn p;",
					"}",
					""
				],
				"name": "Dilate pass 2",
				"outputs": [
					{
						"rgb": "$(name)_distance_v($uv)",
						"type": "rgb"
					}
				],
				"parameters": [
					{
						"default": 9,
						"first": 6,
						"label": "",
						"last": 12,
						"name": "s",
						"type": "size"
					},
					{
						"control": "None",
						"default": 0.5,
						"label": "",
						"max": 1,
						"min": 0,
						"name": "d",
						"step": 0.01,
						"type": "float"
					},
					{
						"default": 2,
						"label": "",
						"name": "distance",
						"type": "enum",
						"values": [
							{
								"name": "Euclidian",
								"value": "euclidian"
							},
							{
								"name": "Manhattan",
								"value": "manhattan"
							},
							{
								"name": "Chebyshev",
								"value": "chebyshev"
							}
						]
					}
				]
			},
			"type": "shader"
		},
		{
			"name": "dilate_pass_1",
			"node_position": {
				"x": 176.313049,
				"y": -231.32901
			},
			"parameters": {
				"d": 1,
				"s": 8
			},
			"seed": 71939,
			"seed_locked": true,
			"shader_model": {
				"code": "",
				"global": "",
				"includes": [
					"pack_1x32_to_2x16"
				],
				"inputs": [
					{
						"default": "0.0",
						"function": true,
						"label": "",
						"name": "in",
						"type": "f"
					}
				],
				"instance": [
					"vec3 $(name)_distance_h(vec2 uv) {",
					"\tvec2 e = vec2(1.0/$s, 0.0);",
					"\tint steps = int($s*$d);",
					"\tfloat rv = 0.0;",
					"\tvec2 source_uv;",
					"\tfor (int i = 0; i < steps; ++i) {",
					"\t\tsource_uv = uv+float(i)*e;",
					"\t\tif ($in(source_uv) > 0.5) {",
					"\t\t\trv = 1.0-float(i)*e.x/$d;",
					"\t\t\tbreak;",
					"\t\t}",
					"\t\tsource_uv = uv-float(i)*e;",
					"\t\tif ($in(source_uv) > 0.5) {",
					"\t\t\trv = 1.0-float(i)*e.x/$d;",
					"\t\t\tbreak;",
					"\t\t}",
					"\t}",
					"\treturn vec3(rv, source_uv);",
					"}",
					""
				],
				"name": "Dilate pass 1",
				"outputs": [
					{
						"rgba": "pack_2x32_to_4x16($(name)_distance_h($uv).xy)",
						"type": "rgba"
					}
				],
				"parameters": [
					{
						"default": 9,
						"first": 6,
						"label": "",
						"last": 12,
						"name": "s",
						"type": "size"
					},
					{
						"control": "None",
						"default": 0.5,
						"label": "",
						"max": 1,
						"min": 0,
						"name": "d",
						"step": 0.01,
						"type": "float"
					}
				]
			},
			"type": "shader"
		},
		{
			"name": "shader_1",
			"node_position": {
				"x": 175.692261,
				"y": -292.035889
			},
			"parameters": {

			},
			"seed_int": 0,
			"shader_model": {
				"code": "",
				"global": "",
				"inputs": [
					{
						"default": "vec4(0.0)",
						"label": "",
						"name": "in",
						"type": "rgba"
					}
				],
				"instance": "",
				"name": "Detect edges",
				"outputs": [
					{
						"f": "sign(dot($in($uv), vec4(1.0)))",
						"type": "f"
					}
				],
				"parameters": [

				]
			},
			"type": "shader"
		},
		{
			"name": "switch",
			"node_position": {
				"x": 428.282593,
				"y": -418.594482
			},
			"parameters": {
				"choices": 2,
				"outputs": 1,
				"source": 0
			},
			"seed_int": 0,
			"type": "switch"
		},
		{
			"name": "buffer",
			"node_position": {
				"x": 158.282593,
				"y": -146.594482
			},
			"parameters": {
				"filter": false,
				"mipmap": false,
				"size": 8
			},
			"seed_int": 0,
			"type": "buffer",
			"version": 2
		},
		{
			"name": "fill_preprocess_2",
			"node_position": {
				"x": -108.156067,
				"y": -423.50708
			},
			"parameters": {
				"s": 8
			},
			"seed_int": 0,
			"type": "fill_preprocess"
		},
		{
			"name": "fill_iterate_2",
			"node_position": {
				"x": -98.005157,
				"y": -199.56427
			},
			"parameters": {
				"s": 8
			},
			"seed_int": 0,
			"type": "fill_iterate"
		},
		{
			"name": "buffer_3",
			"node_position": {
				"x": 381.312256,
				"y": -318.4729
			},
			"parameters": {
				"filter": false,
				"mipmap": false,
				"size": 8
			},
			"seed_int": 0,
			"type": "buffer",
			"version": 2
		}
	],
	"parameters": {
		"adjust": 0,
		"remove_edges": 0,
		"size": 8
	},
	"seed_int": 0,
	"shortdesc": "Fill",
	"type": "graph"
}