Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2018-09-06 15:40:20 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-09-06 16:19:19 +0300
commit25d49a3436164c3cf95c47ab77ffa3e0bc80ce67 (patch)
tree53b4466fdd995607d8864baba88dca2f45f3fe42 /io_mesh_uv_layout/export_uv_eps.py
parent9ff1e5eca76413b0f178ead688e9cde1c1385e36 (diff)
Multi-Objects: UV_OT_export_layout (80%)
""" Apart from the 'export as PNG' all seems to be working ok. 'Export to PNG' also seems to work but doesn't look acceptable because the mesh wireframe modifier is used to draw UV wireframes (I was going to see if a curve object would be usable to draw wireframes). Something in setting the renderer up could also be wrong or missing. """ D3507 by @Al Note from reviewer: I can't get this addon to show in the menus. But the syntax seems correct, and it's pep8 friendly, so no harm in committing it so I can ask other devs to see why the addon is never registering here. Also, some changes I made include making it pep8 friendly and replace: ['foo', 'bar'] with {'foo', 'bar'}.
Diffstat (limited to 'io_mesh_uv_layout/export_uv_eps.py')
-rw-r--r--io_mesh_uv_layout/export_uv_eps.py117
1 files changed, 63 insertions, 54 deletions
diff --git a/io_mesh_uv_layout/export_uv_eps.py b/io_mesh_uv_layout/export_uv_eps.py
index a15dc266..d00e998a 100644
--- a/io_mesh_uv_layout/export_uv_eps.py
+++ b/io_mesh_uv_layout/export_uv_eps.py
@@ -21,66 +21,75 @@
import bpy
-def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
- fw("%!PS-Adobe-3.0 EPSF-3.0\n")
- fw("%%%%Creator: Blender %s\n" % bpy.app.version_string)
- fw("%%Pages: 1\n")
- fw("%%Orientation: Portrait\n")
- fw("%%%%BoundingBox: 0 0 %d %d\n" % (image_width, image_height))
- fw("%%%%HiResBoundingBox: 0.0 0.0 %.4f %.4f\n" %
- (image_width, image_height))
- fw("%%EndComments\n")
- fw("%%Page: 1 1\n")
- fw("0 0 translate\n")
- fw("1.0 1.0 scale\n")
- fw("0 0 0 setrgbcolor\n")
- fw("[] 0 setdash\n")
- fw("1 setlinewidth\n")
- fw("1 setlinejoin\n")
- fw("1 setlinecap\n")
+class Export_UV_EPS:
+ def begin(self, fw, image_size, opacity):
- polys = mesh.polygons
+ self.fw = fw
+ self.image_width = image_size[0]
+ self.image_height = image_size[1]
+ self.opacity = opacity
- if opacity > 0.0:
- for i, mat in enumerate(mesh.materials if mesh.materials else [None]):
- fw("/DRAW_%d {" % i)
- fw("gsave\n")
- if mat:
- color = tuple((1.0 - ((1.0 - c) * opacity))
- for c in mat.diffuse_color)
- else:
- color = 1.0, 1.0, 1.0
- fw("%.3g %.3g %.3g setrgbcolor\n" % color)
- fw("fill\n")
- fw("grestore\n")
- fw("0 setgray\n")
- fw("} def\n")
+ fw("%!PS-Adobe-3.0 EPSF-3.0\n")
+ fw("%%%%Creator: Blender %s\n" % bpy.app.version_string)
+ fw("%%Pages: 1\n")
+ fw("%%Orientation: Portrait\n")
+ fw("%%%%BoundingBox: 0 0 %d %d\n" % (self.image_width, self.image_height))
+ fw("%%%%HiResBoundingBox: 0.0 0.0 %.4f %.4f\n" %
+ (self.image_width, self.image_height))
+ fw("%%EndComments\n")
+ fw("%%Page: 1 1\n")
+ fw("0 0 translate\n")
+ fw("1.0 1.0 scale\n")
+ fw("0 0 0 setrgbcolor\n")
+ fw("[] 0 setdash\n")
+ fw("1 setlinewidth\n")
+ fw("1 setlinejoin\n")
+ fw("1 setlinecap\n")
- # fill
+ def build(self, mesh, face_iter_func):
+ polys = mesh.polygons
+
+ if self.opacity > 0.0:
+ for i, mat in enumerate(mesh.materials if mesh.materials else [None]):
+ self.fw("/DRAW_%d {" % i)
+ self.fw("gsave\n")
+ if mat:
+ color = tuple((1.0 - ((1.0 - c) * self.opacity))
+ for c in mat.diffuse_color)
+ else:
+ color = 1.0, 1.0, 1.0
+ self.fw("%.3g %.3g %.3g setrgbcolor\n" % color)
+ self.fw("fill\n")
+ self.fw("grestore\n")
+ self.fw("0 setgray\n")
+ self.fw("} def\n")
+
+ # fill
+ for i, uvs in face_iter_func():
+ self.fw("newpath\n")
+ for j, uv in enumerate(uvs):
+ uv_scale = (uv[0] * self.image_width, uv[1] * self.image_height)
+ if j == 0:
+ self.fw("%.5f %.5f moveto\n" % uv_scale)
+ else:
+ self.fw("%.5f %.5f lineto\n" % uv_scale)
+
+ self.fw("closepath\n")
+ self.fw("DRAW_%d\n" % polys[i].material_index)
+
+ # stroke only
for i, uvs in face_iter_func():
- fw("newpath\n")
+ self.fw("newpath\n")
for j, uv in enumerate(uvs):
- uv_scale = (uv[0] * image_width, uv[1] * image_height)
+ uv_scale = (uv[0] * self.image_width, uv[1] * self.image_height)
if j == 0:
- fw("%.5f %.5f moveto\n" % uv_scale)
+ self.fw("%.5f %.5f moveto\n" % uv_scale)
else:
- fw("%.5f %.5f lineto\n" % uv_scale)
-
- fw("closepath\n")
- fw("DRAW_%d\n" % polys[i].material_index)
-
- # stroke only
- for i, uvs in face_iter_func():
- fw("newpath\n")
- for j, uv in enumerate(uvs):
- uv_scale = (uv[0] * image_width, uv[1] * image_height)
- if j == 0:
- fw("%.5f %.5f moveto\n" % uv_scale)
- else:
- fw("%.5f %.5f lineto\n" % uv_scale)
+ self.fw("%.5f %.5f lineto\n" % uv_scale)
- fw("closepath\n")
- fw("stroke\n")
+ self.fw("closepath\n")
+ self.fw("stroke\n")
- fw("showpage\n")
- fw("%%EOF\n")
+ def end(self):
+ self.fw("showpage\n")
+ self.fw("%%EOF\n")