oozby 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/oozby +4 -13
- data/lib/oozby/base.rb +1 -1
- data/lib/oozby/environment.rb +4 -0
- data/lib/oozby/method_preprocessor.rb +49 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a23a382871587b9a004386c00f558f07dbe317af
|
4
|
+
data.tar.gz: b287f6a6be40890def253994c9413f5ba3140bad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e202ef9d0b2a7d76bf7cf885df73911e8f86f8240c6705760cccd86f34811db7ad80ae3c543b5e02145180b7fcfc888e6b3c0102cfcfd49e6f42435a312e9748
|
7
|
+
data.tar.gz: 52a53ae63fe96411d3b1783db58466db03e83f3d5b17c6f5819d94ec7c356e4ca0e2afc49f07a3dc093f7f87c82d83958484d87658a90192cc27d8c127b95779
|
data/bin/oozby
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift File.dirname(__FILE__) + "/../lib"
|
3
3
|
require 'thor'
|
4
|
-
#require 'fssm'
|
5
4
|
require 'listen'
|
6
5
|
require 'pp'
|
7
6
|
require 'oozby'
|
@@ -47,6 +46,7 @@ class OozbyUtility < Thor
|
|
47
46
|
compile File.join(*args)
|
48
47
|
end
|
49
48
|
|
49
|
+
puts "Watching folder for changes... (CTRL+C to exit)"
|
50
50
|
Listen.to! directory, filter: /\.oozby$/ do |modified, added, removed|
|
51
51
|
modified.each { |path| recompile_handler[path] }
|
52
52
|
added.each { |path| recompile_handler[path] }
|
@@ -58,20 +58,11 @@ class OozbyUtility < Thor
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
62
|
-
# FSSM.monitor(directory, File.join('**', '*.oozby')) do
|
63
|
-
# create &recompile_handler
|
64
|
-
# update &recompile_handler
|
65
|
-
# delete do |dir, name|
|
66
|
-
# puts "#{name} deleted."
|
67
|
-
# if File.exists? File.join(dir, name + ".scad")
|
68
|
-
# File.delete(File.join(dir, name + ".scad"))
|
69
|
-
# puts "Deleted generated .scad file for obsolete #{name}"
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
# end
|
73
61
|
end
|
74
62
|
end
|
63
|
+
rescue Interrupt => e
|
64
|
+
puts ""
|
65
|
+
puts "Have a nice day!"
|
75
66
|
end
|
76
67
|
end
|
77
68
|
|
data/lib/oozby/base.rb
CHANGED
@@ -12,7 +12,7 @@ class Oozby
|
|
12
12
|
|
13
13
|
# rescue block to filter out junk oozby library stuff from backtraces
|
14
14
|
begin
|
15
|
-
compiled = eval("lambda {; #{code}
|
15
|
+
compiled = eval("lambda {; #{code};\n }", nil, filename)
|
16
16
|
env.instance_exec(&compiled)
|
17
17
|
rescue
|
18
18
|
warn "Recent Calls: " + env.instance_variable_get(:@method_history).last(10).reverse.inspect
|
data/lib/oozby/environment.rb
CHANGED
@@ -122,6 +122,10 @@ class Oozby::Environment
|
|
122
122
|
# gets and sets resolution settings
|
123
123
|
def resolution **settings, &proc
|
124
124
|
warn "Setting fragments_per_turn and degrees_per_fragment together makes no sense!" if settings[:fragments_per_turn] && settings[:degrees_per_fragment]
|
125
|
+
settings[:fragments_per_turn] ||= settings.delete(:facets_per_turn)
|
126
|
+
settings[:degrees_per_fragment] ||= settings.delete(:degrees_per_facet)
|
127
|
+
settings[:fragments] ||= settings.delete(:facets)
|
128
|
+
settings.delete_if { |key,value| value == nil }
|
125
129
|
previous_settings = @resolution
|
126
130
|
@resolution.merge! settings
|
127
131
|
@resolution[:degrees_per_fragment] = 360.0 / settings[:fragments_per_turn].to_f if settings[:fragments_per_turn]
|
@@ -69,7 +69,7 @@ class Oozby::MethodPreprocessor
|
|
69
69
|
|
70
70
|
if info.named_args[:r] && info.named_args[:r] > 0.0
|
71
71
|
# render rounded rectangle
|
72
|
-
info.replace rounded_cube(**args_parse(info, :size, :center
|
72
|
+
info.replace rounded_cube(**args_parse(info, :size, :center))
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -82,6 +82,7 @@ class Oozby::MethodPreprocessor
|
|
82
82
|
info.named_args[:r2] = info.named_args.delete(:radius_2) if info.named_args[:radius_2]
|
83
83
|
|
84
84
|
info.named_args[:"$fn"] = info.named_args.delete(:facets) if info.named_args[:facets]
|
85
|
+
info.named_args[:"$fn"] = info.named_args.delete(:fragments) if info.named_args[:fragments]
|
85
86
|
|
86
87
|
# let users specify diameter instead of radius - convert it
|
87
88
|
{ diameter: :r, dia: :r, d: :r,
|
@@ -124,26 +125,28 @@ class Oozby::MethodPreprocessor
|
|
124
125
|
|
125
126
|
if info[:named_args][:r] and info.named_args[:r] > 0.0
|
126
127
|
# render rounded rectangle
|
127
|
-
info.replace rounded_rect(**args_parse(info, :size, :center
|
128
|
+
info.replace rounded_rect(**args_parse(info, :size, :center).merge(facets: info.named_args["$fn"]))
|
128
129
|
end
|
129
130
|
end
|
130
131
|
|
131
|
-
def rounded_rect size: [1,1], center: false, r: 0.0
|
132
|
+
def rounded_rect size: [1,1], center: false, r: 0.0, facets: nil
|
132
133
|
diameter = r * 2
|
133
134
|
circle_x = (size[0] / 2.0) - r
|
134
135
|
circle_y = (size[1] / 2.0) - r
|
135
136
|
|
136
137
|
capture do
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
138
|
+
resolution(fragments: (facets || 0)) do
|
139
|
+
translate(if center then [0,0] else [size[0].to_f / 2.0, size[1].to_f / 2.0] end) do
|
140
|
+
union do
|
141
|
+
square([size[0], size[1] - diameter], center = true)
|
142
|
+
square([size[0] - diameter, size[1]], center = true)
|
143
|
+
preprocessor true do
|
144
|
+
resolution(fragments: (_fragments_for(radius: r).to_f / 4.0).round * 4.0) do
|
145
|
+
translate([ circle_x, circle_y]) { circle(r: r) }
|
146
|
+
translate([ circle_x, -circle_y]) { circle(r: r) }
|
147
|
+
translate([-circle_x, -circle_y]) { circle(r: r) }
|
148
|
+
translate([-circle_x, circle_y]) { circle(r: r) }
|
149
|
+
end
|
147
150
|
end
|
148
151
|
end
|
149
152
|
end
|
@@ -151,44 +154,46 @@ class Oozby::MethodPreprocessor
|
|
151
154
|
end
|
152
155
|
end
|
153
156
|
|
154
|
-
def rounded_cube size: [1,1,1], center: false, r: 0.0
|
157
|
+
def rounded_cube size: [1,1,1], center: false, r: 0.0, facets: nil
|
155
158
|
size = [size[0] || 1, size[1] || 1, size[2] || 1]
|
156
159
|
diameter = r.to_f * 2.0
|
157
160
|
|
158
161
|
preprocessor = self
|
159
162
|
# use rounded rect to create the body shape
|
160
163
|
capture do
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
164
|
+
resolution(fragments: (facets || 0)) do
|
165
|
+
offset = if center then [0,0,0] else [size[0].to_f / 2.0, size[1].to_f / 2.0, size[2].to_f / 2.0] end
|
166
|
+
translate(offset) do
|
167
|
+
# extrude the main body parts using rounded_rect as the basis
|
168
|
+
linear_extrude(height: size[2] - diameter, center: true) {
|
169
|
+
inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[1]], center: true, r: r)) }
|
170
|
+
rotate([90,0,0]) { linear_extrude(height: size[1] - diameter, center: true) {
|
171
|
+
inject_abstract_tree(preprocessor.rounded_rect(size: [size[0], size[2]], center: true, r: r)) }}
|
172
|
+
rotate([0,90,0]) { linear_extrude(height: size[0] - diameter, center: true) {
|
173
|
+
inject_abstract_tree(preprocessor.rounded_rect(size: [size[2], size[1]], center: true, r: r)) }}
|
170
174
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
175
|
+
# fill in the corners with spheres
|
176
|
+
xr, yr, zr = size.map { |x| (x / 2) - r }
|
177
|
+
corner_coordinates = [
|
178
|
+
[ xr, yr, zr],
|
179
|
+
[ xr, yr,-zr],
|
180
|
+
[ xr,-yr, zr],
|
181
|
+
[ xr,-yr,-zr],
|
182
|
+
[-xr, yr, zr],
|
183
|
+
[-xr, yr,-zr],
|
184
|
+
[-xr,-yr, zr],
|
185
|
+
[-xr,-yr,-zr]
|
186
|
+
]
|
187
|
+
preprocessor true do
|
188
|
+
resolution(fragments: (_fragments_for(radius: r).to_f / 4.0).round * 4.0) do
|
189
|
+
corner_coordinates.each do |coordinate|
|
190
|
+
translate(coordinate) do
|
191
|
+
# generate sphere shape
|
192
|
+
rotate_extrude do
|
193
|
+
intersection do
|
194
|
+
circle(r: r)
|
195
|
+
translate([r, 0, 0]) { square([r * 2, r * 4], center: true) }
|
196
|
+
end
|
192
197
|
end
|
193
198
|
end
|
194
199
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oozby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bluebie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|