Last active
October 1, 2023 01:05
-
-
Save eriknw/10b20fb5c3b137ed84e5d30b00a9a788 to your computer and use it in GitHub Desktop.
experimenting with python-graphblas logo
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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment