Spaces:
Runtime error
Runtime error
Commit
·
028f0f5
1
Parent(s):
2c95e43
feat: support custom size option
Browse filesFormer-commit-id: baca57c4b9770ede12bc2001050ce9e689b6313b
- create-3d-icon.py +9 -4
create-3d-icon.py
CHANGED
@@ -33,6 +33,8 @@ def main():
|
|
33 |
type=float, default=-1)
|
34 |
parser.add_argument("--b", help="blue color",
|
35 |
type=float, default=-1)
|
|
|
|
|
36 |
args = parser.parse_args()
|
37 |
|
38 |
filepath = args.filepath
|
@@ -48,6 +50,7 @@ def main():
|
|
48 |
color_r = args.r
|
49 |
color_g = args.g
|
50 |
color_b = args.b
|
|
|
51 |
|
52 |
capture(
|
53 |
filepath,
|
@@ -63,6 +66,7 @@ def main():
|
|
63 |
color_r,
|
64 |
color_g,
|
65 |
color_b,
|
|
|
66 |
)
|
67 |
else:
|
68 |
print("No file path given")
|
@@ -82,6 +86,7 @@ def capture(
|
|
82 |
color_r=-1,
|
83 |
color_g=-1,
|
84 |
color_b=-1,
|
|
|
85 |
):
|
86 |
reset()
|
87 |
|
@@ -127,7 +132,7 @@ def capture(
|
|
127 |
location=(distance * 3, 0, 0), rotation=(math.pi*0.5, 0, math.pi*0.5))
|
128 |
bpy.context.scene.camera = bpy.data.objects['Camera']
|
129 |
|
130 |
-
render(
|
131 |
|
132 |
return
|
133 |
|
@@ -142,10 +147,10 @@ def log(any):
|
|
142 |
print("func:", key)
|
143 |
|
144 |
|
145 |
-
def render(out=os.path.join(os.getcwd(), 'out.png')):
|
146 |
bpy.context.scene.render.filepath = out
|
147 |
-
bpy.context.scene.render.resolution_x =
|
148 |
-
bpy.context.scene.render.resolution_y =
|
149 |
bpy.context.scene.render.film_transparent = True
|
150 |
bpy.ops.render.render(write_still=True)
|
151 |
|
|
|
33 |
type=float, default=-1)
|
34 |
parser.add_argument("--b", help="blue color",
|
35 |
type=float, default=-1)
|
36 |
+
parser.add_argument(
|
37 |
+
"--size", help="size of the image", type=int, default=2048)
|
38 |
args = parser.parse_args()
|
39 |
|
40 |
filepath = args.filepath
|
|
|
50 |
color_r = args.r
|
51 |
color_g = args.g
|
52 |
color_b = args.b
|
53 |
+
size = args.size
|
54 |
|
55 |
capture(
|
56 |
filepath,
|
|
|
66 |
color_r,
|
67 |
color_g,
|
68 |
color_b,
|
69 |
+
size
|
70 |
)
|
71 |
else:
|
72 |
print("No file path given")
|
|
|
86 |
color_r=-1,
|
87 |
color_g=-1,
|
88 |
color_b=-1,
|
89 |
+
size=2048
|
90 |
):
|
91 |
reset()
|
92 |
|
|
|
132 |
location=(distance * 3, 0, 0), rotation=(math.pi*0.5, 0, math.pi*0.5))
|
133 |
bpy.context.scene.camera = bpy.data.objects['Camera']
|
134 |
|
135 |
+
render(filepath.replace('.svg', '.png'), size)
|
136 |
|
137 |
return
|
138 |
|
|
|
147 |
print("func:", key)
|
148 |
|
149 |
|
150 |
+
def render(out=os.path.join(os.getcwd(), 'out.png'), size=2048):
|
151 |
bpy.context.scene.render.filepath = out
|
152 |
+
bpy.context.scene.render.resolution_x = size
|
153 |
+
bpy.context.scene.render.resolution_y = size
|
154 |
bpy.context.scene.render.film_transparent = True
|
155 |
bpy.ops.render.render(write_still=True)
|
156 |
|