~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/data/themes/nublo/resources/base.py

  • Committer: Jan Jokela
  • Date: 2008-12-10 22:18:59 UTC
  • Revision ID: janjokela@gmail.com-20081210221859-zxr2ut255a7xu15x
Hi, Glitter here

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# !/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# nublo
 
5
# a redefinition of senses
 
6
        
 
7
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
 
8
__licenses__ = ["LICENSE.LGPL"]
 
9
__description__ = "Button background texture"
 
10
 
 
11
import math
 
12
import clutter
 
13
import cairo
 
14
from cluttercairo import CairoTexture
 
15
 
 
16
class Texture(CairoTexture):
 
17
    """ Creates a CairoTexture based on a given SVG """
 
18
 
 
19
    def __init__(self, width, height):
 
20
        
 
21
        CairoTexture.__init__(self, width, height)
 
22
        
 
23
        self.width = width
 
24
        self.height = height
 
25
        
 
26
        self.context = self.cairo_create()
 
27
        
 
28
        #self.context.set_line_width(self.height * 0.01)
 
29
        #self.context.set_source_rgba(1.0, 1.0, 1.0, 1.0)
 
30
        #self.context.rectangle(0.0, 0.0, self.width, self.height)
 
31
        
 
32
        linpat = cairo.LinearGradient(self.width / 2.0, 0.0, self.width / 2.0, self.height);
 
33
        linpat.add_color_stop_rgba (0.0,  0.9, 0.9, 0.9, 1.0);
 
34
        linpat.add_color_stop_rgba (1.0,  0.5, 0.5, 0.5, 1.0);
 
35
 
 
36
        
 
37
        self.context.arc(self.height * 0.2, self.height * 0.2, 
 
38
                         self.height * 0.2, math.pi, 3.0 * math.pi / 2.0)
 
39
        self.context.line_to(self.width - (self.height * 0.2), 0.0)
 
40
        self.context.arc(self.width - (self.height * 0.2),
 
41
                         self.height * 0.2, 
 
42
                         self.height * 0.2, 
 
43
                         3.0 * math.pi / 2.0, 
 
44
                         0.0)
 
45
        self.context.line_to(self.width, self.height - (self.height * 0.2))
 
46
        self.context.arc(self.width - (self.height * 0.2),
 
47
                         self.height - (self.height * 0.2), 
 
48
                         self.height * 0.2, 
 
49
                         0.0, 
 
50
                         math.pi / 2.0)
 
51
        self.context.line_to(self.height * 0.2, self.height)
 
52
        self.context.arc(self.height * 0.2,
 
53
                         self.height - (self.height * 0.2), 
 
54
                         self.height * 0.2, 
 
55
                         math.pi / 2.0, 
 
56
                         math.pi)
 
57
        
 
58
        self.context.close_path()
 
59
        #self.context.set_source_rgba(0.0, 1.0, 0.0, 1.0)
 
60
        self.context.set_source(linpat)
 
61
        self.context.fill()
 
62
        
 
63
        self.context.stroke()
 
64
        del self.context
 
65
          
 
66
    def resize(self, width, height):
 
67
 
 
68
        pass
 
69