Skip to content

Instantly share code, notes, and snippets.

@eriknw
Last active October 1, 2023 01:05
Show Gist options
  • Save eriknw/10b20fb5c3b137ed84e5d30b00a9a788 to your computer and use it in GitHub Desktop.
Save eriknw/10b20fb5c3b137ed84e5d30b00a9a788 to your computer and use it in GitHub Desktop.
experimenting with python-graphblas logo
# It is nice to experiment in a Jupyter Notebook
import numpy as np
import scipy as sp
import drawsvg as draw
gcube = np.array([
[-1, 1, -1],
[-1, 1, 1],
[1, 1, 1],
[-1, -1, 1],
[1, -1, 1],
[1, 0, 1],
[0, 0, 1],
])
gcube_major = gcube[:5] # Big circles
gcube_minor = gcube[5:] # Small circles
lines = np.array([
[gcube[1], gcube[0]],
[gcube[1], gcube[2]],
[gcube[1], gcube[3]],
[gcube[3], gcube[4]],
[gcube[4], gcube[5]],
[gcube[5], gcube[6]],
])
angles = [
180, # Don't modify this
30, # How much of the "left face" to see
22.5, # How much of the "top face" to see
]
R = sp.spatial.transform.Rotation.from_euler("ZYX", angles, degrees=True).as_matrix()
d = draw.Drawing(200, 200, origin='center')
d.append(draw.Rectangle(-100, -100, 200, 200, stroke="black", fill="white")) # Add a border to see boundaries (for testing)
# d.append(draw.Rectangle(-100, -100, 200, 200, stroke="black", fill="black")) # Uncomment to check dark mode
# Similar to, but different than, networkx blue and orange
blue = "#208BB4"
orange = "#F87A2D"
scale = 40
dx = 0
dy = 0
for (x0, y0, z0), (x1, y1, z1) in ((lines @ R)*scale).tolist():
# white border around lines
x0 = -x0 ; x1 = -x1 # Just live with this
d.append(draw.Line(x0 + dx, y0 + dy, x1 + dx, y1 + dy, stroke="white", stroke_width=16))
for (x0, y0, z0), (x1, y1, z1) in ((lines @ R)*scale).tolist():
x0 = -x0 ; x1 = -x1
d.append(draw.Line(x0 + dx, y0 + dy, x1 + dx, y1 + dy, stroke=orange, stroke_width=8))
for x, y, z in ((gcube_major @ R)*scale).tolist():
x = -x
d.append(draw.Circle(x + dx, y + dy, 16, fill=blue, stroke="white", stroke_width=4))
for x, y, z in ((gcube_minor @ R)*scale).tolist():
x = -x
d.append(draw.Circle(x + dx, y + dy, 8, fill=blue, stroke="white", stroke_width=4))
d.append(draw.Text("[", x=-85, y=50, font_size=200, text_anchor="middle", font_family="Courier New", fill="#4d4d4d"))
d.append(draw.Text("]", x=85, y=50, font_size=200, text_anchor="middle", font_family="Courier New", fill="#4d4d4d"))
d.save_svg('python_graphblas_logo0.svg')
d # To view in a Jupyter Notebook
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="200" height="200" viewBox="-100.0 -100.0 200 200">
<defs>
</defs>
<path d="M-14.641016151377546,-16.044969691726 L-54.64101615137754,-42.558055614573334" stroke="white" stroke-width="16" />
<path d="M-14.641016151377546,-16.044969691726 L54.641016151377535,-31.352306986329594" stroke="white" stroke-width="16" />
<path d="M-14.641016151377546,-16.044969691726 L-14.641016151377537,57.86539290917693" stroke="white" stroke-width="16" />
<path d="M-14.641016151377537,57.86539290917693 L54.64101615137754,42.558055614573334" stroke="white" stroke-width="16" />
<path d="M54.64101615137754,42.558055614573334 L54.641016151377535,5.602874314121871" stroke="white" stroke-width="16" />
<path d="M54.641016151377535,5.602874314121871 L19.999999999999996,13.25654296142367" stroke="white" stroke-width="16" />
<path d="M-14.641016151377546,-16.044969691726 L-54.64101615137754,-42.558055614573334" stroke="#F87A2D" stroke-width="8" />
<path d="M-14.641016151377546,-16.044969691726 L54.641016151377535,-31.352306986329594" stroke="#F87A2D" stroke-width="8" />
<path d="M-14.641016151377546,-16.044969691726 L-14.641016151377537,57.86539290917693" stroke="#F87A2D" stroke-width="8" />
<path d="M-14.641016151377537,57.86539290917693 L54.64101615137754,42.558055614573334" stroke="#F87A2D" stroke-width="8" />
<path d="M54.64101615137754,42.558055614573334 L54.641016151377535,5.602874314121871" stroke="#F87A2D" stroke-width="8" />
<path d="M54.641016151377535,5.602874314121871 L19.999999999999996,13.25654296142367" stroke="#F87A2D" stroke-width="8" />
<circle cx="-54.64101615137754" cy="-42.558055614573334" r="16" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="-14.641016151377546" cy="-16.044969691726" r="16" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="54.641016151377535" cy="-31.352306986329594" r="16" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="-14.641016151377537" cy="57.86539290917693" r="16" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="54.64101615137754" cy="42.558055614573334" r="16" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="54.641016151377535" cy="5.602874314121871" r="8" fill="#208BB4" stroke="white" stroke-width="4" />
<circle cx="19.999999999999996" cy="13.25654296142367" r="8" fill="#208BB4" stroke="white" stroke-width="4" />
<text x="-85" y="50" font-size="200" text-anchor="middle" font-family="Courier New" fill="#4d4d4d">[</text>
<text x="85" y="50" font-size="200" text-anchor="middle" font-family="Courier New" fill="#4d4d4d">]</text>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment