cairo

pyCairo: How to resize and position an image?

百般思念 提交于 2019-11-29 19:14:23
问题 Based on the question Create PDF with (resized) PNG images using Pycairo - rescaling Surface issue I have attempted to create code that rescales and places an image at a specific position, as shown in the code below (in this case, for example, the images should appear "over" the underlying rectangles). However, I cannot seem to get the image to appear at the correct location(s). I'd appreciate knowing what I must change, in order to both scale and position an image correctly. import cairo if

include cairo R on a mac

扶醉桌前 提交于 2019-11-29 18:07:22
问题 I'm trying to use 'Cairo' package in Rstudio, using the command install.packages('Cairo') and it goes through with no problem. I get this message- The downloaded binary packages are in /var/folders/xn/c1nj85gx62b89876s15sbv9h0000gn/T//RtmpK9JM0l/downloaded_packages The package appears in the packages list, but when I try to include the package using library(Cairo) or library('Cairo') I get this error mesage- Error : .onLoad failed in loadNamespace() for 'Cairo', details: call: dyn.load(file,

How do I render *parts* of a svg file?

牧云@^-^@ 提交于 2019-11-29 14:42:24
问题 I want to render parts of a svg file by name but for the life of me I cannot figure out how to do so (using python + gtk). Here's the svg file in question: http://david.bellot.free.fr/svg-cards/files/SVG-cards-2.0.1.tar.gz ( Update: this file no longer exists, but you can track it down at http://svg-cards.sourceforge.net/) On his site, David, says: You can draw a card either by rendering the file onto a pixmap and clipping each card manually or by using the card's name through a DOM interface

Simple C++ Graphics Library

戏子无情 提交于 2019-11-29 14:16:40
Any suggestions for a simple C++ library I can use to create an image to a specified size, with either a fixed rgb colour value or ideally supporting gradients. Needs to work on Windows and ideally but not required to work on OS X as well. I've found Cairo, but just wondered if there was anything else as it seems quite simple what I require. greyfade Cairo is an exceptional library for this task. If you're thinking it's overkill, I can reassure you that it most definitely is not a bloated or large library. Cairo is meant exactly for what you need it. Note that if you need the ability to set

Drawing in PyGobject (python3)

Deadly 提交于 2019-11-29 11:06:21
I'm trying to write simple graphic editor using PyGObject and python 3. I need to draw lines with different color and width using mouse. I found many examples like this but nothing more complex. How do I save drawn image between 'draw' events? Is there incremental way of drawing or do I have to redraw pane on each 'draw' event? I found out that I can save path but how can I save width and colors of drawn lines? Is there way create image outside 'draw' callback and only apply (draw) it inside callback? Here is what I have for now. #!/usr/bin/env python # -*- coding: utf-8 -*- from gi.repository

Can't install cairo with cabal on Windows - how to get pkg-config on win?

我的未来我决定 提交于 2019-11-29 07:22:01
Configuring cairo-0.12.0... setup.exe: The program pkg-config version >=0.9.0 is required but it could not be found. cabal: Error: some packages failed to install: cairo-0.12.0 failed during the configure step. The exception was: ExitFailure 1 so how can I get pkg-config on windows or how to install cairo then ? Do you have the cairo development files installed? Recall this isn't the same as having a cairo dll! See the Windows section of their download page for binaries . Also, you can run cabal install -v for more verbosity in the error (which you should post if you're still stuck). you need

rsvg with Python 3.2 on Ubuntu

∥☆過路亽.° 提交于 2019-11-29 07:14:33
I am trying to use rsvg in Python 3.2 but I keep getting an import error. I have installed all of the librsvg packages along with cairo. I cannot find anything online about what else to install to get it to work. I did hear that the rsvg module hasn't been updated since 2005 so is it just not compatible with Python 3.2, or is there something else I can try to install it? Alternatively, if rsvg does not work, does anyone have any suggestions for a simple way to display an SVG file through Python (basically just show the image)? EDIT: The error I get is: 'ImportError: No module named rsvg' This

How to draw any GTK widget on top of Cairo surface

末鹿安然 提交于 2019-11-29 06:11:30
I would like to save the looks of a GTK window, and all the buttons and other widgets it contains to a PNG or PDF file. Cairo supports drawing on such surfaces. Could I somehow ask a GTK widget to draw itself on Cairo surface? A code sample would be much appreciated, since I am a newcomer to both GTK and Cairo. Python is my language of choice. In C, you can put your buttons and widgets in a GtkOffscreenWindow using gtk_widget_reparent() and then use gtk_offscreen_window_get_pixbuf() to render it onto a GdkPixbuf , which you can then save to a file. Sorry I don't have any Python code, but I don

How do you install PyCairo (Cairo for Python) on Windows?

。_饼干妹妹 提交于 2019-11-29 03:09:11
I spent hours this afternoon trying to find a straightforward tutorial for installing PyCairo on Windows. The Cairo project itself does not maintain Windows binaries, they must be dowloaded elsehere (e.g. http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/ ). The process is also complicated further apparently by the fact that MSVC is apparently not a supported compiler for PyCairo (although the source patch is simple). See this bug report: https://www.libreoffice.org/bugzilla/show_bug.cgi?id=22940 Can anyone recommend a tutorial for installing PyCairo on Windows? You should try windows

Error with Python ctypes and librsvg

只谈情不闲聊 提交于 2019-11-28 12:33:03
I'm trying to wrap basic function of librsvg with ctypes for Python, but I'm getting a segfault. C: // pycairo excerpt typedef struct { PyObject_HEAD cairo_t *ctx; PyObject *base; /* base object used to create context, or NULL */ } PycairoContext; // librsvg excerpt RsvgHandle * rsvg_handle_new_from_file (const gchar * file_name, GError ** error); // ... gboolean rsvg_handle_render_cairo (RsvgHandle * handle, cairo_t * cr); Python ctypes: from ctypes import * from ctypes import util librsvg = cdll.LoadLibrary('/brew/lib/librsvg-2.2.dylib') libgobject = cdll.LoadLibrary('/brew/lib/libgobject-2