Python cairo.ANTIALIAS_DEFAULT Examples
The following are 15
code examples of cairo.ANTIALIAS_DEFAULT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cairo
, or try the search function
.
Example #1
Source File: canvas.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: canvas.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: fontctrl.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
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))
Example #4
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
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')
Example #5
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
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)
Example #6
Source File: chart_object.py From openxenmanager with GNU General Public License v2.0 | 6 votes |
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
Example #7
Source File: canvas.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
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)
Example #8
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
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')
Example #9
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
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()
Example #10
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
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
Example #11
Source File: line_chart.py From openxenmanager with GNU General Public License v2.0 | 5 votes |
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)
Example #12
Source File: line_chart.py From openxenmanager with GNU General Public License v2.0 | 5 votes |
def draw(self, context, rect, xaxis): """ 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, xaxis) context.set_antialias(cairo.ANTIALIAS_DEFAULT)
Example #13
Source File: crenderer.py From uniconvertor with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #14
Source File: crenderer.py From uniconvertor with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #15
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 4 votes |
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)