本文整理汇总了Python中cairo.ANTIALIAS_DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Python cairo.ANTIALIAS_DEFAULT属性的具体用法?Python cairo.ANTIALIAS_DEFAULT怎么用?Python cairo.ANTIALIAS_DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cairo
的用法示例。
在下文中一共展示了cairo.ANTIALIAS_DEFAULT属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_page
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def _draw_page(self):
self.ctx.set_line_width(1.0 / self.zoom)
offset = 5.0 / self.zoom
w, h = self.printer.get_page_size()
# ---Page shadow
self.ctx.rectangle(-w / 2.0 + offset, -h / 2.0 - offset, w, h)
self.ctx.set_source_rgba(*CAIRO_GRAY)
self.ctx.fill()
# ---Page
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.set_source_rgb(*CAIRO_WHITE)
self.ctx.fill()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
示例2: _render_page
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def _render_page(self):
self.ctx.save()
w, h = self.printer.get_page_size()
t, r, b, l = self.printer.margins
rect = (-w / 2.0 + l, -h / 2.0 + b, w - l - r, h - t - b)
self.ctx.rectangle(*rect)
self.ctx.clip()
groups = self.pages[self.page_index].childs
for group in groups:
self.renderer.render(self.ctx, group.childs)
self.ctx.restore()
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
self.ctx.set_source_rgb(*CAIRO_RED)
width = 1.0 / self.zoom
self.ctx.set_line_width(1.0 / self.zoom)
self.ctx.set_dash([3 * width, 3 * width])
self.ctx.rectangle(*rect)
self.ctx.stroke()
self.ctx.set_dash([])
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
示例3: generate_fontsample_cache
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def generate_fontsample_cache(fonts):
w = config.font_preview_width
fontsize = config.font_preview_size
color = cms.val_255(config.font_preview_color)
text = config.font_preview_text.decode('utf-8')
for item in fonts:
h = libpango.get_sample_size(text, item, fontsize)[1]
if not h:
h = 10
LOG.warn('Incorrect font <%s>: zero font height', item)
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h)
ctx = cairo.Context(surface)
ctx.set_source_rgb(0.0, 0.0, 0.0)
ctx.paint()
matrix = cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)
ctx.set_matrix(matrix)
ctx.set_source_rgb(1.0, 1.0, 1.0)
ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
libpango.render_sample(ctx, text, item, fontsize)
ctx.fill()
bmp = wal.copy_surface_to_bitmap(surface)
FONTSAMPLE_CACHE.append(wal.invert_text_bitmap(bmp, color))
示例4: draw_gradient_vector
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw_gradient_vector(self, start, end, stops=None):
self.ctx.set_matrix(self.direct_matrix)
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
self.ctx.set_source_rgba(*config.gradient_vector_bg_color)
self.ctx.set_line_width(config.gradient_vector_width)
self.ctx.set_dash([])
self.ctx.move_to(*start)
self.ctx.line_to(*end)
self.ctx.stroke()
self.ctx.set_source_rgba(*config.gradient_vector_fg_color)
self.ctx.set_line_width(config.gradient_vector_width)
self.ctx.set_dash(config.gradient_vector_dash)
self.ctx.move_to(*start)
self.ctx.line_to(*end)
self.ctx.stroke()
self.draw_curve_point(start, 'gradient_point')
self.draw_curve_point(end, 'gradient_point')
示例5: draw_curve_point
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw_curve_point(self, point, data):
size, fill, stroke, stroke_width = data if isinstance(data, tuple) \
else self.point_data[data]
cx, cy = point if len(point) == 2 else point[2]
x, y = cx - int(size / 2.0), cy - int(size / 2.0)
self.ctx.move_to(x, y)
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
self.ctx.set_dash([])
self.ctx.set_source_rgb(*fill)
self.ctx.rectangle(x, y, size, size)
self.ctx.fill()
self.ctx.set_line_width(stroke_width)
self.ctx.set_source_rgb(*stroke)
self.ctx.rectangle(x, y, size, size)
self.ctx.stroke()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
示例6: draw
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw(self, context, rect, *args):
"""
This method is called by the parent Chart instance. It
calls _do_draw.
@type context: cairo.Context
@param context: The context to draw on.
@type rect: gtk.gdk.Rectangle
@param rect: A rectangle representing the charts area.
"""
res = None
if self._show:
if not self._antialias:
context.set_antialias(cairo.ANTIALIAS_NONE)
res = self._do_draw(context, rect, *args)
context.set_antialias(cairo.ANTIALIAS_DEFAULT)
return res
示例7: _draw_page_border
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def _draw_page_border(self):
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
w, h = self.printer.get_page_size()
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.set_source_rgb(*CAIRO_BLACK)
self.ctx.stroke()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
示例8: draw_control_point
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw_control_point(self, start, end):
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
self.ctx.set_line_width(config.control_line_stroke_width)
self.ctx.set_dash([])
self.ctx.set_source_rgba(*config.control_line_bg_stroke_color)
self.ctx.move_to(*start)
self.ctx.line_to(*end)
self.ctx.stroke()
self.ctx.set_source_rgba(*config.control_line_stroke_color)
self.ctx.set_dash(config.control_line_stroke_dash)
self.ctx.move_to(*start)
self.ctx.line_to(*end)
self.ctx.stroke()
self.draw_curve_point(end, 'control_point')
示例9: draw_text_selection
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw_text_selection(self, bboxs, trafo):
self.set_direct_matrix()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
self.ctx.set_source_rgba(*config.text_selection_color)
for item in bboxs:
cpath = libcairo.convert_bbox_to_cpath(item)
libcairo.apply_trafo(cpath, trafo)
libcairo.apply_trafo(cpath, self.canvas.trafo)
self.ctx.new_path()
self.ctx.append_path(cpath)
self.ctx.fill()
示例10: draw_text_cursor
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw_text_cursor(self, start, end):
self.set_direct_matrix()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
if start[0] == end[0] or start[1] == end[1]:
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
self.ctx.set_dash([])
self.ctx.set_source_rgb(*config.text_cursor_color)
self.ctx.set_line_width(config.text_cursor_width)
self.ctx.move_to(*start)
self.ctx.line_to(*end)
self.ctx.stroke()
# ------DIRECT DRAWING
示例11: draw
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def draw(self, context, rect, yaxis):
"""
This method is called by the parent Plot instance. It
calls _do_draw.
"""
if self._show:
if not self._antialias:
context.set_antialias(cairo.ANTIALIAS_NONE)
self._do_draw(context, rect, yaxis)
context.set_antialias(cairo.ANTIALIAS_DEFAULT)
示例12: render
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def render(self, ctx, objs=None):
objs = objs or []
if self.antialias_flag:
ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
else:
ctx.set_antialias(cairo.ANTIALIAS_NONE)
if objs:
for obj in objs:
self.render_object(ctx, obj)
示例13: render
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def render(self, ctx, objs=[]):
if self.antialias_flag:
ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)
else:
ctx.set_antialias(cairo.ANTIALIAS_NONE)
if objs:
for obj in objs:
self.render_object(ctx, obj)
示例14: paint_page
# 需要导入模块: import cairo [as 别名]
# 或者: from cairo import ANTIALIAS_DEFAULT [as 别名]
def paint_page(self):
self.ctx.set_line_width(1.0 / self.canvas.zoom)
offset = 5.0 / self.canvas.zoom
w, h = self.presenter.get_page_size()
border = self.doc_methods.get_page_border()
if border:
self.ctx.rectangle(-w / 2.0 + offset, -h / 2.0 - offset, w, h)
self.ctx.set_source_rgba(*CAIRO_GRAY)
self.ctx.fill()
self.ctx.set_antialias(cairo.ANTIALIAS_NONE)
page_fill = self.doc_methods.get_page_fill()
if page_fill[0] == sk2const.FILL_SOLID:
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.set_source_rgb(*page_fill[1])
self.ctx.fill()
else:
units = self.doc_methods.get_doc_units()
gdx = uc2const.unit_dict[units]
dx = self.calc_grid(0.0, 0.0, gdx, gdx)[2] / self.canvas.zoom
origin = self.doc_methods.get_doc_origin()
sx = sy = 0.0
if origin == sk2const.DOC_ORIGIN_LU:
sy = dx - (h - float(int(h / dx)) * dx)
elif origin == sk2const.DOC_ORIGIN_CENTER:
sy = dx - (h / 2.0 - float(int(h / (2.0 * dx))) * dx)
sx = dx - (w / 2.0 - float(int(w / (2.0 * dx))) * dx)
self.ctx.save()
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.clip()
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.set_source_rgb(*page_fill[1][1])
self.ctx.fill()
self.ctx.set_source_rgb(*page_fill[1][0])
ypos = ystart = -h / 2.0 - sy
j = 0
while ypos < h / 2.0:
ypos = ystart + j * dx
xpos = xstart = -w / 2.0 - sx
i = 0
if j % 2:
xpos = xstart = -w / 2.0 + dx - sx
while xpos < w / 2.0:
xpos = xstart + i * dx * 2.0
self.ctx.rectangle(xpos, ypos, dx, dx)
self.ctx.fill()
i += 1
j += 1
self.ctx.restore()
if border:
self.ctx.rectangle(-w / 2.0, -h / 2.0, w, h)
self.ctx.set_source_rgb(*CAIRO_BLACK)
self.ctx.stroke()
self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT)