Initial commit of py/hexagram/icons.py
This commit is contained in:
parent
2f0334b8c5
commit
d410fa3eda
1 changed files with 30 additions and 0 deletions
30
py/hexagram/icons.py
Normal file
30
py/hexagram/icons.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import cairo
|
||||
import gi
|
||||
|
||||
gi.require_version('Rsvg', '2.0')
|
||||
|
||||
from gi.repository import Rsvg
|
||||
|
||||
def to_surface(path: str, width: float, height: float, style: str) -> cairo.Surface:
|
||||
surface = cairo.RecordingSurface(cairo.CONTENT_ALPHA,
|
||||
cairo.Rectangle(0, 0, width, height))
|
||||
|
||||
cr = cairo.Context(surface)
|
||||
|
||||
rect = Rsvg.Rectangle()
|
||||
rect.x = 0
|
||||
rect.y = 0
|
||||
rect.width = width
|
||||
rect.height = height
|
||||
|
||||
svg = Rsvg.Handle.new_from_file(path)
|
||||
svg.set_stylesheet(bytes(style, 'utf8'))
|
||||
svg.render_layer(cr, None, rect)
|
||||
|
||||
return surface
|
||||
|
||||
class ISO7000():
|
||||
__icons__ = dict()
|
||||
|
||||
def __init__(self):
|
||||
pass
|
Loading…
Add table
Reference in a new issue