def noise2d(self, x, y):
<EOL>stretch_offset = (x + y) * STRETCH_CONSTANT_2D<EOL>xs = x + stretch_offset<EOL>ys = y + stretch_offset<EOL>xsb = floor(xs)<EOL>ysb = floor(ys)<EOL>squish_offset = (xsb + ysb) * SQUISH_CONSTANT_2D<EOL>xb = xsb + squish_offset<EOL>yb = ysb + squish_offset<EOL>xins = xs - xsb<EOL>yins = ys - ysb<EOL>in_sum = xins + yins<EOL>dx0 = x - xb<EOL>dy0 = y - yb<EOL>value = <NUM_LIT:0><EOL>dx1 = dx0 - <NUM_LIT:1> - SQUISH_CONSTANT_2D<EOL>dy1 = dy0 - <NUM_LIT:0> - SQUISH_CONSTANT_2D<EOL>attn1 = <NUM_LIT:2> - dx1 * dx1 - dy1 * dy1<EOL>extrapolate = self._extrapolate2d<EOL>if attn1 > <NUM_LIT:0>:<EOL><INDENT>attn1 *= attn1<EOL>value += attn1 * attn1 * extrapolate(xsb + <NUM_LIT:1>, ysb + <NUM_LIT:0>, dx1, dy1)<EOL><DEDENT>dx2 = dx0 - <NUM_LIT:0> - SQUISH_CONSTANT_2D<EOL>dy2 = dy0 - <NUM_LIT:1> - SQUISH_CONSTANT_2D<EOL>attn2 = <NUM_LIT:2> - dx2 * dx2 - dy2 * dy2<EOL>if attn2 > <NUM_LIT:0>:<EOL><INDENT>attn2 *= attn2<EOL>value += attn2 * attn2 * extrapolate(xsb + <NUM_LIT:0>, ysb + <NUM_LIT:1>, dx2, dy2)<EOL><DEDENT>if in_sum <= <NUM_LIT:1>: <EOL><INDENT>zins = <NUM_LIT:1> - in_sum<EOL>if zins > xins or zins > yins: <EOL><INDENT>if xins > yins:<EOL><INDENT>xsv_ext = xsb + <NUM_LIT:1><EOL>ysv_ext = ysb - <NUM_LIT:1><EOL>dx_ext = dx0 - <NUM_LIT:1><EOL>dy_ext = dy0 + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>xsv_ext = xsb - <NUM_LIT:1><EOL>ysv_ext = ysb + <NUM_LIT:1><EOL>dx_ext = dx0 + <NUM_LIT:1><EOL>dy_ext = dy0 - <NUM_LIT:1><EOL><DEDENT><DEDENT>else: <EOL><INDENT>xsv_ext = xsb + <NUM_LIT:1><EOL>ysv_ext = ysb + <NUM_LIT:1><EOL>dx_ext = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL>dy_ext = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL><DEDENT><DEDENT>else: <EOL><INDENT>zins = <NUM_LIT:2> - in_sum<EOL>if zins < xins or zins < yins: <EOL><INDENT>if xins > yins:<EOL><INDENT>xsv_ext = xsb + <NUM_LIT:2><EOL>ysv_ext = ysb + <NUM_LIT:0><EOL>dx_ext = dx0 - <NUM_LIT:2> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL>dy_ext = dy0 + <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL><DEDENT>else:<EOL><INDENT>xsv_ext = xsb + <NUM_LIT:0><EOL>ysv_ext = ysb + <NUM_LIT:2><EOL>dx_ext = dx0 + <NUM_LIT:0> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL>dy_ext = dy0 - <NUM_LIT:2> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL><DEDENT><DEDENT>else: <EOL><INDENT>dx_ext = dx0<EOL>dy_ext = dy0<EOL>xsv_ext = xsb<EOL>ysv_ext = ysb<EOL><DEDENT>xsb += <NUM_LIT:1><EOL>ysb += <NUM_LIT:1><EOL>dx0 = dx0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL>dy0 = dy0 - <NUM_LIT:1> - <NUM_LIT:2> * SQUISH_CONSTANT_2D<EOL><DEDENT>attn0 = <NUM_LIT:2> - dx0 * dx0 - dy0 * dy0<EOL>if attn0 > <NUM_LIT:0>:<EOL><INDENT>attn0 *= attn0<EOL>value += attn0 * attn0 * extrapolate(xsb, ysb, dx0, dy0)<EOL><DEDENT>attn_ext = <NUM_LIT:2> - dx_ext * dx_ext - dy_ext * dy_ext<EOL>if attn_ext > <NUM_LIT:0>:<EOL><INDENT>attn_ext *= attn_ext<EOL>value += attn_ext * attn_ext * extrapolate(xsv_ext, ysv_ext, dx_ext, dy_ext)<EOL><DEDENT>return value / NORM_CONSTANT_2D<EOL>
Generate 2D OpenSimplex noise from X,Y coordinates.