module Glitch3d::FindAndReplace

Public Class Methods

alter_faces(faces_objects_array, vertices_objects_array) click to toggle source
# File lib/glitch3d/strategies/find_and_replace.rb, line 14
def alter_faces(faces_objects_array, vertices_objects_array)
  (FACE_GLITCH_ITERATION_RATIO * faces_objects_array.count)
  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) click to toggle source
# File lib/glitch3d/strategies/find_and_replace.rb, line 5
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) click to toggle source
# File lib/glitch3d/strategies/find_and_replace.rb, line 22
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