In [1]:
from calysto.graphics import *
In [1]:
from PIL import Image
In [3]:
image = Image.new("RGB", (256, 128))
In [4]:
image
Out[4]:
In [5]:
str(image)
Out[5]:
'<PIL.Image.Image image mode=RGB size=256x128 at 0x7F15097FFE10>'
In [2]:
canvas = Canvas()
In [3]:
canvas
Out[3]:
In [4]:
import cairosvg
In [6]:
from cairosvg.surface import helpers
In [9]:
canvas.viewbox
Out[9]:
<bound method Canvas.viewbox of <Canvas (300, 300)>>
In [10]:
transform = cairosvg.surface.transform()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-82bad57c7970> in <module>()
----> 1 transform = cairosvg.surface.transform()

TypeError: transform() missing 2 required positional arguments: 'surface' and 'string'
In [13]:
surface = canvas._render()
In [14]:
canvas
Out[14]:
In [4]:
rect = Rectangle((10,10), (30, 40))
In [5]:
rect.draw(canvas)
Out[5]:
In [17]:
rect
Out[17]:
<Rectangle [10, 10],[30, 40]>
In [18]:
surface
Out[18]:
<svgwrite.drawing.Drawing at 0x7fa7bdf21908>
In [19]:
rect._add(surface)
In [20]:
surface
Out[20]:
<svgwrite.drawing.Drawing at 0x7fa7bdf21908>
In [21]:
surface.add
Out[21]:
<bound method Drawing.add of <svgwrite.drawing.Drawing object at 0x7fa7bdf21908>>
In [26]:
surface.context
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-26-d6c9b7c4772a> in <module>()
----> 1 surface.context

/usr/lib/python3.4/site-packages/svgwrite/elementfactory.py in __getattr__(self, name)
     71             return ElementBuilder(factoryelements[name], self)
     72         else:
---> 73             raise AttributeError("'%s' has no attribute '%s'" % (self.__class__.__name__, name))

AttributeError: 'Drawing' has no attribute 'context'
In [27]:
dir(surface)
Out[27]:
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattr__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_parameter',
 '_stylesheets',
 'add',
 'add_stylesheet',
 'attribs',
 'clip_rect',
 'copy',
 'dasharray',
 'debug',
 'defs',
 'elementname',
 'elements',
 'filename',
 'fill',
 'fit',
 'get_funciri',
 'get_id',
 'get_iri',
 'get_xml',
 'next_id',
 'profile',
 'save',
 'saveas',
 'set_desc',
 'set_metadata',
 'set_parameter',
 'stretch',
 'stroke',
 'tostring',
 'update',
 'validator',
 'value_to_string',
 'version',
 'viewbox',
 'write']
In [28]:
text = Text("Hello", (10, 10), rotate=[45])
In [27]:
canvas.shapes.pop()
canvas
Out[27]:
In [29]:
text.draw(canvas)
Out[29]:
Hello