Python cairo.ANTIALIAS_NONE Examples
The following are 18
code examples of cairo.ANTIALIAS_NONE().
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: 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 #3
Source File: ruler.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def paint(self): if self.presenter is None: return w, h = self.dc.get_size() fmt = cairo.FORMAT_RGB24 if self.surface is None or self.width != w or self.height != h: self.surface = cairo.ImageSurface(fmt, w, h) self.width, self.height = w, h self.ctx = cairo.Context(self.surface) self.ctx.set_matrix(cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)) self.ctx.set_source_rgb(*config.ruler_bg) self.ctx.paint() self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash([]) self.ctx.set_source_rgb(*config.ruler_fg) if self.vertical: self.vrender(w, h) else: self.hrender(w, h) self.dc.draw_surface(self.surface, 0, 0)
Example #4
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def _draw_frame(self, path): self.start_soft_repaint() self.reflect_snap() self.ctx.set_matrix(self.direct_matrix) self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash([]) self.ctx.set_source_rgb(*CAIRO_WHITE) self.ctx.new_path() self.ctx.append_path(path) self.ctx.stroke() self.ctx.set_dash(config.sel_frame_dash) self.ctx.set_source_rgb(*config.sel_frame_color) self.ctx.new_path() self.ctx.append_path(path) self.ctx.stroke() self.end_soft_repaint()
Example #5
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def paint_guide_dragging(self, point=None, orient=uc2const.HORIZONTAL): point = point or [] self.start_soft_repaint() self.ctx.set_matrix(self.direct_matrix) self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash(config.guide_line_dash) self.ctx.set_source_rgba(*config.guide_line_dragging_color) if point: if orient == uc2const.HORIZONTAL: y_win = self.canvas.point_doc_to_win(point)[1] self.ctx.move_to(0, y_win) self.ctx.line_to(self.width, y_win) self.ctx.stroke() else: x_win = self.canvas.point_doc_to_win(point)[0] self.ctx.move_to(x_win, 0) self.ctx.line_to(x_win, self.height) self.ctx.stroke() self.reflect_snap() self.end_soft_repaint()
Example #6
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def reflect_snap(self): if self.canvas.show_snapping: snap = self.presenter.snap.active_snap if not snap[0] is None or not snap[1] is None: self.ctx.set_matrix(self.direct_matrix) self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash(config.snap_line_dash) self.ctx.set_source_rgba(*config.snap_line_color) if not snap[0] is None: x_win = self.canvas.point_doc_to_win([snap[0], 0])[0] self.ctx.move_to(x_win, 0) self.ctx.line_to(x_win, self.height) self.ctx.stroke() if not snap[1] is None: y_win = self.canvas.point_doc_to_win([0, snap[1]])[1] self.ctx.move_to(0, y_win) self.ctx.line_to(self.width, y_win) self.ctx.stroke() self.presenter.snap.active_snap = [None, None]
Example #7
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def render_guides(self): guide_layer = self.presenter.methods.get_guide_layer() if not self.presenter.methods.is_layer_visible(guide_layer): return guides = [child for child in guide_layer.childs if child.is_guide] self.ctx.set_matrix(self.direct_matrix) self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash(config.guide_line_dash) self.ctx.set_source_rgba(*guide_layer.color) for item in guides: x_win, y_win = self.canvas.point_doc_to_win(2 * [item.position]) if item.orientation == uc2const.HORIZONTAL: self.ctx.move_to(0, y_win) self.ctx.line_to(self.width, y_win) else: self.ctx.move_to(x_win, 0) self.ctx.line_to(x_win, self.height) self.ctx.stroke() # ------GRID RENDERING
Example #8
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 #9
Source File: ruler.py From sk1-wx with GNU General Public License v3.0 | 6 votes |
def paint(self): w, h = self.get_size() if self.surface is None or self.width != w or self.height != h: self.surface = cairo.ImageSurface(cairo.FORMAT_RGB24, w, h) self.width, self.height = w, h self.ctx = cairo.Context(self.surface) self.ctx.set_matrix(cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)) self.ctx.set_source_rgb(*config.ruler_bg) self.ctx.paint() self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash([]) self.ctx.set_source_rgb(*config.ruler_fg) if self.horizontal: self.hrender(w, h) else: self.vrender(w, h) self.draw_bitmap(wal.copy_surface_to_bitmap(self.surface))
Example #10
Source File: prefs_ruler.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
def paint(self): w, h = self.get_size() fmt = cairo.FORMAT_RGB24 self.surface = cairo.ImageSurface(fmt, w, h) self.ctx = cairo.Context(self.surface) self.ctx.set_matrix(cairo.Matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)) self.ctx.set_source_rgb(*self.prefs.bg_btn.get_value()) self.ctx.paint() self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_line_width(1.0) self.ctx.set_dash([]) self.ctx.set_source_rgb(*self.prefs.fg_btn.get_value()) self.ctx.move_to(0, h) self.ctx.line_to(w, h) self.ctx.stroke() small_l = self.prefs.ruler_small_tick.get_value() for item in SMALL_TICKS: self.ctx.move_to(item, h - small_l) self.ctx.line_to(item, h - 1) large_l = self.prefs.ruler_large_tick.get_value() for pos, txt in TEXT_TICKS: self.ctx.move_to(pos, h - large_l) self.ctx.line_to(pos, h - 1) self.ctx.stroke() vshift = self.prefs.ruler_text_vshift.get_value() hshift = self.prefs.ruler_text_hshift.get_value() for pos, txt in TEXT_TICKS: for character in txt: data = self.font[character] position = int(pos) + hshift self.ctx.set_source_surface(data[1], position, vshift) self.ctx.paint() pos += data[0] self.draw_surface(self.surface)
Example #11
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 #12
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 5 votes |
def cdc_set_ctx(self, ctx, color=CAIRO_BLACK, dash=None): dash = dash or [] ctx.set_antialias(cairo.ANTIALIAS_NONE) ctx.set_line_width(1.0) ctx.set_dash(dash) ctx.set_source_rgba(*color)
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
Source File: renderer.py From sk1-wx with GNU General Public License v3.0 | 4 votes |
def render_grid(self): methods = self.presenter.methods grid_layer = methods.get_grid_layer() if not methods.is_layer_visible(grid_layer): return self.ctx.set_matrix(self.direct_matrix) self.ctx.set_antialias(cairo.ANTIALIAS_NONE) self.ctx.set_source_rgba(*grid_layer.color) self.ctx.set_line_width(1.0) self.ctx.set_dash(()) x, y, gdx, gdy = grid_layer.grid x0, y0, dx, dy, sx, sy = self.calc_grid(x, y, gdx, gdy) i = pos = 0 nul_i = round((x0 - sx) / dx) while pos < self.width: pos = sx + i * dx i += 1 self.ctx.move_to(pos, 0) self.ctx.line_to(pos, self.height) self.ctx.stroke() if dx == gdx * self.canvas.zoom and not (i - nul_i - 1) % 5: self.ctx.move_to(pos, 0) self.ctx.line_to(pos, self.height) self.ctx.stroke() i = pos = 0 nul_i = round((y0 - sy) / dy) while pos < self.height: pos = sy + i * dy i += 1 self.ctx.move_to(0, pos) self.ctx.line_to(self.width, pos) self.ctx.stroke() if dy == gdy * self.canvas.zoom and not (i - nul_i - 1) % 5: self.ctx.move_to(0, pos) self.ctx.line_to(self.width, pos) self.ctx.stroke() self.ctx.set_antialias(cairo.ANTIALIAS_DEFAULT) # ------MARKER RENDERING