Beispiel #1
0
def task_2():
    '''
    @note: text_object.setfontsize(12) - Fontsize has been set to 12
          text_object.scale(a,b) - A method which takes two arguments, one for scaling the width value, one for scaling the
          height value of text_object.text_str.
    '''
    print '>>> task 2 -\tscale text_object\n'
    text_object = TextObject()
    text_object.text_str('foobar')
    text_object.set_font_size(12)
    print 'original size:\t{0}'.format(text_object.check_text_dimensions())

    text_object.scale(2,1)
    print 'scaled size:\t{0}'.format(text_object.check_text_dimensions())

    text_object.scale(2,4) #scaling handle absolute values, currently values entered before will be overwritten
    print 'rescaled size:\t{0}'.format(text_object.check_text_dimensions())
    print 50*'-'
Beispiel #2
0
def task_1():
    '''
    @note: text_object - an object for text data and several methods
           text_object.text_str - Some arbitrary text. It can be any length of characters.
           text_object.setfontsize(fontsize) - A method with one parameter to set the fontsize in points of the text_str.   
           text_object.check_text_dimensions() - A method which returns the height and width in pixels of the text_str using the current font size 
    '''
    print '>>> task 1 -text_object basics\n'
    text_object = TextObject()
    text_object.text_str('foobar') 
    
    text_object.set_font_size(11)
    print 'text size with 11pt:\t{0}'.format(text_object.check_text_dimensions())
    
    text_object.set_font_size(18)
    print 'text size with 18pt:\t{0}'.format(text_object.check_text_dimensions())
    
    text_object.scale(0.5, 0.5)    
    print 'shrinked text:\t{0}'.format(text_object.check_text_dimensions())

    text_object.scale(2, 1.5)    
    print 'bloated text:\t{0}'.format(text_object.check_text_dimensions())
    print 50*'-'