Module: Glitch3d::FindAndReplace
- Defined in:
- lib/glitch3d/strategies/find_and_replace.rb
Instance Method Summary collapse
- #alter_faces(faces_objects_array, vertices_objects_array) ⇒ Object
- #alter_vertices(vertices_objects_array) ⇒ Object
- #find_and_replace(vertex) ⇒ Object
Instance Method Details
#alter_faces(faces_objects_array, vertices_objects_array) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/glitch3d/strategies/find_and_replace.rb', line 13 def alter_faces(faces_objects_array, vertices_objects_array) faces_objects_array.sample(3) do |face| face.v1 = rand(0..vertices_objects_array.size - 1) end faces_objects_array end |
#alter_vertices(vertices_objects_array) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/glitch3d/strategies/find_and_replace.rb', line 4 def alter_vertices(vertices_objects_array) @target = rand(9).to_s @replacement = rand(9).to_s vertices_objects_array.each do |v| find_and_replace(v) end vertices_objects_array end |
#find_and_replace(vertex) ⇒ Object
20 21 22 23 24 |
# File 'lib/glitch3d/strategies/find_and_replace.rb', line 20 def find_and_replace(vertex) vertex.x = vertex.x.to_s.tr(@target, @replacement).to_f vertex.y = vertex.y.to_s.tr(@target, @replacement).to_f vertex.z = vertex.z.to_s.tr(@target, @replacement).to_f end |