-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Artist refactoring #1175
Artist refactoring #1175
Changes from 43 commits
9f51daf
7b5189a
113d8e5
edf81f5
9526b7b
ebf3fe0
1dbb918
881f3e8
d9bea85
e5c880e
529dc65
ebb4dd8
9bd1190
e373482
25236fe
062e85d
956e0e6
393bee0
e34ac07
4916f90
05b9db5
d3d7210
3879e2b
9ed1aa7
56dc846
a992fe6
6e4cc94
977b252
ee7602b
bb48185
9519f94
b3b1abc
a3ac99a
8b268fb
1db8dcf
6581ca4
7984648
54b9b35
0ffbf0a
80672b0
1a93263
6c0ee02
02ecda4
002dd45
adb0adf
e52a9bb
66f85d1
44ff68c
266b1fb
39c351e
685e3d5
7cf077d
fab631a
c6132d7
08e61fd
dce464e
21ec06b
ce73710
2419428
8bbfdd2
11f13f5
6caba8a
5fe516f
2bb415b
31e661d
3a6aa51
c304994
2cd05fa
7491e06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,3 +143,5 @@ src/compas_ghpython/components/**/*.ghuser | |
dev | ||
|
||
NOTES | ||
|
||
src/compas_blender/conversions/__temp/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Box | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
box = Box.from_corner_corner_height([0, 0, 0], [1, 1, 0], 3) | ||
|
||
artist = Artist(box, layer='Test::Child') | ||
artist.draw(color=(0.0, 1.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Capsule | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
capsule = Capsule(radius=1.0, height=7.0) | ||
|
||
artist = Artist(capsule) | ||
artist.draw(color=(1.0, 0.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Circle | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
circle = Circle(radius=3.0) | ||
|
||
artist = Artist(circle) | ||
artist.draw(color=(0.0, 0.0, 1.0), show_point=True, show_normal=True) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Cone | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
cone = Cone(radius=1.0, height=7.0) | ||
|
||
artist = Artist(cone) | ||
artist.draw(color=(1.0, 0.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from compas.geometry import NurbsCurve | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
curve = NurbsCurve.from_points([[0, 0, 0], [3, 3, 6], [6, -3, -3], [9, 0, 0]]) | ||
|
||
artist = Artist(curve) | ||
artist.color = (0.0, 1.0, 0.0) | ||
artist.draw() | ||
|
||
Artist.redraw() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Cylinder | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
cylinder = Cylinder(radius=1.0, height=7.0) | ||
|
||
artist = Artist(cylinder) | ||
artist.draw(color=(1.0, 0.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from compas.geometry import Frame | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
frame = Frame.worldXY() | ||
artist = Artist(frame) | ||
artist.draw() | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from math import pi | ||
from compas.geometry import Rotation, Scale | ||
from compas.geometry import Line | ||
from compas.artists import Artist | ||
from compas.colors import Color | ||
|
||
Artist.clear() | ||
|
||
line = Line([0, 0, 0], [3, 0, 0]) | ||
artist = Artist(line) | ||
# artist.color = (1.0, 0.0, 0.0) | ||
|
||
step = pi / 10.0 | ||
rotation = Rotation.from_axis_and_angle([0, 0, 1], angle=step) | ||
|
||
for i in range(11): | ||
artist.draw(color=Color.from_i(i / 10)) | ||
line.transform(rotation) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||
from compas.datastructures import Mesh | ||||
from compas.artists import Artist | ||||
from compas.colors import Color | ||||
|
||||
mesh = Mesh.from_meshgrid(10, 10) | ||||
|
||||
Artist.clear() | ||||
|
||||
artist = Artist(mesh) | ||||
artist.draw_vertices() | ||||
artist.draw_edges() | ||||
artist.draw_faces(color={face: Color.pink() for face in mesh.face_sample(size=17)}) | ||||
#artist.draw_vertexnormals() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
delete? |
||||
artist.draw_facenormals() | ||||
|
||||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from compas.geometry import Pointcloud | ||
from compas.datastructures import Network | ||
from compas.artists import Artist | ||
from compas.colors import Color | ||
|
||
network = Network.from_pointcloud(Pointcloud.from_bounds(8, 5, 3, 53)) | ||
|
||
node = network.node_sample(size=1)[0] | ||
nbrs = network.neighbors(node) | ||
edges = network.connected_edges(node) | ||
|
||
Artist.clear() | ||
|
||
artist = Artist(network) | ||
artist.draw( | ||
nodecolor={n: Color.pink() for n in [node] + nbrs}, | ||
edgecolor={e: Color.pink() for e in edges}, | ||
nodetext='index' | ||
) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||
import compas_rhino | ||||
|
||||
from compas.geometry import Point | ||||
from compas.artists import Artist | ||||
from compas.colors import Color | ||||
|
||||
compas_rhino.clear() | ||||
|
||||
point = Point(0, 0, 0) | ||||
artist = Artist(point) | ||||
# artist.color = (0.0, 1.0, 0.0) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
delete? or uncomment? |
||||
|
||||
for i in range(11): | ||||
point.x = i | ||||
artist.draw(color=Color.from_i(i / 10)) | ||||
|
||||
compas_rhino.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from compas.geometry import Polygon | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
polygon = Polygon.from_sides_and_radius_xy(8, 7.0) | ||
|
||
artist = Artist(polygon) | ||
artist.color = (0.0, 1.0, 0.0) | ||
|
||
artist.draw(show_points=True, show_edges=True) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from compas.geometry import Polyhedron | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
polyhedron = Polyhedron.from_platonicsolid(f=8) | ||
artist = Artist(polyhedron) | ||
artist.draw() | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from random import randrange | ||
from compas.geometry import Polyline | ||
from compas.artists import Artist | ||
from compas.colors import Color | ||
|
||
Artist.clear() | ||
|
||
polyline = Polyline([[0, 0, 0]]) | ||
|
||
for i, r in enumerate([randrange(1, 20) for _ in range(10)]): | ||
if i % 2 == 0: | ||
polyline.append([r, polyline.points[-1].y, 0]) | ||
else: | ||
polyline.append([polyline.points[-1].x, r, 0]) | ||
|
||
artist = Artist(polyline) | ||
artist.color = (0.0, 0.0, 1.0) | ||
artist.draw() | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Sphere | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
sphere = Sphere(radius=1.0) | ||
|
||
artist = Artist(sphere) | ||
artist.draw(color=(1.0, 0.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from compas.geometry import Torus | ||
from compas.artists import Artist | ||
|
||
Artist.clear() | ||
|
||
torus = Torus(radius_axis=7.0, radius_pipe=2.0) | ||
|
||
artist = Artist(torus) | ||
artist.draw(color=(1.0, 0.0, 0.0)) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from math import pi | ||
from compas.geometry import Vector | ||
from compas.geometry import Rotation | ||
from compas.artists import Artist | ||
from compas.colors import Color | ||
|
||
Artist.clear() | ||
|
||
vector = Vector(1, 0, 0) | ||
artist = Artist(vector) | ||
# artist.color = (0.0, 1.0, 0.0) | ||
|
||
# for i in range(11): | ||
# artist.draw( | ||
# color=Color.from_i(i / 10), | ||
# point=[i, 0, 0], | ||
# show_point=True | ||
# ) | ||
|
||
Comment on lines
+11
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, delete or uncomment? |
||
step = pi / 10.0 | ||
|
||
for i in range(11): | ||
artist.draw(color=Color.from_i(i / 10)) | ||
|
||
rotation = Rotation.from_axis_and_angle([0, 0, 1], angle=step) | ||
vector.transform(rotation) | ||
|
||
Artist.redraw() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from compas.datastructures import VolMesh | ||
from compas.artists import Artist | ||
from compas.colors import Color | ||
|
||
mesh = VolMesh.from_meshgrid(dx=10, nx=10) | ||
|
||
Artist.clear() | ||
|
||
artist = Artist(mesh) | ||
artist.draw_cells(color={cell: Color.pink() for cell in mesh.cell_sample(size=83)}) | ||
|
||
Artist.redraw() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️