Created
February 26, 2020 23:09
-
-
Save stuaxo/2d9629652b5125cc58959182822dd329 to your computer and use it in GitHub Desktop.
Attempting to repro a bug in shoebot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# packages used\n", | |
"# !pip3 install display-xml --user\n", | |
"# !pip3 install cairo_jupyter" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/svg+xml": [ | |
"<svg height=\"100pt\" version=\"1.1\" viewBox=\"0 0 100 100\" width=\"100pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n", | |
"<defs>\n", | |
"<g clip-path=\"url(#clip1)\" id=\"surface179\">\n", | |
"<rect height=\"16777215\" style=\"opacity:1;stroke:none;fill:rgb(0,0,0);\" width=\"16777215\"/>\n", | |
"<path d=\"M 0.398438 0.398438 L 51 0.398438 L 51 51 L 0.398438 51 Z M 0.398438 0.398438 \" style=\" stroke:none;fill-rule:nonzero;fill:rgb(100%,20%,20%);fill-opacity:0.6;\"/>\n", | |
"</g>\n", | |
"</defs>\n", | |
"<g id=\"surface176\">\n", | |
"<use transform=\"matrix(1,0,0,1,10,10)\" xlink:href=\"#surface179\"/>\n", | |
"</g>\n", | |
"</svg>" | |
], | |
"text/plain": [ | |
"<IPython.core.display.SVG object>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
" <div class=ab9cde0e8-cca9-4963-9962-3e1b991200d8> \n", | |
" <style>\n", | |
" div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .hll { background-color: #ffffcc }\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .c { color: #aaaaaa; font-style: italic } /* Comment */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .err { color: #FF0000; background-color: #FFAAAA } /* Error */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .k { color: #0000aa } /* Keyword */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .ch { color: #aaaaaa; font-style: italic } /* Comment.Hashbang */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .cm { color: #aaaaaa; font-style: italic } /* Comment.Multiline */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .cp { color: #4c8317 } /* Comment.Preproc */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .cpf { color: #aaaaaa; font-style: italic } /* Comment.PreprocFile */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .c1 { color: #aaaaaa; font-style: italic } /* Comment.Single */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .cs { color: #0000aa; font-style: italic } /* Comment.Special */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gd { color: #aa0000 } /* Generic.Deleted */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .ge { font-style: italic } /* Generic.Emph */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gr { color: #aa0000 } /* Generic.Error */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gi { color: #00aa00 } /* Generic.Inserted */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .go { color: #888888 } /* Generic.Output */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gp { color: #555555 } /* Generic.Prompt */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gs { font-weight: bold } /* Generic.Strong */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .gt { color: #aa0000 } /* Generic.Traceback */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kc { color: #0000aa } /* Keyword.Constant */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kd { color: #0000aa } /* Keyword.Declaration */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kn { color: #0000aa } /* Keyword.Namespace */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kp { color: #0000aa } /* Keyword.Pseudo */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kr { color: #0000aa } /* Keyword.Reserved */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .kt { color: #00aaaa } /* Keyword.Type */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .m { color: #009999 } /* Literal.Number */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .s { color: #aa5500 } /* Literal.String */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .na { color: #1e90ff } /* Name.Attribute */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nb { color: #00aaaa } /* Name.Builtin */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nc { color: #00aa00; text-decoration: underline } /* Name.Class */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .no { color: #aa0000 } /* Name.Constant */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nd { color: #888888 } /* Name.Decorator */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .ni { color: #880000; font-weight: bold } /* Name.Entity */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nf { color: #00aa00 } /* Name.Function */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nn { color: #00aaaa; text-decoration: underline } /* Name.Namespace */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nt { color: #1e90ff; font-weight: bold } /* Name.Tag */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .nv { color: #aa0000 } /* Name.Variable */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .ow { color: #0000aa } /* Operator.Word */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .w { color: #bbbbbb } /* Text.Whitespace */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .mb { color: #009999 } /* Literal.Number.Bin */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .mf { color: #009999 } /* Literal.Number.Float */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .mh { color: #009999 } /* Literal.Number.Hex */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .mi { color: #009999 } /* Literal.Number.Integer */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .mo { color: #009999 } /* Literal.Number.Oct */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sa { color: #aa5500 } /* Literal.String.Affix */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sb { color: #aa5500 } /* Literal.String.Backtick */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sc { color: #aa5500 } /* Literal.String.Char */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .dl { color: #aa5500 } /* Literal.String.Delimiter */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sd { color: #aa5500 } /* Literal.String.Doc */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .s2 { color: #aa5500 } /* Literal.String.Double */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .se { color: #aa5500 } /* Literal.String.Escape */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sh { color: #aa5500 } /* Literal.String.Heredoc */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .si { color: #aa5500 } /* Literal.String.Interpol */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sx { color: #aa5500 } /* Literal.String.Other */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .sr { color: #009999 } /* Literal.String.Regex */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .s1 { color: #aa5500 } /* Literal.String.Single */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .ss { color: #0000aa } /* Literal.String.Symbol */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .bp { color: #00aaaa } /* Name.Builtin.Pseudo */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .fm { color: #00aa00 } /* Name.Function.Magic */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .vc { color: #aa0000 } /* Name.Variable.Class */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .vg { color: #aa0000 } /* Name.Variable.Global */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .vi { color: #aa0000 } /* Name.Variable.Instance */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .vm { color: #aa0000 } /* Name.Variable.Magic */\n", | |
"div.ab9cde0e8-cca9-4963-9962-3e1b991200d8 .il { color: #009999 } /* Literal.Number.Integer.Long */\n", | |
" </style>\n", | |
" <div class=\"highlight\"><pre><span></span><span class=\"nt\"><svg</span> <span class=\"na\">xmlns=</span><span class=\"s\">"http://www.w3.org/2000/svg"</span> <span class=\"na\">xmlns:xlink=</span><span class=\"s\">"http://www.w3.org/1999/xlink"</span> <span class=\"na\">width=</span><span class=\"s\">"100pt"</span> <span class=\"na\">height=</span><span class=\"s\">"100pt"</span> <span class=\"na\">viewBox=</span><span class=\"s\">"0 0 100 100"</span> <span class=\"na\">version=</span><span class=\"s\">"1.1"</span><span class=\"nt\">></span>\n", | |
" <span class=\"nt\"><defs></span>\n", | |
" <span class=\"nt\"><g</span> <span class=\"na\">id=</span><span class=\"s\">"surface179"</span> <span class=\"na\">clip-path=</span><span class=\"s\">"url(#clip1)"</span><span class=\"nt\">></span>\n", | |
" <span class=\"nt\"><rect</span> <span class=\"na\">width=</span><span class=\"s\">"16777215"</span> <span class=\"na\">height=</span><span class=\"s\">"16777215"</span> <span class=\"na\">style=</span><span class=\"s\">"opacity:1;stroke:none;fill:rgb(0,0,0);"</span><span class=\"nt\">/></span>\n", | |
" <span class=\"nt\"><path</span> <span class=\"na\">style=</span><span class=\"s\">" stroke:none;fill-rule:nonzero;fill:rgb(100%,20%,20%);fill-opacity:0.6;"</span> <span class=\"na\">d=</span><span class=\"s\">"M 0.398438 0.398438 L 51 0.398438 L 51 51 L 0.398438 51 Z M 0.398438 0.398438 "</span><span class=\"nt\">/></span>\n", | |
" <span class=\"nt\"></g></span>\n", | |
" <span class=\"nt\"></defs></span>\n", | |
" <span class=\"nt\"><g</span> <span class=\"na\">id=</span><span class=\"s\">"surface176"</span><span class=\"nt\">></span>\n", | |
" <span class=\"nt\"><use</span> <span class=\"na\">xlink:href=</span><span class=\"s\">"#surface179"</span> <span class=\"na\">transform=</span><span class=\"s\">"matrix(1,0,0,1,10,10)"</span><span class=\"nt\">/></span>\n", | |
" <span class=\"nt\"></g></span>\n", | |
"<span class=\"nt\"></svg></span>\n", | |
"</pre></div>\n", | |
"\n", | |
" </div>\n", | |
" " | |
], | |
"text/plain": [ | |
"<display_xml.xml.XML at 0x7fae178b2d90>" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%reload_ext cairo_jupyter\n", | |
"\n", | |
"# RecordingSurface info from copied from https://stackoverflow.com/questions/29359534/transferring-all-of-a-cairo-recordingsurface-to-svg\n", | |
"\n", | |
"import cairo\n", | |
"\n", | |
"from io import BytesIO\n", | |
"from IPython.display import SVG, display\n", | |
"\n", | |
"rec_surf = cairo.RecordingSurface(cairo.CONTENT_COLOR, None)\n", | |
"\n", | |
"context = cairo.Context(rec_surf)\n", | |
"context.set_source_rgba(1, 0.2, 0.2, 0.6)\n", | |
"context.rectangle(0.4, 0.4, 50.6, 50.6)\n", | |
"context.fill()\n", | |
"\n", | |
"svgio = BytesIO()\n", | |
"\n", | |
"# can't seem to do the following in a with statement:\n", | |
"final_surf = cairo.SVGSurface(svgio, 100, 100)\n", | |
"final_ctx = cairo.Context(final_surf)\n", | |
"final_ctx.set_source_surface(rec_surf, 10, 10)\n", | |
"final_ctx.paint()\n", | |
"final_surf.finish()\n", | |
"\n", | |
"display(SVG(data=svgio.getvalue()))\n", | |
"XML(svgio.getvalue(), style='autumn')" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment