Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
All Data Structures Namespaces Files Functions Variables
GUIRect Class Reference
Inheritance diagram for GUIRect:
GUINPOTRect

Public Member Functions

def __init__
 
def __repr__
 
def __str__
 
def getNormalXYWH
 
def getNormalCenter
 
def getNormalTL
 
def getNormalBR
 
def getNormalWH
 
def getHotRect
 
def getSpriteRect
 
def getTextRect
 

Data Fields

 x
 
 y
 
 w
 
 h
 
 ref
 
 mode
 

Detailed Description

A rectangle on the screen                                                   
ref: may be (room), (screenx,screeny) or (screenx,screeny,marginx,marginy)  
(first takes the dimensions from the room, the next from the tuple itself
just the dimensions but margins and stuff from the root, and the last   
takes everything from the tuple)                                        

Definition at line 452 of file GUI.py.

Constructor & Destructor Documentation

def __init__ (   self,
  x,
  y,
  wid,
  hei,
  mode = "pixel",
  ref = None 
)

Definition at line 458 of file GUI.py.

459  def __init__(self,x,y,wid,hei,mode="pixel",ref=None):
460  self.x = x
461  self.y = y
462  self.w = wid
463  self.h = hei
464  self.ref = ref
465  self.mode = mode

Member Function Documentation

def __repr__ (   self)

Definition at line 466 of file GUI.py.

References GUIRect.h, GzipFile.mode, ZipFile.mode, GUIRect.mode, GUIRect.ref, GUIRect.w, GUIRect.x, and GUIRect.y.

467  def __repr__(self):
return repr((self.x,self.y,self.w,self.h,self.mode,self.ref))
def __str__ (   self)

Definition at line 468 of file GUI.py.

References GUIRect.h, GzipFile.mode, ZipFile.mode, GUIRect.mode, GUIRect.ref, locale.str(), GUIRect.w, GUIRect.x, and GUIRect.y.

469  def __str__(self):
470  return str((self.x,self.y,self.w,self.h,self.mode,self.ref))
def getHotRect (   self)
(BOTTOM, LEFT, WIDTH, HEIGHT) as needed by Base hotspots 

Definition at line 540 of file GUI.py.

References GUIRect.getNormalXYWH().

541  def getHotRect(self):
542  """ (BOTTOM, LEFT, WIDTH, HEIGHT) as needed by Base hotspots """
543  aux = self.getNormalXYWH()
544  return ( aux[0], aux[1]-aux[3], aux[2], aux[3] )
def getNormalBR (   self)
returns BOTTOM-RIGHT coordinate pair 

Definition at line 524 of file GUI.py.

References GUIRect.getNormalXYWH().

525  def getNormalBR(self):
526  """ returns BOTTOM-RIGHT coordinate pair """
527  aux = self.getNormalXYWH()
528  return ( aux[0]+aux[2], aux[1]-aux[3] )
def getNormalCenter (   self)

Definition at line 515 of file GUI.py.

References GUIRect.getNormalXYWH().

516  def getNormalCenter(self):
517  aux = self.getNormalXYWH()
518  return ( aux[0]+aux[2]/2, aux[1]-aux[3]/2 )
def getNormalTL (   self)
returns TOP-LEFT coordinate pair 

Definition at line 519 of file GUI.py.

References GUIRect.getNormalXYWH().

520  def getNormalTL(self):
521  """ returns TOP-LEFT coordinate pair """
522  aux = self.getNormalXYWH()
523  return ( aux[0], aux[1] )
def getNormalWH (   self)
returns WIDTH-HEIGHT dimensions 

Definition at line 529 of file GUI.py.

References GUIRect.getNormalXYWH().

530  def getNormalWH(self):
531  """ returns WIDTH-HEIGHT dimensions """
532  aux = self.getNormalXYWH()
533  return ( aux[2], aux[3] )
def getNormalXYWH (   self)
returns (x,y,w,h) - x/y is top-left - in Base coordinates 
Allow two kinds of screen dimension overrides, for design convenience 
a) (screenx,screeny) - margins set as per root settings 
b) (screenx,screeny,marginx,marginy) - set both dimensions and margin manually 

Definition at line 471 of file GUI.py.

References GUIRect.h, GzipFile.mode, ZipFile.mode, GUIRect.mode, GUIRect.ref, inspect.trace(), GUIRect.w, GUIRect.x, and GUIRect.y.

