Themes in eigene Dateien
authorJoachim Breitner <mail@joachim-breitner.de>
Sat, 7 Jul 2007 07:24:25 +0000 (07:24 +0000)
committerJoachim Breitner <mail@joachim-breitner.de>
Sat, 7 Jul 2007 07:24:25 +0000 (07:24 +0000)
cairoboard.py
grasstheme.py [new file with mode: 0644]
ozeanien.py
seatheme.py [new file with mode: 0644]

index 4f6ade3..f8d0eb8 100644 (file)
@@ -159,315 +159,6 @@ class CairoBoard(gtk.DrawingArea):
 class CairoSlot:
     pass
 
-class SeaBoard(CairoBoard):
-    def draw_base(self, cr):
-        cr.translate(GRIDPAD, GRIDPAD)
-        cr.scale(GRIDWIDTH, GRIDWIDTH)
-
-        # Sea Background
-        # Unten
-        pat = cairo.LinearGradient (0, 5, 0, 5.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1,1)
-        pat.add_color_stop_rgba(1, 0, 0, 1,0)
-        cr.rectangle(1, 5, 7, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben
-        pat = cairo.LinearGradient (0, 0, 0, -0.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1,1)
-        pat.add_color_stop_rgba(1, 0, 0, 1,0)
-        cr.rectangle(1, -0.5, 7, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Links
-        pat = cairo.LinearGradient (1, 0, 0.5, 0)
-        pat.add_color_stop_rgba(0, 0, 0, 1,1)
-        pat.add_color_stop_rgba(1, 0, 0, 1,0)
-        cr.rectangle(0.5, 0, 0.5, 5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Rechts
-        pat = cairo.LinearGradient (8, 0, 8.5, 0)
-        pat.add_color_stop_rgba(0, 0, 0, 1,1)
-        pat.add_color_stop_rgba(1, 0, 0, 1,0)
-        cr.rectangle(8, 0, 0.5, 5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben Links
-        pat = cairo.RadialGradient(1,0,0, 1,0, 0.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
-        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
-        cr.rectangle(0.5, -0.5, 0.5, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben Rechts
-        pat = cairo.RadialGradient(8,0,0, 8,0, 0.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
-        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
-        cr.rectangle(8, -0.5, 8.5, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Unten Rechts
-        pat = cairo.RadialGradient(8,5,0, 8,5, 0.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
-        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
-        cr.rectangle(8, 5, 8.5, 5.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Unten Links
-        pat = cairo.RadialGradient(1,5,0, 1,5, 0.5)
-        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
-        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
-        cr.rectangle(0.5, 5, 1, 5.5)
-        cr.set_source(pat)
-        cr.fill()
-
-
-        # Frame
-        cr.set_source_rgb(1,1,1)
-        cr.set_line_width(0.05)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        for x in range(0,8):
-            cr.move_to(1+x, 0)
-            cr.line_to(1+x, 5.5)
-            cr.stroke()
-        for y in range(0,6):
-            cr.move_to(0.5, y)
-            cr.line_to(8.5, y)
-            cr.stroke()
-
-class SeaSlot(CairoSlot):
-    def __init__(self, fabric, slot):
-        self.fabric = fabric
-        self.slot = slot
-
-    def translate(self, cr):
-        raise "Abstract Method of Object" + str(self)
-
-    def draw(self, window):
-        if self.slot.card or self.slot.ship:
-            cr = window.cairo_create()
-            self.translate(cr)
-            cr.scale(SCALE, SCALE)
-
-            #cr.rectangle(-1, -1, 2, 2)
-            #cr.clip()
-
-            matrix = cr.get_matrix()
-            if self.slot.card:
-                self.fabric.setup(self.slot.card)
-                self.slot.card.guiinfo.draw(cr)
-                cr.set_matrix(matrix)
-            if self.slot.ship:
-                self.fabric.setup(self.slot.ship)
-                self.slot.ship.guiinfo.draw(cr)
-                cr.set_matrix(matrix)
-
-            if self.slot.highlighted:
-                cr.set_source_rgba(1, 1, 1, 0.5)
-                cr.rectangle(-1, -1, 2, 2)
-                cr.fill()
-
-class SeaHandSlot(SeaSlot):
-    def __init__(self, fabric, slot):
-        SeaSlot.__init__(self, fabric, slot)
-        self.x = 0
-        self.y = 0
-
-    def move_to(self, x,y):
-        self.x = x
-        self.y = y
-
-    def translate(self, cr):
-        cr.translate(self.x, self.y)
-
-class SeaBoardSlot(SeaSlot):
-    def __init__(self, fabric, slot):
-        SeaSlot.__init__(self, fabric, slot)
-
-    def translate(self, cr):
-        cr.translate(
-                 GRIDPAD + (self.slot.x+0.5)*GRIDWIDTH,
-                 GRIDPAD + (self.slot.y+0.5)*GRIDWIDTH
-        )
-
-class SeaPile(SeaSlot):
-    def __init__(self, fabric, slot):
-        SeaSlot.__init__(self, fabric, slot)
-        self.pile = self.slot
-
-    def translate(self, cr):
-        cr.translate(
-                PILE_X,
-                PILE_Y,
-        )
-    
-    def draw_arrow(self, cr):
-        cr.arc(1, 1, 0.5, 0, math.pi/2)
-        cr.set_source_rgb(0, 0, 0)
-        cr.set_line_width(0.1)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        cr.move_to(1,    1.5)
-        cr.line_to(0.75, 1.5)
-        cr.move_to(0.75, 1.5)
-        cr.line_to(1   , 1.75)
-        cr.move_to(0.75, 1.5)
-        cr.line_to(1   , 1.25)
-        cr.stroke()
-
-    def draw(self, window):
-        cr = window.cairo_create()
-        cr.translate(PILE_X, PILE_Y)
-        cr.scale(SCALE, SCALE)
-
-        cr.set_source_rgb(0.8, 0.8, 0.8)
-        cr.rectangle(-1, -1, 2, 2)
-        cr.fill()
-
-        matrix = cr.get_matrix()
-        self.draw_arrow(cr)
-        cr.scale(-1,1)
-        self.draw_arrow(cr)
-        cr.set_matrix(matrix)
-
-        cr.set_line_cap(cairo.LINE_CAP_SQUARE)
-        cr.translate(0,-3)
-        if self.pile.cards:
-            cr.set_source_rgb(0, 0, 0.5)
-            cr.rectangle(-1, -1, 2, 2)
-            cr.fill()
-        else:
-            cr.set_source_rgb(0, 0, 0)
-            cr.set_line_width(0.05)
-            cr.rectangle(-1, -1, 2, 2)
-            cr.stroke()
-
-        cr.set_font_size(1)
-        cr.set_source_rgb(1,1,1)
-        (_,_,w,h,_,_) = cr.text_extents(str(len(self.pile.cards)))
-
-        cr.move_to(-w/2, h/2)
-        cr.show_text(str(len(self.pile.cards)))
-        cr.fill()
-
-        SeaSlot.draw(self, window)
-
-class SeaBlackHole:
-    def __init__(self, fabric, bh):
-        self.fabric = fabric
-        self.bh = bh
-
-    def draw(self, window):
-        cr = window.cairo_create()
-        cr.translate(BH_X, BH_Y)
-        cr.scale(SCALE, SCALE)
-
-        cr.rectangle(-1, -1, 2, 2)
-        cr.clip()
-
-        cr.set_source_rgb(0,0,0)
-        cr.arc(0, 0, 0.8, 0, 2*math.pi)
-        cr.fill()
-        
-        cr.set_font_size(1)
-        cr.set_source_rgb(1,1,1)
-        (_,_,w,h,_,_) = cr.text_extents(str(self.bh.count))
-
-        cr.move_to(-w/2, h/2)
-        cr.show_text(str(self.bh.count))
-        cr.fill()
-
-class SeaCard:
-    def __init__(self, fabric, card):
-        self.fabric = fabric
-        self.card = card
-        self.cache = None
-
-    def draw(self, cr):
-        cr.rotate(-(self.card.rotation * math.pi / 2))
-
-        if not self.cache:
-            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
-                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
-            scr = cairo.Context(self.cache)
-            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
-            scr.scale(SCALE, SCALE)
-
-            self.draw_cache(scr)
-
-        cr.scale(1.0/SCALE, 1.0/SCALE)
-        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
-        cr.paint()
-
-    def draw_cache(self, cr):
-        # Meer
-        cr.set_source_rgb(0, 0, 1)
-        cr.rectangle(-1, -1, 2, 2)
-        cr.fill()
-
-        cr.set_source_rgb(0, 1, 0)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        cr.set_line_join(cairo.LINE_JOIN_ROUND)
-        cr.set_line_width(0.9)
-
-        p2c = [ (1,0), (0,-1), (-1,0), (0,1) ]
-
-        # Land
-        for island in self.card.islands:
-            point = island[0]
-            cr.move_to( *p2c[point] )
-            for point in island[1:]:
-                cr.line_to( *p2c[point] )
-            cr.close_path()
-            cr.stroke()
-        
-        # Border
-        cr.set_source_rgb(0, 0, 0)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        cr.set_line_width(0.05)
-        cr.rectangle(-1, -1, 2, 2)
-        cr.stroke()
-
-class SeaShip:
-    def __init__(self, fabric, ship):
-        self.fabric = fabric
-        self.ship = ship
-        self.cache = None
-    
-    def draw_cache(self, cr):
-        cr.move_to(0.9, 0)
-        cr.arc(0, 0, 0.3, math.pi, 0) 
-        cr.line_to(-0.9,0)
-        cr.line_to(-0.6, 0.6)
-        cr.line_to( 0.6, 0.6)
-
-        cr.set_source_rgb(1, 0, 0)
-        cr.fill()
-
-    def draw(self, cr):
-        cr.rotate(-(self.ship.rotation * math.pi / 2))
-        cr.rotate(math.pi / 2) # Koordinaten unten passen sonst nicht
-
-        if not self.cache:
-            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
-                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
-            scr = cairo.Context(self.cache)
-            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
-            scr.scale(SCALE, SCALE)
-
-            self.draw_cache(scr)
-
-        cr.scale(1.0/SCALE, 1.0/SCALE)
-        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
-        cr.paint()
-
 class CairoFabric:
     def get_widget(self, board):
         board_draw = self.get_drawer(board)
@@ -484,421 +175,4 @@ class CairoFabric:
         if not object.guiinfo:
             object.guiinfo = self.get_drawer(object)
 
-class SeaFabric(CairoFabric):
-    classes = [ 
-            (engine.Board,      SeaBoard),
-            (engine.BoardSlot,  SeaBoardSlot),
-            (engine.HandSlot,   SeaHandSlot),
-            (engine.Pile,       SeaPile),
-            (engine.Slot,       SeaSlot),
-            (engine.Ship,       SeaShip),
-            (engine.Card,       SeaCard),
-    ]
-
-class GrassBoard(CairoBoard):
-    def draw_base(self,cr):
-        cr.translate(GRIDPAD, GRIDPAD)
-        cr.scale(GRIDWIDTH, GRIDWIDTH)
-
-        # Sea Background
-
-        # Unten
-        pat = cairo.LinearGradient (0, 5, 0, 5.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
-        cr.rectangle(1, 5, 7, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben
-        pat = cairo.LinearGradient (0, 0, 0, -0.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
-        cr.rectangle(1, -0.5, 7, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Links
-        pat = cairo.LinearGradient (1, 0, 0.5, 0)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
-        cr.rectangle(0.5, 0, 0.5, 5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Rechts
-        pat = cairo.LinearGradient (8, 0, 8.5, 0)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
-        cr.rectangle(8, 0, 0.5, 5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben Links
-        pat = cairo.RadialGradient(1,0,0, 1,0, 0.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
-        cr.rectangle(0.5, -0.5, 0.5, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Oben Rechts
-        pat = cairo.RadialGradient(8,0,0, 8,0, 0.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
-        cr.rectangle(8, -0.5, 8.5, 0.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Unten Rechts
-        pat = cairo.RadialGradient(8,5,0, 8,5, 0.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
-        cr.rectangle(8, 5, 8.5, 5.5)
-        cr.set_source(pat)
-        cr.fill()
-
-        # Unten Links
-        pat = cairo.RadialGradient(1,5,0, 1,5, 0.5)
-        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
-        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
-        cr.rectangle(0.5, 5, 0.5, 5.5)
-        cr.set_source(pat)
-        cr.fill()
-
-
-        # Frame
-        cr.set_source_rgb(1,1,1)
-        cr.set_line_width(0.05)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        for x in range(0,8):
-            cr.move_to(1+x, 0)
-            cr.line_to(1+x, 5.5)
-            cr.stroke()
-        for y in range(0,6):
-            cr.move_to(0.5, y)
-            cr.line_to(8.5, y)
-            cr.stroke()
-
-class GrassSlot(CairoSlot):
-    def __init__(self, fabric, slot):
-        self.fabric = fabric
-        self.slot = slot
-
-    def translate(self, cr):
-        raise "Abstract Method of Object" + str(self)
-
-    def draw(self, window):
-        if self.slot.card or self.slot.ship:
-            cr = window.cairo_create()
-            self.translate(cr)
-            cr.scale(SCALE, SCALE)
-
-            #cr.rectangle(-1, -1, 2, 2)
-            #cr.clip()
-
-            matrix = cr.get_matrix()
-            if self.slot.card:
-                self.fabric.setup(self.slot.card)
-                self.slot.card.guiinfo.draw(cr)
-                cr.set_matrix(matrix)
-            if self.slot.ship:
-                self.fabric.setup(self.slot.ship)
-                self.slot.ship.guiinfo.draw(cr)
-                cr.set_matrix(matrix)
-
-            if self.slot.highlighted:
-                cr.set_source_rgba(1, 1, 1, 0.5)
-                cr.rectangle(-1, -1, 2, 2)
-                cr.fill()
-
-class GrassBoardSlot(GrassSlot):
-    def __init__(self, fabric, slot):
-        GrassSlot.__init__(self, fabric, slot)
-
-    def translate(self, cr):
-        cr.translate(
-                 GRIDPAD + (self.slot.x+0.5)*GRIDWIDTH,
-                 GRIDPAD + (self.slot.y+0.5)*GRIDWIDTH
-        )
-
-class GrassShip:
-    def __init__(self, fabric, ship):
-        self.fabric = fabric
-        self.ship = ship
-        self.cache = None
-    
-    def draw_cache(self, cr):
-        # Grundkörper (noch abzurunden)
-        cr.move_to(-0.5, -0.75)
-        cr.line_to(0.5, -0.75)
-        cr.line_to(0.5, 0.5)
-        cr.line_to(-0.5, 0.5)
-        cr.close_path()
-        cr.set_source_rgb(1, 0.2, 0.2)
-        cr.fill_preserve()
-        cr.set_source_rgb(0, 0, 0)
-        cr.set_line_width(0.05)
-        cr.stroke()
-
-        # Griff
-        cr.move_to(-0.25, 0.25)
-        cr.line_to(-0.55,  0.75)
-        cr.line_to( 0.55,  0.75)
-        cr.line_to( 0.25, 0.25)
-        cr.set_line_width(0.1)
-        cr.set_line_join(cairo.LINE_JOIN_ROUND)
-        cr.stroke()
-        
-        # Motor
-        cr.arc(0, -0.1 , 0.3, 0, 2*math.pi)
-        cr.set_source_rgb(0, 0, 0)
-        cr.fill()
-
-        # Augen
-        for _ in range(2):
-            cr.scale(-1,1)
-            cr.arc(0.3, -0.55 , 0.15, 0, 2*math.pi)
-            cr.set_source_rgb(1, 1, 1)
-            cr.fill_preserve()
-            cr.set_source_rgb(0, 0, 0)
-            cr.set_line_width(0.05)
-            cr.stroke()
-            cr.arc(0.25, -0.6 , 0.05, 0, 2*math.pi)
-            cr.set_source_rgb(0, 0, 0)
-            cr.fill()
-
-    def draw(self, cr):
-        cr.rotate(-(self.ship.rotation * math.pi / 2))
-        cr.rotate(math.pi / 2) # Koordinaten unten passen sonst nicht
-
-        if not self.cache:
-            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
-                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
-            scr = cairo.Context(self.cache)
-            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
-            scr.scale(SCALE, SCALE)
-
-            self.draw_cache(scr)
-
-        cr.scale(1.0/SCALE, 1.0/SCALE)
-        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
-        cr.paint()
-
-class GrassHandSlot(GrassSlot):
-    def __init__(self, fabric, slot):
-        GrassSlot.__init__(self, fabric, slot)
-        self.x = 0
-        self.y = 0
-
-    def move_to(self, x,y):
-        self.x = x
-        self.y = y
-
-    def translate(self, cr):
-        cr.translate(self.x, self.y)
-
-class GrassPile(GrassSlot):
-    def __init__(self, fabric, slot):
-        GrassSlot.__init__(self, fabric, slot)
-        self.pile = self.slot
-
-    def translate(self, cr):
-        cr.translate(
-                PILE_X,
-                PILE_Y,
-        )
-    
-    def draw_arrow(self, cr):
-        cr.arc(1, 1, 0.5, 0, math.pi/2)
-        cr.set_source_rgb(0, 0, 0)
-        cr.set_line_width(0.1)
-        cr.set_line_cap(cairo.LINE_CAP_ROUND)
-        cr.move_to(1,    1.5)
-        cr.line_to(0.75, 1.5)
-        cr.move_to(0.75, 1.5)
-        cr.line_to(1   , 1.75)
-        cr.move_to(0.75, 1.5)
-        cr.line_to(1   , 1.25)
-        cr.stroke()
-
-    def draw(self, window):
-        cr = window.cairo_create()
-        cr.translate(PILE_X, PILE_Y)
-        cr.scale(SCALE, SCALE)
-
-        cr.set_source_rgb(0.8, 0.8, 0.8)
-        cr.rectangle(-1, -1, 2, 2)
-        cr.fill()
-
-        matrix = cr.get_matrix()
-        self.draw_arrow(cr)
-        cr.scale(-1,1)
-        self.draw_arrow(cr)
-        cr.set_matrix(matrix)
-
-        cr.set_line_cap(cairo.LINE_CAP_SQUARE)
-        cr.translate(0,-3)
-        if self.pile.cards:
-            cr.set_source_rgb(0, 0, 0.5)
-            cr.rectangle(-1, -1, 2, 2)
-            cr.fill()
-        else:
-            cr.set_source_rgb(0, 0, 0)
-            cr.set_line_width(0.05)
-            cr.rectangle(-1, -1, 2, 2)
-            cr.stroke()
-
-        cr.set_font_size(1)
-        cr.set_source_rgb(1,1,1)
-        (_,_,w,h,_,_) = cr.text_extents(str(len(self.pile.cards)))
-
-        cr.move_to(-w/2, h/2)
-        cr.show_text(str(len(self.pile.cards)))
-        cr.fill()
-
-        GrassSlot.draw(self, window)
-
-class GrassCard:
-    def __init__(self, fabric, card):
-        self.fabric = fabric
-        self.card = card
-        self.cache = None
-
-    def draw(self, cr):
-        cr.rotate(-(self.card.rotation * math.pi / 2))
-
-        if not self.cache:
-            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
-                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
-            scr = cairo.Context(self.cache)
-            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
-            scr.scale(SCALE, SCALE)
-
-            self.draw_cache(scr)
-
-        cr.scale(1.0/SCALE, 1.0/SCALE)
-        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
-        cr.paint()
-
-    #Karte füllen
-    def draw_cache(self, cr):
-        orientation=0;
-        cr.set_source_rgb(0.6, 0.4, 0.3)
-        cr.rectangle(-1, -1, 2, 2)
-        cr.fill()
-        p2c = [ (0.7,0), (0,-0.7), (-0.7,0), (0,0.7) ]
-        between_p2c = [ (0.6,-0.6), (-0.6,-0.6), (-0.6,0.6), (0.6,0.6) ]
-        matrix=cr.get_matrix()
-        for c in [
-                    (-0.7,-0.6), 
-                    (0,-0.65),
-                    (-0.5,-0.6),
-                    (0.4,-0.55),
-                    (0.8,-0.6),
-                    (-0.3,-0.4),
-                    (0.6,-0.35),
-                    (-0.85,-0.3),
-                    (0.3,-0.3),
-                    (0,-0.25),
-                    (-0.6,-0.2),
-                    (0.75,-0.2),
-                    (0.5,-0.1),
-                    (-0.5,0),
-                    (0.3,0.1),
-                    (-0.1,0.1),
-                    (-0.8,0.2),
-                    (0.7,0.2),
-                    (-0.4,0.3),
-                    (0.85,0.3),
-                    (-0.1,0.35),
-                    (0.25,0.4),
-                    (-0.75,0.4),
-                    (0.6,0.45),
-                    (-0.45,0.5),
-                    (0,0.6),
-                    (-0.8,0.7),
-                    (0.75,0.7),
-                    (-0.4,0.75),
-                    (0.5,0.75),
-                    (0.15,0.8),
-                    (-0.2,0.85),
-                    (-0.85,0.9),
-                    (0.85,0.9),
-                    (0,0.95),
-                    (-0.5,1),
-                    (0.45,1),
-                    
-                ]:
-            cr.translate(*c)
-            self.draw_gras(cr, 0)
-            self.draw_gras(cr, 1)
-            cr.set_matrix(matrix)
-
-        for island in self.card.islands:
-            for dir in island:
-                cr.translate(*p2c[dir])
-                self.draw_flower(cr)
-                cr.set_matrix(matrix)
-            for dir in island[:-1]:
-                cr.translate(*between_p2c[dir])
-                self.draw_flower(cr)
-                cr.set_matrix(matrix)
-
-    #Einen Grashalm malen
-    def draw_gras(self, cr, orientation):
-        x=random.uniform(0.1,0.2)
-        y=random.uniform(0.2,0.3)
-        matrix=cr.get_matrix()
-        if orientation == 0: 
-            cr.scale(x, y)
-        else:
-            cr.scale(-x, y)
-        cr.translate(-1,-1)
-        cr.set_source_rgb(0, 1, 0)
-        cr.move_to(-1,-1)
-        cr.curve_to(0,-1,1,0,1,1)
-        cr.curve_to(0,1,0,-1,-1,-1)
-        cr.fill_preserve()
-        cr.set_source_rgb(0, 0, 0)
-        cr.set_line_width(0.1)
-        cr.stroke()
-        cr.set_matrix(matrix)
-            
-    def choose_flower_color(self):
-        return (random.random(),
-                random.random(),
-                random.random() )
-
-
-    #Eine Blume malen
-    def draw_flower(self, cr):
-        cr.rotate(random.uniform(0,2*math.pi))
-        matrix=cr.get_matrix()
-        cr.scale(0.25, 0.25)
-        color = self.choose_flower_color()
-        for n in range(5):
-            cr.set_source_rgb(*color)
-            cr.move_to(0,0)
-            cr.curve_to(0,-0.8,-0.2,-1,-1,-1)
-            cr.curve_to(-1,-0.2,-0.8,0.2,0,0)
-            cr.fill_preserve()
-            cr.set_source_rgb(0, 0, 0)
-            cr.set_line_width(0.1)
-            cr.stroke()
-            cr.rotate(2* math.pi / 5)
-        cr.set_matrix(matrix)
-    
-
-class GrassFabric(CairoFabric):
-    classes = [ 
-            (engine.Board,      GrassBoard),
-            (engine.BoardSlot,  GrassBoardSlot),
-            (engine.HandSlot,   GrassHandSlot),
-            (engine.Pile,       GrassPile),
-            (engine.Slot,       GrassSlot),
-            (engine.Ship,       GrassShip),
-            (engine.Card,       GrassCard),
-    ]
-
 # vim:ts=4:sw=4:sts=4:et
diff --git a/grasstheme.py b/grasstheme.py
new file mode 100644 (file)
index 0000000..5b0efd6
--- /dev/null
@@ -0,0 +1,421 @@
+#!/usr/bin/python
+# encoding:utf8
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import cairo
+import math
+import random
+
+from cairoboard import *
+import engine
+
+
+class GrassBoard(CairoBoard):
+    def draw_base(self,cr):
+        cr.translate(GRIDPAD, GRIDPAD)
+        cr.scale(GRIDWIDTH, GRIDWIDTH)
+
+        # Sea Background
+
+        # Unten
+        pat = cairo.LinearGradient (0, 5, 0, 5.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
+        cr.rectangle(1, 5, 7, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben
+        pat = cairo.LinearGradient (0, 0, 0, -0.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
+        cr.rectangle(1, -0.5, 7, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Links
+        pat = cairo.LinearGradient (1, 0, 0.5, 0)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
+        cr.rectangle(0.5, 0, 0.5, 5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Rechts
+        pat = cairo.LinearGradient (8, 0, 8.5, 0)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4,1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4,0)
+        cr.rectangle(8, 0, 0.5, 5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben Links
+        pat = cairo.RadialGradient(1,0,0, 1,0, 0.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
+        cr.rectangle(0.5, -0.5, 0.5, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben Rechts
+        pat = cairo.RadialGradient(8,0,0, 8,0, 0.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
+        cr.rectangle(8, -0.5, 8.5, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Unten Rechts
+        pat = cairo.RadialGradient(8,5,0, 8,5, 0.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
+        cr.rectangle(8, 5, 8.5, 5.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Unten Links
+        pat = cairo.RadialGradient(1,5,0, 1,5, 0.5)
+        pat.add_color_stop_rgba(0.3, 0.6, 0.4, 0.4, 1)
+        pat.add_color_stop_rgba(1, 0.6, 0.4, 0.4, 0)
+        cr.rectangle(0.5, 5, 0.5, 5.5)
+        cr.set_source(pat)
+        cr.fill()
+
+
+        # Frame
+        cr.set_source_rgb(1,1,1)
+        cr.set_line_width(0.05)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        for x in range(0,8):
+            cr.move_to(1+x, 0)
+            cr.line_to(1+x, 5.5)
+            cr.stroke()
+        for y in range(0,6):
+            cr.move_to(0.5, y)
+            cr.line_to(8.5, y)
+            cr.stroke()
+
+class GrassSlot(CairoSlot):
+    def __init__(self, fabric, slot):
+        self.fabric = fabric
+        self.slot = slot
+
+    def translate(self, cr):
+        raise "Abstract Method of Object" + str(self)
+
+    def draw(self, window):
+        if self.slot.card or self.slot.ship:
+            cr = window.cairo_create()
+            self.translate(cr)
+            cr.scale(SCALE, SCALE)
+
+            #cr.rectangle(-1, -1, 2, 2)
+            #cr.clip()
+
+            matrix = cr.get_matrix()
+            if self.slot.card:
+                self.fabric.setup(self.slot.card)
+                self.slot.card.guiinfo.draw(cr)
+                cr.set_matrix(matrix)
+            if self.slot.ship:
+                self.fabric.setup(self.slot.ship)
+                self.slot.ship.guiinfo.draw(cr)
+                cr.set_matrix(matrix)
+
+            if self.slot.highlighted:
+                cr.set_source_rgba(1, 1, 1, 0.5)
+                cr.rectangle(-1, -1, 2, 2)
+                cr.fill()
+
+class GrassBoardSlot(GrassSlot):
+    def __init__(self, fabric, slot):
+        GrassSlot.__init__(self, fabric, slot)
+
+    def translate(self, cr):
+        cr.translate(
+                 GRIDPAD + (self.slot.x+0.5)*GRIDWIDTH,
+                 GRIDPAD + (self.slot.y+0.5)*GRIDWIDTH
+        )
+
+class GrassShip:
+    def __init__(self, fabric, ship):
+        self.fabric = fabric
+        self.ship = ship
+        self.cache = None
+    
+    def draw_cache(self, cr):
+        # Grundkörper (noch abzurunden)
+        cr.move_to(-0.5, -0.75)
+        cr.line_to(0.5, -0.75)
+        cr.line_to(0.5, 0.5)
+        cr.line_to(-0.5, 0.5)
+        cr.close_path()
+        cr.set_source_rgb(1, 0.2, 0.2)
+        cr.fill_preserve()
+        cr.set_source_rgb(0, 0, 0)
+        cr.set_line_width(0.05)
+        cr.stroke()
+
+        # Griff
+        cr.move_to(-0.25, 0.25)
+        cr.line_to(-0.55,  0.75)
+        cr.line_to( 0.55,  0.75)
+        cr.line_to( 0.25, 0.25)
+        cr.set_line_width(0.1)
+        cr.set_line_join(cairo.LINE_JOIN_ROUND)
+        cr.stroke()
+        
+        # Motor
+        cr.arc(0, -0.1 , 0.3, 0, 2*math.pi)
+        cr.set_source_rgb(0, 0, 0)
+        cr.fill()
+
+        # Augen
+        for _ in range(2):
+            cr.scale(-1,1)
+            cr.arc(0.3, -0.55 , 0.15, 0, 2*math.pi)
+            cr.set_source_rgb(1, 1, 1)
+            cr.fill_preserve()
+            cr.set_source_rgb(0, 0, 0)
+            cr.set_line_width(0.05)
+            cr.stroke()
+            cr.arc(0.25, -0.6 , 0.05, 0, 2*math.pi)
+            cr.set_source_rgb(0, 0, 0)
+            cr.fill()
+
+    def draw(self, cr):
+        cr.rotate(-(self.ship.rotation * math.pi / 2))
+        cr.rotate(math.pi / 2) # Koordinaten unten passen sonst nicht
+
+        if not self.cache:
+            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
+                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
+            scr = cairo.Context(self.cache)
+            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
+            scr.scale(SCALE, SCALE)
+
+            self.draw_cache(scr)
+
+        cr.scale(1.0/SCALE, 1.0/SCALE)
+        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
+        cr.paint()
+
+class GrassHandSlot(GrassSlot):
+    def __init__(self, fabric, slot):
+        GrassSlot.__init__(self, fabric, slot)
+        self.x = 0
+        self.y = 0
+
+    def move_to(self, x,y):
+        self.x = x
+        self.y = y
+
+    def translate(self, cr):
+        cr.translate(self.x, self.y)
+
+class GrassPile(GrassSlot):
+    def __init__(self, fabric, slot):
+        GrassSlot.__init__(self, fabric, slot)
+        self.pile = self.slot
+
+    def translate(self, cr):
+        cr.translate(
+                PILE_X,
+                PILE_Y,
+        )
+    
+    def draw_arrow(self, cr):
+        cr.arc(1, 1, 0.5, 0, math.pi/2)
+        cr.set_source_rgb(0, 0, 0)
+        cr.set_line_width(0.1)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        cr.move_to(1,    1.5)
+        cr.line_to(0.75, 1.5)
+        cr.move_to(0.75, 1.5)
+        cr.line_to(1   , 1.75)
+        cr.move_to(0.75, 1.5)
+        cr.line_to(1   , 1.25)
+        cr.stroke()
+
+    def draw(self, window):
+        cr = window.cairo_create()
+        cr.translate(PILE_X, PILE_Y)
+        cr.scale(SCALE, SCALE)
+
+        cr.set_source_rgb(0.8, 0.8, 0.8)
+        cr.rectangle(-1, -1, 2, 2)
+        cr.fill()
+
+        matrix = cr.get_matrix()
+        self.draw_arrow(cr)
+        cr.scale(-1,1)
+        self.draw_arrow(cr)
+        cr.set_matrix(matrix)
+
+        cr.set_line_cap(cairo.LINE_CAP_SQUARE)
+        cr.translate(0,-3)
+        if self.pile.cards:
+            cr.set_source_rgb(0, 0, 0.5)
+            cr.rectangle(-1, -1, 2, 2)
+            cr.fill()
+        else:
+            cr.set_source_rgb(0, 0, 0)
+            cr.set_line_width(0.05)
+            cr.rectangle(-1, -1, 2, 2)
+            cr.stroke()
+
+        cr.set_font_size(1)
+        cr.set_source_rgb(1,1,1)
+        (_,_,w,h,_,_) = cr.text_extents(str(len(self.pile.cards)))
+
+        cr.move_to(-w/2, h/2)
+        cr.show_text(str(len(self.pile.cards)))
+        cr.fill()
+
+        GrassSlot.draw(self, window)
+
+class GrassCard:
+    def __init__(self, fabric, card):
+        self.fabric = fabric
+        self.card = card
+        self.cache = None
+
+    def draw(self, cr):
+        cr.rotate(-(self.card.rotation * math.pi / 2))
+
+        if not self.cache:
+            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
+                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
+            scr = cairo.Context(self.cache)
+            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
+            scr.scale(SCALE, SCALE)
+
+            self.draw_cache(scr)
+
+        cr.scale(1.0/SCALE, 1.0/SCALE)
+        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
+        cr.paint()
+
+    #Karte füllen
+    def draw_cache(self, cr):
+        orientation=0;
+        cr.set_source_rgb(0.6, 0.4, 0.3)
+        cr.rectangle(-1, -1, 2, 2)
+        cr.fill()
+        p2c = [ (0.7,0), (0,-0.7), (-0.7,0), (0,0.7) ]
+        between_p2c = [ (0.6,-0.6), (-0.6,-0.6), (-0.6,0.6), (0.6,0.6) ]
+        matrix=cr.get_matrix()
+        for c in [
+                    (-0.7,-0.6), 
+                    (0,-0.65),
+                    (-0.5,-0.6),
+                    (0.4,-0.55),
+                    (0.8,-0.6),
+                    (-0.3,-0.4),
+                    (0.6,-0.35),
+                    (-0.85,-0.3),
+                    (0.3,-0.3),
+                    (0,-0.25),
+                    (-0.6,-0.2),
+                    (0.75,-0.2),
+                    (0.5,-0.1),
+                    (-0.5,0),
+                    (0.3,0.1),
+                    (-0.1,0.1),
+                    (-0.8,0.2),
+                    (0.7,0.2),
+                    (-0.4,0.3),
+                    (0.85,0.3),
+                    (-0.1,0.35),
+                    (0.25,0.4),
+                    (-0.75,0.4),
+                    (0.6,0.45),
+                    (-0.45,0.5),
+                    (0,0.6),
+                    (-0.8,0.7),
+                    (0.75,0.7),
+                    (-0.4,0.75),
+                    (0.5,0.75),
+                    (0.15,0.8),
+                    (-0.2,0.85),
+                    (-0.85,0.9),
+                    (0.85,0.9),
+                    (0,0.95),
+                    (-0.5,1),
+                    (0.45,1),
+                    
+                ]:
+            cr.translate(*c)
+            self.draw_gras(cr, 0)
+            self.draw_gras(cr, 1)
+            cr.set_matrix(matrix)
+
+        for island in self.card.islands:
+            for dir in island:
+                cr.translate(*p2c[dir])
+                self.draw_flower(cr)
+                cr.set_matrix(matrix)
+            for dir in island[:-1]:
+                cr.translate(*between_p2c[dir])
+                self.draw_flower(cr)
+                cr.set_matrix(matrix)
+
+    #Einen Grashalm malen
+    def draw_gras(self, cr, orientation):
+        x=random.uniform(0.1,0.2)
+        y=random.uniform(0.2,0.3)
+        matrix=cr.get_matrix()
+        if orientation == 0: 
+            cr.scale(x, y)
+        else:
+            cr.scale(-x, y)
+        cr.translate(-1,-1)
+        cr.set_source_rgb(0, 1, 0)
+        cr.move_to(-1,-1)
+        cr.curve_to(0,-1,1,0,1,1)
+        cr.curve_to(0,1,0,-1,-1,-1)
+        cr.fill_preserve()
+        cr.set_source_rgb(0, 0, 0)
+        cr.set_line_width(0.1)
+        cr.stroke()
+        cr.set_matrix(matrix)
+            
+    def choose_flower_color(self):
+        return (random.random(),
+                random.random(),
+                random.random() )
+
+
+    #Eine Blume malen
+    def draw_flower(self, cr):
+        cr.rotate(random.uniform(0,2*math.pi))
+        matrix=cr.get_matrix()
+        cr.scale(0.25, 0.25)
+        color = self.choose_flower_color()
+        for n in range(5):
+            cr.set_source_rgb(*color)
+            cr.move_to(0,0)
+            cr.curve_to(0,-0.8,-0.2,-1,-1,-1)
+            cr.curve_to(-1,-0.2,-0.8,0.2,0,0)
+            cr.fill_preserve()
+            cr.set_source_rgb(0, 0, 0)
+            cr.set_line_width(0.1)
+            cr.stroke()
+            cr.rotate(2* math.pi / 5)
+        cr.set_matrix(matrix)
+    
+class GrassFabric(CairoFabric):
+    classes = [ 
+            (engine.Board,      GrassBoard),
+            (engine.BoardSlot,  GrassBoardSlot),
+            (engine.HandSlot,   GrassHandSlot),
+            (engine.Pile,       GrassPile),
+            (engine.Slot,       GrassSlot),
+            (engine.Ship,       GrassShip),
+            (engine.Card,       GrassCard),
+    ]
+
+
+# vim:ts=4:sw=4:sts=4:et
index 6c07e21..56ff1cb 100644 (file)
@@ -8,7 +8,8 @@ import gtk
 import sys
 
 from engine import * 
-from cairoboard import SeaFabric, GrassFabric
+from seatheme import SeaFabric
+from grasstheme import GrassFabric
 
 
 DEBUG = 1
diff --git a/seatheme.py b/seatheme.py
new file mode 100644 (file)
index 0000000..d0b455a
--- /dev/null
@@ -0,0 +1,335 @@
+#!/usr/bin/python
+# encoding:utf8
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import cairo
+import math
+import random
+
+from cairoboard import *
+import engine
+
+class SeaBoard(CairoBoard):
+    def draw_base(self, cr):
+        cr.translate(GRIDPAD, GRIDPAD)
+        cr.scale(GRIDWIDTH, GRIDWIDTH)
+
+        # Sea Background
+        # Unten
+        pat = cairo.LinearGradient (0, 5, 0, 5.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1,1)
+        pat.add_color_stop_rgba(1, 0, 0, 1,0)
+        cr.rectangle(1, 5, 7, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben
+        pat = cairo.LinearGradient (0, 0, 0, -0.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1,1)
+        pat.add_color_stop_rgba(1, 0, 0, 1,0)
+        cr.rectangle(1, -0.5, 7, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Links
+        pat = cairo.LinearGradient (1, 0, 0.5, 0)
+        pat.add_color_stop_rgba(0, 0, 0, 1,1)
+        pat.add_color_stop_rgba(1, 0, 0, 1,0)
+        cr.rectangle(0.5, 0, 0.5, 5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Rechts
+        pat = cairo.LinearGradient (8, 0, 8.5, 0)
+        pat.add_color_stop_rgba(0, 0, 0, 1,1)
+        pat.add_color_stop_rgba(1, 0, 0, 1,0)
+        cr.rectangle(8, 0, 0.5, 5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben Links
+        pat = cairo.RadialGradient(1,0,0, 1,0, 0.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
+        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
+        cr.rectangle(0.5, -0.5, 0.5, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Oben Rechts
+        pat = cairo.RadialGradient(8,0,0, 8,0, 0.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
+        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
+        cr.rectangle(8, -0.5, 8.5, 0.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Unten Rechts
+        pat = cairo.RadialGradient(8,5,0, 8,5, 0.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
+        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
+        cr.rectangle(8, 5, 8.5, 5.5)
+        cr.set_source(pat)
+        cr.fill()
+
+        # Unten Links
+        pat = cairo.RadialGradient(1,5,0, 1,5, 0.5)
+        pat.add_color_stop_rgba(0, 0, 0, 1, 1)
+        pat.add_color_stop_rgba(1, 0, 0, 1, 0)
+        cr.rectangle(0.5, 5, 1, 5.5)
+        cr.set_source(pat)
+        cr.fill()
+
+
+        # Frame
+        cr.set_source_rgb(1,1,1)
+        cr.set_line_width(0.05)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        for x in range(0,8):
+            cr.move_to(1+x, 0)
+            cr.line_to(1+x, 5.5)
+            cr.stroke()
+        for y in range(0,6):
+            cr.move_to(0.5, y)
+            cr.line_to(8.5, y)
+            cr.stroke()
+
+class SeaSlot(CairoSlot):
+    def __init__(self, fabric, slot):
+        self.fabric = fabric
+        self.slot = slot
+
+    def translate(self, cr):
+        raise "Abstract Method of Object" + str(self)
+
+    def draw(self, window):
+        if self.slot.card or self.slot.ship:
+            cr = window.cairo_create()
+            self.translate(cr)
+            cr.scale(SCALE, SCALE)
+
+            #cr.rectangle(-1, -1, 2, 2)
+            #cr.clip()
+
+            matrix = cr.get_matrix()
+            if self.slot.card:
+                self.fabric.setup(self.slot.card)
+                self.slot.card.guiinfo.draw(cr)
+                cr.set_matrix(matrix)
+            if self.slot.ship:
+                self.fabric.setup(self.slot.ship)
+                self.slot.ship.guiinfo.draw(cr)
+                cr.set_matrix(matrix)
+
+            if self.slot.highlighted:
+                cr.set_source_rgba(1, 1, 1, 0.5)
+                cr.rectangle(-1, -1, 2, 2)
+                cr.fill()
+
+class SeaHandSlot(SeaSlot):
+    def __init__(self, fabric, slot):
+        SeaSlot.__init__(self, fabric, slot)
+        self.x = 0
+        self.y = 0
+
+    def move_to(self, x,y):
+        self.x = x
+        self.y = y
+
+    def translate(self, cr):
+        cr.translate(self.x, self.y)
+
+class SeaBoardSlot(SeaSlot):
+    def __init__(self, fabric, slot):
+        SeaSlot.__init__(self, fabric, slot)
+
+    def translate(self, cr):
+        cr.translate(
+                 GRIDPAD + (self.slot.x+0.5)*GRIDWIDTH,
+                 GRIDPAD + (self.slot.y+0.5)*GRIDWIDTH
+        )
+
+class SeaPile(SeaSlot):
+    def __init__(self, fabric, slot):
+        SeaSlot.__init__(self, fabric, slot)
+        self.pile = self.slot
+
+    def translate(self, cr):
+        cr.translate(
+                PILE_X,
+                PILE_Y,
+        )
+    
+    def draw_arrow(self, cr):
+        cr.arc(1, 1, 0.5, 0, math.pi/2)
+        cr.set_source_rgb(0, 0, 0)
+        cr.set_line_width(0.1)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        cr.move_to(1,    1.5)
+        cr.line_to(0.75, 1.5)
+        cr.move_to(0.75, 1.5)
+        cr.line_to(1   , 1.75)
+        cr.move_to(0.75, 1.5)
+        cr.line_to(1   , 1.25)
+        cr.stroke()
+
+    def draw(self, window):
+        cr = window.cairo_create()
+        cr.translate(PILE_X, PILE_Y)
+        cr.scale(SCALE, SCALE)
+
+        cr.set_source_rgb(0.8, 0.8, 0.8)
+        cr.rectangle(-1, -1, 2, 2)
+        cr.fill()
+
+        matrix = cr.get_matrix()
+        self.draw_arrow(cr)
+        cr.scale(-1,1)
+        self.draw_arrow(cr)
+        cr.set_matrix(matrix)
+
+        cr.set_line_cap(cairo.LINE_CAP_SQUARE)
+        cr.translate(0,-3)
+        if self.pile.cards:
+            cr.set_source_rgb(0, 0, 0.5)
+            cr.rectangle(-1, -1, 2, 2)
+            cr.fill()
+        else:
+            cr.set_source_rgb(0, 0, 0)
+            cr.set_line_width(0.05)
+            cr.rectangle(-1, -1, 2, 2)
+            cr.stroke()
+
+        cr.set_font_size(1)
+        cr.set_source_rgb(1,1,1)
+        (_,_,w,h,_,_) = cr.text_extents(str(len(self.pile.cards)))
+
+        cr.move_to(-w/2, h/2)
+        cr.show_text(str(len(self.pile.cards)))
+        cr.fill()
+
+        SeaSlot.draw(self, window)
+
+class SeaBlackHole:
+    def __init__(self, fabric, bh):
+        self.fabric = fabric
+        self.bh = bh
+
+    def draw(self, window):
+        cr = window.cairo_create()
+        cr.translate(BH_X, BH_Y)
+        cr.scale(SCALE, SCALE)
+
+        cr.rectangle(-1, -1, 2, 2)
+        cr.clip()
+
+        cr.set_source_rgb(0,0,0)
+        cr.arc(0, 0, 0.8, 0, 2*math.pi)
+        cr.fill()
+        
+        cr.set_font_size(1)
+        cr.set_source_rgb(1,1,1)
+        (_,_,w,h,_,_) = cr.text_extents(str(self.bh.count))
+
+        cr.move_to(-w/2, h/2)
+        cr.show_text(str(self.bh.count))
+        cr.fill()
+
+class SeaCard:
+    def __init__(self, fabric, card):
+        self.fabric = fabric
+        self.card = card
+        self.cache = None
+
+    def draw(self, cr):
+        cr.rotate(-(self.card.rotation * math.pi / 2))
+
+        if not self.cache:
+            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
+                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
+            scr = cairo.Context(self.cache)
+            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
+            scr.scale(SCALE, SCALE)
+
+            self.draw_cache(scr)
+
+        cr.scale(1.0/SCALE, 1.0/SCALE)
+        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
+        cr.paint()
+
+    def draw_cache(self, cr):
+        # Meer
+        cr.set_source_rgb(0, 0, 1)
+        cr.rectangle(-1, -1, 2, 2)
+        cr.fill()
+
+        cr.set_source_rgb(0, 1, 0)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        cr.set_line_join(cairo.LINE_JOIN_ROUND)
+        cr.set_line_width(0.9)
+
+        p2c = [ (1,0), (0,-1), (-1,0), (0,1) ]
+
+        # Land
+        for island in self.card.islands:
+            point = island[0]
+            cr.move_to( *p2c[point] )
+            for point in island[1:]:
+                cr.line_to( *p2c[point] )
+            cr.close_path()
+            cr.stroke()
+        
+        # Border
+        cr.set_source_rgb(0, 0, 0)
+        cr.set_line_cap(cairo.LINE_CAP_ROUND)
+        cr.set_line_width(0.05)
+        cr.rectangle(-1, -1, 2, 2)
+        cr.stroke()
+
+class SeaShip:
+    def __init__(self, fabric, ship):
+        self.fabric = fabric
+        self.ship = ship
+        self.cache = None
+    
+    def draw_cache(self, cr):
+        cr.move_to(0.9, 0)
+        cr.arc(0, 0, 0.3, math.pi, 0) 
+        cr.line_to(-0.9,0)
+        cr.line_to(-0.6, 0.6)
+        cr.line_to( 0.6, 0.6)
+
+        cr.set_source_rgb(1, 0, 0)
+        cr.fill()
+
+    def draw(self, cr):
+        cr.rotate(-(self.ship.rotation * math.pi / 2))
+        cr.rotate(math.pi / 2) # Koordinaten unten passen sonst nicht
+
+        if not self.cache:
+            self.cache = cr.get_target().create_similar(cairo.CONTENT_COLOR_ALPHA, 
+                    GRIDWIDTH + GRIDPAD, GRIDWIDTH + GRIDPAD)
+            scr = cairo.Context(self.cache)
+            scr.translate((GRIDWIDTH + GRIDPAD)/2, (GRIDWIDTH+GRIDPAD)/2)
+            scr.scale(SCALE, SCALE)
+
+            self.draw_cache(scr)
+
+        cr.scale(1.0/SCALE, 1.0/SCALE)
+        cr.set_source_surface(self.cache,-(GRIDWIDTH + GRIDPAD)/2,-(GRIDWIDTH + GRIDPAD)/2)
+        cr.paint()
+
+class SeaFabric(CairoFabric):
+    classes = [ 
+            (engine.Board,      SeaBoard),
+            (engine.BoardSlot,  SeaBoardSlot),
+            (engine.HandSlot,   SeaHandSlot),
+            (engine.Pile,       SeaPile),
+            (engine.Slot,       SeaSlot),
+            (engine.Ship,       SeaShip),
+            (engine.Card,       SeaCard),
+    ]
+
+# vim:ts=4:sw=4:sts=4:et