Skip to content
Snippets Groups Projects
Commit 77774b1f authored by Campbell Barton's avatar Campbell Barton
Browse files

formatting edits only

parent e1c5b902
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8-80 compliant>
import bpy
......@@ -27,7 +27,8 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
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("%%%%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")
......@@ -45,7 +46,8 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fw("/DRAW_%d {" % i)
fw("gsave\n")
if mat:
color = tuple((1.0 - ((1.0 - c) * opacity)) for c in mat.diffuse_color)
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)
......
......@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8-80 compliant>
import bpy
......@@ -25,7 +25,9 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
filepath = fw.__self__.name
fw.__self__.close()
material_solids = [bpy.data.materials.new("uv_temp_solid") for i in range(max(1, len(mesh_source.materials)))]
material_solids = [bpy.data.materials.new("uv_temp_solid")
for i in range(max(1, len(mesh_source.materials)))]
material_wire = bpy.data.materials.new("uv_temp_wire")
scene = bpy.data.scenes.new("uv_temp")
......@@ -39,15 +41,21 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
faces_source = mesh_source.faces
# get unique UV's in case there are many overlapping which slow down filling.
# get unique UV's in case there are many overlapping
# which slow down filling.
face_hash_3 = set()
face_hash_4 = set()
for i, uv in face_iter_func():
material_index = faces_source[i].material_index
if len(uv) == 3:
face_hash_3.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], material_index))
face_hash_3.add((uv[0][0], uv[0][1],
uv[1][0], uv[1][1],
uv[2][0], uv[2][1], material_index))
else:
face_hash_4.add((uv[0][0], uv[0][1], uv[1][0], uv[1][1], uv[2][0], uv[2][1], uv[3][0], uv[3][1], material_index))
face_hash_4.add((uv[0][0], uv[0][1],
uv[1][0], uv[1][1],
uv[2][0], uv[2][1],
uv[3][0], uv[3][1], material_index))
# now set the faces coords and locations
# build mesh data
......@@ -58,13 +66,20 @@ def write(fw, mesh_source, image_width, image_height, opacity, face_iter_func):
current_vert = 0
for face_data in face_hash_3:
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0])
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, 0])
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0,
face_data[2], face_data[3], 0.0,
face_data[4], face_data[5], 0.0])
mesh_new_face_vertices.extend([current_vert, current_vert + 1,
current_vert + 2, 0])
mesh_new_materials.append(face_data[6])
current_vert += 3
for face_data in face_hash_4:
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0, face_data[2], face_data[3], 0.0, face_data[4], face_data[5], 0.0, face_data[6], face_data[7], 0.0])
mesh_new_face_vertices.extend([current_vert, current_vert + 1, current_vert + 2, current_vert + 3])
mesh_new_vertices.extend([face_data[0], face_data[1], 0.0,
face_data[2], face_data[3], 0.0,
face_data[4], face_data[5], 0.0,
face_data[6], face_data[7], 0.0])
mesh_new_face_vertices.extend([current_vert, current_vert + 1,
current_vert + 2, current_vert + 3])
mesh_new_materials.append(face_data[8])
current_vert += 4
......
......@@ -16,7 +16,7 @@
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
# <pep8-80 compliant>
import bpy
......@@ -29,9 +29,11 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fw('<?xml version="1.0" standalone="no"?>\n')
fw('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" \n')
fw(' "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')
fw('<svg width="%dpx" height="%dpx" viewBox="0px 0px %dpx %dpx"\n' % (image_width, image_height, image_width, image_height))
fw('<svg width="%dpx" height="%dpx" viewBox="0px 0px %dpx %dpx"\n' %
(image_width, image_height, image_width, image_height))
fw(' xmlns="http://www.w3.org/2000/svg" version="1.1">\n')
desc = "%r, %s, (Blender %s)" % (basename(bpy.data.filepath), mesh.name, bpy.app.version_string)
desc = ("%r, %s, (Blender %s)" %
(basename(bpy.data.filepath), mesh.name, bpy.app.version_string))
fw('<desc>%s</desc>\n' % escape(desc))
# svg colors
......@@ -39,7 +41,9 @@ def write(fw, mesh, image_width, image_height, opacity, face_iter_func):
fill_default = 'fill="grey"'
for mat in mesh.materials if mesh.materials else [None]:
if mat:
fill_settings.append('fill="rgb(%d, %d, %d)"' % tuple(int(c * 255) for c in mat.diffuse_color))
fill_settings.append('fill="rgb(%d, %d, %d)"' %
tuple(int(c * 255)
for c in mat.diffuse_color))
else:
fill_settings.append(fill_default)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment