本文整理汇总了Python中psychopy.tools.monitorunittools.cm2pix函数的典型用法代码示例。如果您正苦于以下问题:Python cm2pix函数的具体用法?Python cm2pix怎么用?Python cm2pix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cm2pix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _calcFieldCoordsRendered
def _calcFieldCoordsRendered(self):
if self.units in ['norm', 'pix','height']:
self._fieldSizeRendered=self.fieldSize
self._fieldPosRendered=self.fieldPos
elif self.units in ['deg', 'degs']:
self._fieldSizeRendered=deg2pix(self.fieldSize, self.win.monitor)
self._fieldPosRendered=deg2pix(self.fieldPos, self.win.monitor)
elif self.units=='cm':
self._fieldSizeRendered=cm2pix(self.fieldSize, self.win.monitor)
self._fieldPosRendered=cm2pix(self.fieldPos, self.win.monitor)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:10,代码来源:elementarray.py
示例2: _calcVerticesRendered
def _calcVerticesRendered(self):
self.needVertexUpdate=False
if self.units in ['norm', 'pix', 'height']:
self._verticesRendered=self.vertices
self._posRendered=self.pos
elif self.units in ['deg', 'degs']:
self._verticesRendered=deg2pix(self.vertices, self.win.monitor)
self._posRendered=deg2pix(self.pos, self.win.monitor)
elif self.units=='cm':
self._verticesRendered=cm2pix(self.vertices, self.win.monitor)
self._posRendered=cm2pix(self.pos, self.win.monitor)
self._verticesRendered = self._verticesRendered * self.size
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:12,代码来源:shape.py
示例3: _calcSizeRendered
def _calcSizeRendered(self):
"""Calculate the size of the stimulus in coords of the :class:`~psychopy.visual.Window` (normalised or pixels)"""
if self.units in ['norm','pix', 'height']: self._sizeRendered=self.size
elif self.units in ['deg', 'degs']: self._sizeRendered=deg2pix(self.size, self.win.monitor)
elif self.units=='cm': self._sizeRendered=cm2pix(self.size, self.win.monitor)
else:
logging.ERROR("Stimulus units should be 'height', 'norm', 'deg', 'cm' or 'pix', not '%s'" %self.units)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:7,代码来源:aperture.py
示例4: setHeight
def setHeight(self,height, log=True):
"""Set the height of the letters (including the entire box that surrounds the letters
in the font). The width of the letters is then defined by the font.
"""
#height in pix (needs to be done after units)
if self.units=='cm':
if height==None: self.height = 1.0#default text height
else: self.height = height
self.heightPix = cm2pix(self.height, self.win.monitor)
elif self.units in ['deg', 'degs']:
if height==None: self.height = 1.0
else: self.height = height
self.heightPix = deg2pix(self.height, self.win.monitor)
elif self.units=='norm':
if height==None: self.height = 0.1
else: self.height = height
self.heightPix = self.height*self.win.size[1]/2
elif self.units=='height':
if height==None: self.height = 0.2
else: self.height = height
self.heightPix = self.height*self.win.size[1]
else: #treat units as pix
if height==None: self.height = 20
else: self.height = height
self.heightPix = self.height
#need to update the font to reflect the change
self.setFont(self.fontname, log=False)
if log and self.autoLog:
self.win.logOnFlip("Set %s height=%.2f" %(self.name, height),
level=logging.EXP,obj=self)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:30,代码来源:text.py
示例5: contains
def contains(self, x, y=None):
"""Determines if a point x,y is inside the extent of the stimulus.
Can accept: a) two args, x and y; b) one arg, as a point (x,y) that is
list-like; or c) an object with a getPos() method that returns x,y, such
as a mouse. Returns True if the point is within the area defined by `vertices`.
This handles complex shapes, including concavities and self-crossings.
Note that, if your stimulus uses a mask (such as a Gaussian blob) then
this is not accounted for by the `contains` method; the extent of the
stmulus is determined purely by the size, pos and orientation settings
(and by the vertices for shape stimuli).
See coder demo, shapeContains.py
"""
if self.needVertexUpdate:
self._calcVerticesRendered()
if hasattr(x, 'getPos'):
x, y = x.getPos()
elif type(x) in [list, tuple, numpy.ndarray]:
x, y = x[0], x[1]
if self.units in ['deg','degs']:
x, y = deg2pix(numpy.array((x, y)), self.win.monitor)
elif self.units == 'cm':
x, y = cm2pix(numpy.array((x, y)), self.win.monitor)
if self.ori:
oriRadians = numpy.radians(self.ori)
sinOri = numpy.sin(oriRadians)
cosOri = numpy.cos(oriRadians)
x0, y0 = x-self._posRendered[0], y-self._posRendered[1]
x = x0 * cosOri - y0 * sinOri + self._posRendered[0]
y = x0 * sinOri + y0 * cosOri + self._posRendered[1]
return pointInPolygon(x, y, self)
开发者ID:Gianluigi,项目名称:psychopy,代码行数:34,代码来源:basevisual.py
示例6: _calcSizeRendered
def _calcSizeRendered(self):
"""DEPRECATED in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"""
#raise DeprecationWarning, "_calcSizeRendered() was deprecated in 1.80.00. This funtionality is nowhanded by _updateVertices() and verticesPix"
if self.units in ['norm','pix', 'height']: self._sizeRendered=copy.copy(self.size)
elif self.units in ['deg', 'degs']: self._sizeRendered=deg2pix(self.size, self.win.monitor)
elif self.units=='cm': self._sizeRendered=cm2pix(self.size, self.win.monitor)
else:
logging.ERROR("Stimulus units should be 'height', 'norm', 'deg', 'cm' or 'pix', not '%s'" %self.units)
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:8,代码来源:basevisual.py
示例7: _windowUnits2pix
def _windowUnits2pix(self, pos):
if self.win.units == 'pix':
return pos
elif self.win.units == 'norm':
return pos * self.win.size / 2.0
elif self.win.units == 'cm':
return cm2pix(pos, self.win.monitor)
elif self.win.units == 'deg':
return deg2pix(pos, self.win.monitor)
elif self.win.units == 'height':
return pos * float(self.win.size[1])
开发者ID:mmagnuski,项目名称:psychopy,代码行数:11,代码来源:event.py
示例8: _calcPosRendered
def _calcPosRendered(self):
"""Calculate the pos of the stimulus in pixels"""
if self.units == 'pix':
self._posRendered = self.pos
elif self.units == 'cm':
self._posRendered = cm2pix(self.pos, self.win.monitor)
elif self.units =='deg':
self._posRendered = deg2pix(self.pos, self.win.monitor)
elif self.units == 'norm':
self._posRendered = self.pos * self.win.size/2.0
elif self.units == 'height':
self._posRendered = self.pos * self.win.size[1]
开发者ID:PieterMoors,项目名称:psychopy,代码行数:12,代码来源:simpleimage.py
示例9: _calcPosRendered
def _calcPosRendered(self):
"""Calculate the pos of the stimulus in coords of the :class:`~psychopy.visual.Window` (normalised or pixels)"""
if self.units in ['pix', 'pixels', 'height', 'norm']: self._posRendered=self.pos
elif self.units in ['deg', 'degs']: self._posRendered=deg2pix(self.pos, self.win.monitor)
elif self.units=='cm': self._posRendered=cm2pix(self.pos, self.win.monitor)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:5,代码来源:simpleimage.py
示例10: _calcPosRendered
def _calcPosRendered(self):
"""DEPRECATED in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"""
#raise DeprecationWarning, "_calcSizeRendered() was deprecated in 1.80.00. This funtionality is now handled by _updateVertices() and verticesPix"
if self.units in ['norm','pix', 'height']: self._posRendered= copy.copy(self.pos)
elif self.units in ['deg', 'degs']: self._posRendered=deg2pix(self.pos, self.win.monitor)
elif self.units=='cm': self._posRendered=cm2pix(self.pos, self.win.monitor)
开发者ID:larigaldie-n,项目名称:psychopy,代码行数:6,代码来源:basevisual.py
示例11: _calcXYsRendered
def _calcXYsRendered(self):
if self.units in ['norm','pix','height']: self._XYsRendered=self.xys
elif self.units in ['deg', 'degs']: self._XYsRendered=deg2pix(self.xys, self.win.monitor)
elif self.units=='cm': self._XYsRendered=cm2pix(self.xys, self.win.monitor)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:4,代码来源:elementarray.py
示例12: _calcDotsXYRendered
def _calcDotsXYRendered(self):
if self.units in ['norm','pix', 'height']: self._dotsXYRendered=self._dotsXY
elif self.units in ['deg','degs']: self._dotsXYRendered=deg2pix(self._dotsXY, self.win.monitor)
elif self.units=='cm': self._dotsXYRendered=cm2pix(self._dotsXY, self.win.monitor)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:4,代码来源:dot.py
示例13: __init__
def __init__(self, win,
text="Hello World",
font="",
pos=(0.0,0.0),
depth=0,
rgb=None,
color=(1.0,1.0,1.0),
colorSpace='rgb',
opacity=1.0,
contrast=1.0,
units="",
ori=0.0,
height=None,
antialias=True,
bold=False,
italic=False,
alignHoriz='center',
alignVert='center',
fontFiles=[],
wrapWidth=None,
flipHoriz=False, flipVert=False,
name='', autoLog=True):
"""
:Parameters:
win: A :class:`Window` object.
Required - the stimulus must know where to draw itself
text:
The text to be rendered
height:
Height of the characters (including the ascent of the letter and the descent)
antialias:
boolean to allow (or not) antialiasing the text
bold:
Make the text bold (better to use a bold font name)
italic:
Make the text italic (better to use an actual italic font)
alignHoriz:
The horizontal alignment ('left', 'right' or 'center')
alignVert:
The vertical alignment ('top', 'bottom' or 'center')
fontFiles:
A list of additional files if the font is not in the standard system location (include the full path)
wrapWidth:
The width the text should run before wrapping
flipHoriz : boolean
Mirror-reverse the text in the left-right direction
flipVert : boolean
Mirror-reverse the text in the up-down direction
"""
BaseVisualStim.__init__(self, win, units=units, name=name, autoLog=autoLog)
self.useShaders = win._haveShaders #use shaders if available by default, this is a good thing
self._needUpdate = True
self.alignHoriz = alignHoriz
self.alignVert = alignVert
self.antialias = antialias
self.bold=bold
self.italic=italic
self.text='' #NB just a placeholder - real value set below
self.depth=depth
self.ori=ori
self.wrapWidth=wrapWidth
self.flipHoriz = flipHoriz
self.flipVert = flipVert
self._pygletTextObj=None
self.pos= numpy.array(pos, float)
#height in pix (needs to be done after units which is done during _Base.__init__)
if self.units=='cm':
if height==None: self.height = 1.0#default text height
else: self.height = height
self.heightPix = cm2pix(self.height, win.monitor)
elif self.units in ['deg', 'degs']:
if height==None: self.height = 1.0
else: self.height = height
self.heightPix = deg2pix(self.height, win.monitor)
elif self.units=='norm':
if height==None: self.height = 0.1
else: self.height = height
self.heightPix = self.height*win.size[1]/2
elif self.units=='height':
if height==None: self.height = 0.2
else: self.height = height
self.heightPix = self.height*win.size[1]
else: #treat units as pix
if height==None: self.height = 20
else: self.height = height
self.heightPix = self.height
if self.wrapWidth ==None:
if self.units in ['height','norm']: self.wrapWidth=1
elif self.units in ['deg', 'degs']: self.wrapWidth=15
elif self.units=='cm': self.wrapWidth=15
elif self.units in ['pix', 'pixels']: self.wrapWidth=500
if self.units=='norm': self._wrapWidthPix= self.wrapWidth*win.size[0]/2
elif self.units=='height': self._wrapWidthPix= self.wrapWidth*win.size[0]
elif self.units in ['deg', 'degs']: self._wrapWidthPix= deg2pix(self.wrapWidth, win.monitor)
elif self.units=='cm': self._wrapWidthPix= cm2pix(self.wrapWidth, win.monitor)
elif self.units in ['pix', 'pixels']: self._wrapWidthPix=self.wrapWidth
#.........这里部分代码省略.........
开发者ID:GentBinaku,项目名称:psychopy,代码行数:101,代码来源:text.py
示例14: degcoord2pix
def degcoord2pix(self, degx, degy, display_index=None):
if display_index == self.getIndex():
return psychopy2displayPix(
deg2pix(degx, self._psychopy_monitor), cm2pix(degy, self._psychopy_monitor)
)
return degx, degy
开发者ID:smathot,项目名称:psychopy,代码行数:6,代码来源:__init__.py
示例15: cmcoord2pix
def cmcoord2pix(self, cx, cy, display_index=None):
if display_index == self.getIndex():
return psychopy2displayPix(cm2pix(cx, self._psychopy_monitor), cm2pix(cy, self._psychopy_monitor))
return cx, cy
开发者ID:smathot,项目名称:psychopy,代码行数:4,代码来源:__init__.py
注:本文中的psychopy.tools.monitorunittools.cm2pix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论