Skip to content

Commit

Permalink
Merge pull request #26 from jiangzhongshi/master
Browse files Browse the repository at this point in the history
Improve interface: forward kwargs to shading
  • Loading branch information
skoch9 authored Nov 24, 2020
2 parents dfae72e + 392b6fc commit d780cc5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions meshplot/Viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def __get_point_colors(self, v, c, sh):

return colors, v_color

def add_mesh(self, v, f, c=None, uv=None, n=None, shading={}, texture_data=None):
def add_mesh(self, v, f, c=None, uv=None, n=None, shading={}, texture_data=None, **kwargs):
shading.update(kwargs)
sh = self.__get_shading(shading)
mesh_obj = {}

Expand Down Expand Up @@ -278,7 +279,8 @@ def add_mesh(self, v, f, c=None, uv=None, n=None, shading={}, texture_data=None)
return self.__add_object(mesh_obj)


def add_lines(self, beginning, ending, shading={}, obj=None):
def add_lines(self, beginning, ending, shading={}, obj=None, **kwargs):
shading.update(kwargs)
if len(beginning.shape) == 1:
if len(beginning) == 2:
beginning = np.array([[beginning[0], beginning[1], 0]])
Expand All @@ -299,7 +301,8 @@ def add_lines(self, beginning, ending, shading={}, obj=None):
lines = lines.reshape((-1, 3))
return self.__add_line_geometry(lines, sh, obj)

def add_edges(self, vertices, edges, shading={}, obj=None):
def add_edges(self, vertices, edges, shading={}, obj=None, **kwargs):
shading.update(kwargs)
if vertices.shape[1] == 2:
vertices = np.append(
vertices, np.zeros([vertices.shape[0], 1]), 1)
Expand All @@ -312,7 +315,8 @@ def add_edges(self, vertices, edges, shading={}, obj=None):
cnt += 2
return self.__add_line_geometry(lines, sh, obj)

def add_points(self, points, c=None, shading={}, obj=None):
def add_points(self, points, c=None, shading={}, obj=None, **kwargs):
shading.update(kwargs)
if len(points.shape) == 1:
if len(points) == 2:
points = np.array([[points[0], points[1], 0]])
Expand Down Expand Up @@ -417,7 +421,8 @@ def update_object(self, oid=0, vertices=None, colors=None, faces=None):
# self.scene.exec_three_obj_method('update')


def add_text(self, text, shading={}):
def add_text(self, text, shading={}, **kwargs):
shading.update(kwargs)
sh = self.__get_shading(shading)
tt = p3s.TextTexture(string=text, color=sh["text_color"])
sm = p3s.SpriteMaterial(map=tt)
Expand Down
6 changes: 4 additions & 2 deletions meshplot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def to_html(self, imports=True, html_frame=True):

return s

def plot(v, f=None, c=None, uv=None, n=None, shading={}, plot=None, return_plot=True, filename="", texture_data=None):#, return_id=False):
def plot(v, f=None, c=None, uv=None, n=None, shading={}, plot=None, return_plot=True, filename="", texture_data=None, **kwargs):#, return_id=False):
shading.update(kwargs)
if not plot:
view = Viewer(shading)
else:
Expand All @@ -98,7 +99,8 @@ def plot(v, f=None, c=None, uv=None, n=None, shading={}, plot=None, return_plot=
if return_plot or rendertype == "WEBSITE":
return view

def subplot(v, f=None, c=None, uv=None, n=None, shading={}, s=[1, 1, 0], data=None, texture_data=None):
def subplot(v, f=None, c=None, uv=None, n=None, shading={}, s=[1, 1, 0], data=None, texture_data=None, **kwargs):
shading.update(kwargs)
shading["width"] = 400
shading["height"] = 400
view = Viewer(shading)
Expand Down

0 comments on commit d780cc5

Please sign in to comment.