KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /usr/share/doc/pygtk2-2.10.1/examples/pango/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/pygtk2-2.10.1/examples/pango/pangocairo-simple.py
#! /usr/bin/env python
import sys
import math
import pango
import cairo
import pangocairo

RADIUS = 150

def draw_text(cr):
    N_WORDS = 10
    FONT = "Sans Bold 27"

    # Center coordinates on the middle of the region we are drawing
    cr.translate(RADIUS, RADIUS);

    # Create a PangoLayout, set the font and text */
    layout = cr.create_layout()

    layout.set_text("Text")
    layout.set_font_description(pango.FontDescription(FONT))

    # Draw the layout N_WORDS times in a circle
    for i in range(N_WORDS):
        angle = (360 * i) / N_WORDS;
        cr.save()

        # Gradient from red at angle == 60 to blue at angle == 300
        red   = (1 + math.cos((angle - 60)*math.pi/180))/2
        cr.set_source_rgb(red, 0, 1 - red)
        cr.rotate(angle*math.pi/180)

        # Inform Pango to re-layout the text with the new transformation */
        cr.update_layout(layout)

        width, height = layout.get_size()
        cr.move_to(-width/pango.SCALE/2, -RADIUS)
        cr.show_layout(layout)

        cr.restore()

def main(argv):
    if len(argv) != 2:
        print >> sys.stderr, "Usage: cairosimple OUTPUT_BASENAME\n"
        return 1

    filename = argv[1]
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 2*RADIUS, 2*RADIUS)
    cr = pangocairo.CairoContext(cairo.Context(surface))
    cr.set_source_rgb(1.0, 1.0, 1.0)
    cr.rectangle(0, 0, 2*RADIUS, 2*RADIUS)
    cr.fill()
    draw_text(cr)

    surface.write_to_png(filename + ".png")

    ## output also a PDF file
    surface = cairo.PDFSurface(filename + ".pdf", 2*RADIUS, 2*RADIUS)
    cr = pangocairo.CairoContext(cairo.Context(surface))
    draw_text(cr)
    cr.show_page()
    surface.finish()


if __name__ == '__main__':
    sys.exit(main(sys.argv))

Anon7 - 2021