Skip to content

Commit

Permalink
Merge pull request #2 from cfe-lab/invert-y
Browse files Browse the repository at this point in the history
Addtional updates for drawsvg >2.0
  • Loading branch information
CBeelen authored Jun 12, 2023
2 parents ca2edf5 + 3b12043 commit a7f20f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions genetracks/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ def show(self, w=None, h=None):
if h is None:
h = self.h

d = draw.Drawing(self.w * xscale, h, origin=(0,0))
d = draw.Drawing(self.w * xscale, h, origin=(0,0), context=draw.Context(invert_y=True))
for y, element in self.elements:
d.append(element.draw(xscale=xscale, y=y-h))

# d.setRenderSize(w, h)
return d

def to_svg(self, path, w=None, h=None):
self.show(w=w, h=h).save_svg(path)
self.show(w=w, h=h).save_svg(path, context=draw.Context(invert_y=True))

def to_png(self, path, w=None, h=None):
self.show(w=w, h=h).save_png(path)
self.show(w=w, h=h).save_png(path, context=draw.Context(invert_y=True))


class Element:
Expand Down Expand Up @@ -174,7 +174,7 @@ def draw(self, x=None, y=0, xscale=1.0):

d = draw.Group(transform="translate({} {})".format(x, y))
d.append(draw.Text(self.text, self.font_size, self.w,
(self.font_size/2 + offset), font_family='monospace', center=True))
offset, font_family='monospace', text_anchor='middle'))
return d


Expand Down
2 changes: 1 addition & 1 deletion genetracks/plasmid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, length, regions=[], size=400, color='lightgrey'):
self.color = color

def show(self):
d = draw.Drawing(1.4, 1.4, origin='center')
d = draw.Drawing(1.4, 1.4, origin='center', context=draw.Context(invert_y=True))

d.append(draw.Circle(0, 0, 0.5, stroke_width='0.005', stroke=self.color,
fill_opacity='0.0'))
Expand Down

0 comments on commit a7f20f6

Please sign in to comment.