Exemplo n.º 1
0
import os, sys, cPickle, string
from logging import *
from debug import Debug
from math import *

""" Enables catching / logging of exceptions by @errorlog """
Debug.set('BLOCK_EXCEPTIONS',True)

fnt = '\\f(data/FreeSerif.ttf)\\s(48)'
futura = os.path.join('data','Futura Light BT.ttf')
tahoma = os.path.join('data','tahoma.ttf')
pakenham = os.path.join('data','pakenham free.ttf')

def str_to_num(str):
    """ Converts a given string to a number. Returns zero if it is invalid."""
    try:
        return int(str)
    except:
        try:
            return float(str)
        except:
            return 0

def point_in_rect(pt, rect):
    """/fn point_in_rect(pt, rect)
    /brief Returns True if a given point is within a given rect
    @arg pt A point: basically, must be (int, int)
    @arg rect A rectangle: basically, must be (int, int, int, int)
    """ 
    return pt[0] >= rect[0] and \
           pt[0] <= rect[2]+rect[0] and \