root/galaxy-central/static/june_2007_style/callout_top.py @ 2

リビジョン 2, 1.2 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

  • 属性 svn:executable の設定値 *
行番号 
1#!/usr/bin/env python
2
3"""
4usage: %prog width height bg_color hatch_color [color alpha stop_pos] +
5"""
6
7from __future__ import division
8
9import sys
10import cairo
11
12assert sys.version_info[:2] >= ( 2, 4 )
13
14def parse_css_color( color ):
15    if color.startswith( '#' ):
16        color = color[1:]
17    if len( color ) == 3:
18        r = int( color[0]*2, 16 )
19        g = int( color[1]*2, 16 )
20        b = int( color[2]*2, 16 )
21    elif len( color ) == 6:
22        r = int( color[0:2], 16 )
23        g = int( color[2:4], 16 )
24        b = int( color[4:6], 16 )
25    else:
26        raise Exception( "Color should be 3 hex numbers" )
27    return r/256, g/256, b/256
28                       
29width = int( sys.argv[1] )
30height = int( sys.argv[2] )
31   
32surface = cairo.ImageSurface( cairo.FORMAT_ARGB32, width, height )
33c = cairo.Context( surface )
34
35height -= 1
36width -= 1
37
38hw = width / 2
39
40c.set_line_width( 1 )
41
42def t( x ): return x + 0.5
43
44c.move_to( t( 0 ), t( height+2 ) )
45c.line_to( t( hw ), t( 0 ) )
46c.line_to( t( width ), t( height+2 ) )
47c.close_path()
48
49c.set_source_rgb( *parse_css_color( sys.argv[3] ) )
50c.fill_preserve()
51
52c.set_source_rgb( *parse_css_color( sys.argv[4] ) )
53c.stroke()
54
55surface.write_to_png( "/dev/stdout" )
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。