Skip to content

Commit

Permalink
rotation works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lingruiluo committed Jul 13, 2020
1 parent efba6c7 commit ddfc32f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions jp_doodle/svg_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ def rect(self, x, y, w, h, color, degrees = None, lineWidth=1, fill=True, **othe
# svg rect element does not support negative coordinates
if degrees:
atts['transform'] = "rotate(%s, %s, %s)" %(-degrees, x, y)
else:
atts['x'] = x
atts['y'] = y-h
atts['x'] = x
atts['y'] = y-h
style = ""
if lineWidth:
style += "stroke-width:" + str(lineWidth)
Expand Down
10 changes: 5 additions & 5 deletions notebooks/misc/svg_tests/rect test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "88250ecbd820440399d3a90c5cf52a03",
"model_id": "e1b19d8358734e25a87b19aba5fc2896",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -59,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -69,9 +69,9 @@
"<svg viewBox=\"0 0 320 220\" xmlns=\"http://www.w3.org/2000/svg\">\n",
" <g transform=\"scale(1.7390438239897745 1.7390438239897745) translate(76.51333851480325 39.2403876506104)\">\n",
"\t<rect width=\"50\" height=\"30\" stroke=\"green\" style=\"stroke-width:1\" fill=\"green\" x=\"0\" y=\"18.02552486507885\" />\n",
"\t<rect width=\"40\" height=\"90\" stroke=\"#7DD\" style=\"stroke-width:5\" fill=\"transparent\" transform=\"rotate(-33, 0, 68.02552486507885)\" />\n",
"\t<rect width=\"40\" height=\"90\" stroke=\"#7DD\" style=\"stroke-width:5\" fill=\"transparent\" transform=\"rotate(-33, 0, 68.02552486507885)\" x=\"0\" y=\"-21.97447513492115\" />\n",
"\t<rect width=\"100\" height=\"40\" stroke=\"rgba(2,22,222,0.5)\" style=\"stroke-width:10\" fill=\"transparent\" x=\"-20\" y=\"8.02552486507885\" />\n",
"\t<rect width=\"30\" height=\"50\" stroke=\"rgba(200,150,50,0.8)\" style=\"stroke-width:1\" fill=\"rgba(200,150,50,0.8)\" transform=\"rotate(10, 30, 78.02552486507885)\" />\n",
"\t<rect width=\"30\" height=\"50\" stroke=\"rgba(200,150,50,0.8)\" style=\"stroke-width:1\" fill=\"rgba(200,150,50,0.8)\" transform=\"rotate(10, 30, 78.02552486507885)\" x=\"30\" y=\"28.02552486507885\" />\n",
"\t</g>\n",
"</svg>\n"
],
Expand Down

0 comments on commit ddfc32f

Please sign in to comment.