{ file created by makewarp }

brickweave_u = if(brickweave_inbounds(Px,Py), brickweave_wu(Px,Py), Px) ;
brickweave_v = if(brickweave_inbounds(Px,Py), brickweave_wv(Px,Py), Py) ;

brickweave_tile_u = brickweave_wu(mod(Px,brickweave_mu),mod(Py,brickweave_mv)) ;
brickweave_tile_v = brickweave_wv(mod(Px,brickweave_mu),mod(Py,brickweave_mv)) ;

brickweave_match_u = brickweave_wu(tri(Px,brickweave_mu),tri(Py,brickweave_mv)) ;
brickweave_match_v = brickweave_wv(tri(Px,brickweave_mu),tri(Py,brickweave_mv)) ;

brickweave_wu(u,v) =
	linterp(frac(brickweave_iu(u)),
		linterp(frac(brickweave_iv(v)),
			brickweave_gu(floor(brickweave_iu(u)),floor(brickweave_iv(v))),
			brickweave_gu(floor(brickweave_iu(u)),ceil(brickweave_iv(v)))
		), linterp(frac(brickweave_iv(v)),
			brickweave_gu(ceil(brickweave_iu(u)),floor(brickweave_iv(v))),
			brickweave_gu(ceil(brickweave_iu(u)),ceil(brickweave_iv(v)))
		)
) ;
brickweave_wv(u,v) =
	linterp(frac(brickweave_iu(u)),
		linterp(frac(brickweave_iv(v)),
			brickweave_gv(floor(brickweave_iu(u)),floor(brickweave_iv(v))),
			brickweave_gv(floor(brickweave_iu(u)),ceil(brickweave_iv(v)))
		), linterp(frac(brickweave_iv(v)),
			brickweave_gv(ceil(brickweave_iu(u)),floor(brickweave_iv(v))),
			brickweave_gv(ceil(brickweave_iu(u)),ceil(brickweave_iv(v)))
		)
) ;

brickweave_iu(u) = 1 + 4 * u / brickweave_mu ;
brickweave_iv(v) = 1 + 4 * v / brickweave_mv ;

brickweave_inbounds(u,v) = and( and( u, brickweave_mu - u),
			and(v, brickweave_mv - v) ) ;

brickweave_mu = 1.000000 ;
brickweave_mv = 1.000000 ;

brickweave_gu(i, j) = select( i,
	select( j,
		0.000000,
		0.000000,
		0.000000,
		0.000000,
		0.000000
	), select( j,
		0.248322,
		0.248322,
		0.248322,
		0.248322,
		0.248322
	), select( j,
		0.496644,
		0.496644,
		0.496644,
		0.496644,
		0.496644
	), select( j,
		0.744966,
		0.744966,
		0.744966,
		0.744966,
		0.744966
	), select( j,
		1.000000,
		1.000000,
		1.000000,
		1.000000,
		1.000000
	)
) ;
brickweave_gv(i, j) = select( i,
	select( j,
		1.000000,
		0.751678,
		0.503356,
		0.255034,
		0.000000
	), select( j,
		1.000000,
		0.751678,
		0.503356,
		0.255034,
		0.000000
	), select( j,
		1.000000,
		0.751678,
		0.503356,
		0.255034,
		0.000000
	), select( j,
		1.000000,
		0.751678,
		0.503356,
		0.255034,
		0.000000
	), select( j,
		1.000000,
		0.751678,
		0.503356,
		0.255034,
		0.000000
	)
) ;