472  def getNormalXYWH(self):
473  """ returns (x,y,w,h) - x/y is top-left - in Base coordinates """
474 
475  """ Allow two kinds of screen dimension overrides, for design convenience """
476  """ a) (screenx,screeny) - margins set as per root settings """
477  """ b) (screenx,screeny,marginx,marginy) - set both dimensions and margin manually """
478  if not self.ref or (type(self.ref)!=tuple) or ((len(self.ref)!=1)and(len(self.ref)!=2)and(len(self.ref)!=4)):
479  (screenX,screenY) = GUIRootSingleton.getScreenDimensions()
480  (marginX,marginY) = GUIRootSingleton.getScreenMargins()
481  else:
482  if len(self.ref)==4:
483  (screenX,screenY,marginX,marginY) = self.ref
484  elif len(self.ref)==2:
485  (screenX,screenY) = self.ref
486  (marginX,marginY) = GUIRootSingleton.getScreenMargins()
487  else:
488  (screenX,screenY) = self.ref[0].getScreenDimensions()
489  (marginX,marginY) = self.ref[0].getScreenMargins()
490  if (self.mode=="pixel"):
491  """ pixel coordinates relative to current screen settings
492  to translate (0,0) (screenX,screenY) to (-1,1) (1,-1)
493  x = 2*xi/screenX - 1
494  y = 1 - 2*yi/screenY
495  """
496  return ( (2.0 * self.x / screenX - 1.0)*(1.0-marginX) , \
497  (-2.0 * self.y / screenY + 1.0)*(1.0-marginY) , \
498  (2.0 * self.w / screenX * (1.0-marginX)) , \
499  (2.0 * self.h / screenY * (1.0-marginY)) \
500  )
501  elif (self.mode=='normalized_biased_scaled'):
502  """ direct coordinates: top-left = (-1,+1), bottom-right = (+1,-1) - margins WILL NOT be applied """
503  return (self.x,self.y,self.w,self.h)
504  elif (self.mode=='normalized_biased'):
505  """ direct coordinates: top-left = (-1,+1), bottom-right = (+1,-1) - margins WILL be applied """
506  return (self.x*(1.0-marginX),self.y*(1.0-marginY),self.w*(1.0-marginX),self.h*(1.0-marginY))
507  elif (self.mode=='normalized_scaled'):
508  """ normalized coordinates: top-left = (0,0), bottom-right = (1,1) - margins WILL NOT be applied """
509  return ((2.0*self.x-1.0),(-2.0*self.y+1.0),2.0*self.w,2.0*self.h)
510  elif (self.mode=='normalized'):
511  """ normalized coordinates: top-left = (0,0), bottom-right = (1,1) - margins WILL be applied """
512  return ((2.0*self.x-1.0)*(1.0-marginX),(-2.0*self.y+1.0)*(1.0-marginY),2.0*self.w*(1.0-marginX),2.0*self.h*(1.0-marginY))
513  else:
514  trace(_GUITraceLevel, "WARNING! - gui.py - GUIRect::getNormalizedCoords(): unknown coordinate mode\n")
def getSpriteRect (   self)
(CenterX, CenterY, WIDTH, -HEIGHT) as needed by Base sprites 

Definition at line 545 of file GUI.py.

References GUIRect.getNormalXYWH().

546  def getSpriteRect(self):
547  """ (CenterX, CenterY, WIDTH, -HEIGHT) as needed by Base sprites """
548  aux = self.getNormalXYWH()
549  return ( aux[0]+aux[2]/2, aux[1]-aux[3]/2, aux[2], -aux[3] )
def getTextRect (   self)
(TOP, LEFT, WIDTH, HEIGHT) as needed by Base textboxes 

Definition at line 550 of file GUI.py.

References GUIRect.getNormalXYWH().

551  def getTextRect(self):
552  """ (TOP, LEFT, WIDTH, HEIGHT) as needed by Base textboxes """
553  return self.getNormalXYWH()
554 
555 
556 """----------------------------------------------------------------"""
557 """ """
558 """ GUINPOTRect - defines rectangles on the screen. """
559 """ Adjusts a rectangle so that a Power-Of-Two texture """
560 """ with Non-Power-Of-Two contents (top/left aligned) """
561 """ displays its contents in the specified area. """
562 """ """
563 """----------------------------------------------------------------"""

Field Documentation

h

Definition at line 462 of file GUI.py.

mode

Definition at line 464 of file GUI.py.

ref

Definition at line 463 of file GUI.py.

w

Definition at line 461 of file GUI.py.

x

Definition at line 459 of file GUI.py.

y

Definition at line 460 of file GUI.py.


The documentation for this class was generated from the following file: