本文整理汇总了Python中field.Field.reset方法的典型用法代码示例。如果您正苦于以下问题:Python Field.reset方法的具体用法?Python Field.reset怎么用?Python Field.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field.Field
的用法示例。
在下文中一共展示了Field.reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import reset [as 别名]
class Grid:
# Class to rasterize a Field down into a big grid of squares
def __init__( self, wide, high ):
# Basic, keep a background field, and a 2d array of values
self.f = Field( )
self.w = wide
self.h = high
self.vals = [ [ 0 for i in range( self.w ) ] for j in range( self.h ) ]
# Pre-compute all the box values
self.step( 0.0 )
def reset( self ):
# Basic, reset the underlying field
self.f.reset( )
def step( self,perc ):
# Again basic, step the field, then compute all the box values
self.f.step( perc )
self.compute( )
def compute( self ):
for y in range( self.h ):
for x in range( self.w ):
# Map the x and y to the center of the box, get a value from the field
self.vals[ y ][ x ] = self.f.getVal( float( x ) / ( self.w - 1 ), float( y ) / ( self.h - 1 ) )
def getVal( self, x, y ):
# Basic as it gets
return self.vals[ y ][ x ]