With U+1F54A 🕊 Dove of Peace.
class FreeOver_tile (FreeOver):
def draw (self, ctx, width, height):
tiledata = self.tile_data ()
tw = tiledata ["width" ]
th = tiledata ["height"]
data = tiledata ["data" ]
one = self.tile_one
for x, y in self.tile_locations (width, height, tw, th):
one (ctx, x, y, tw, th, data)
def tile_data (self):
return {
"width": 60,
"height": 60,
"data": None,
}
def tile_locations (self, cw, ch, tw, th):
halfth = th // 2
xd, xm = divmod (cw, tw)
yd, ym = divmod (ch + halfth, th)
xn = xd + (1 if xm > 0 else 0)
yn = yd + (1 if ym > 0 else 0)
ryn = range (yn)
offset = 0
for xk in range (xn):
for yk in ryn:
yield (xk * tw, yk * th - offset)
offset = halfth - offset
def tile_one (self, ctx, x, y, w, h, somedata):
dx, dy = 3, 3
kgeo.Path.polyline (
ctx,
[(x + dx, y + h / 2),
(x + w - dx, y + dy),
(x + w - dx, y + h - dy)],
True)
ctx.set_source_rgb (0, 1, 0)
ctx.stroke ()
class FreeOver_tile2 (FreeOver_tile):
def tile_data (self):
path = "dove.png"
surf = cairo.ImageSurface.create_from_png (path)
return {
"width": surf.get_width (),
"height": surf.get_height (),
"data": {
"surface": surf
}
}
def tile_one (self, ctx, x, y, w, h, somedata):
ctx.save ()
ctx.translate (x, y)
ctx.set_source_surface (
somedata ["surface"], 0, 0)
ctx.paint ()
ctx.restore ()