Sha256: 5c67a6f524a46e36a6a0ce671a23fff49bfdc799d365204738bf8bcbfd2cd8c4

Contents?: true

Size: 831 Bytes

Versions: 4

Compression:

Stored size: 831 Bytes

Contents

# frozen_string_literal: true
module Glitch3d
  module FindAndReplace
    # Find and replace for vertices
    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

    # Assign some faces to different vertices
    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

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glitch3d-0.2.2.8 lib/glitch3d/strategies/find_and_replace.rb
glitch3d-0.2.2.6 lib/glitch3d/strategies/find_and_replace.rb
glitch3d-0.2.2.5 lib/glitch3d/strategies/find_and_replace.rb
glitch3d-0.2.2.3 lib/glitch3d/strategies/find_and_replace.rb