Skip to content

Instantly share code, notes, and snippets.

@cat-in-136
Created July 1, 2017 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cat-in-136/aa1edd312b8031f6e85107c45113ac80 to your computer and use it in GitHub Desktop.
Save cat-in-136/aa1edd312b8031f6e85107c45113ac80 to your computer and use it in GitHub Desktop.
LDR(LDraw) file generator of Random colored logo bricks
#!/usr/bin/ruby
#
# LDR(LDraw) file generator of Random colored logo bricks
#
# Copyright (c) 2017 @cat_in_136
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# 1 brick width/depth = 20LDU
BRICK_WD = 20
# 1 brick height = 24LDU
BRICK_H = 24
# 15 colours : original 16 colours - 0 (black).
COLOURS = (1..15).to_a
RANGE_X = -590..590
RANGE_Z = -590..590
RANGE_X.step(BRICK_WD) do |x|
RANGE_Z.step(BRICK_WD) do |z|
colour = COLOURS[rand(0..(COLOURS.length - 1))]
y = -BRICK_H
# 3005.DAT -- 1x1 brick
$stdout << "1 #{colour} #{x} #{y} #{z} 1 0 0 0 1 0 0 0 1 3005.DAT"
$stdout << "\r\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment