def test_add_piece(): group1 = Group() group2 = Group() piece = Piece(White, Vector(0, 0, 0), Identity(), Brick1X1, group=group1) assert piece in group1.pieces assert piece not in group2.pieces group2.add_piece(piece) assert piece in group2.pieces assert piece not in group1.pieces
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import random from ldraw.colours import * from ldraw.figure import * from ldraw.pieces import Group, Piece group = Group(Vector(0, 0, 0), Identity()) figure = Person(group=group) print figure.head(Yellow) print figure.hat(Green, "4485") # Cap print figure.torso(Red, "973") # Torso print figure.left_arm(Red) print figure.left_hand(Yellow) print figure.right_arm(Red, -60) print figure.right_hand(Yellow, -10) print figure.right_hand_item(Black, Vector(0, -1, -10), 0, "30132") # Gun Revolver print figure.hips(Blue) print figure.left_leg(Blue) print figure.right_leg(Blue, -30)
from ldraw.library.colours import * from ldraw.figure import * from ldraw.library.parts.minifig.accessories import HelmetClassicWithThickChinGuardAndVisorDimples as HelmetClassic, Torch, MetalDetector from ldraw.library.parts.minifig.torsos import TorsoWithClassicSpacePattern # from ldraw.library.parts.others import Baseplate16X16, Rock1X1Crystal5Point from ldraw.pieces import Piece, Group rover = Group(Vector(0, 0, 0), Identity()) r = Piece(White, Vector(0, 0, 0), Identity(), "44728", rover) print(r)
pixels = [pixels[i * width:(i + 1) * width] for i in xrange(height)] rgbPixels = im.load() if width >= 256 or height >= 256: print( "Opps that files is big - your file needs to be less than 256 pixels in width and height" ) print("Script will now exit") print sys.exit(0) #print pixels #Used for checking print("Creating Lego...") print "Width...", width, " Height...", height onexonexone = Group(Vector(0, 0, 0), Identity()) #Set up the LDraw file mosaicFilename = fileName[:-4] + "_mosiac.ldr" LDrawFile = open(mosaicFilename, 'w') LDrawFile.write('0 // Mosaic Maker Colour - Neil Marsden' + '\n') #Set Up the Lego Colour Dictionary #rgb_code_dictionary = {(27,42,53):26, (242,243,243):1, (163,162,165):194} #(255, 217, 168):RED,(196, 0, 255):FLESH,(30, 0, 255):PURPLE #rgb_code_dictionary = {(0,0,0):0, (87,87,87):8, (110,110,110):7, (190,190,190):503, (255,255,255):15} #GreyScaleOnly - Black,DarkGrey,Grey,LightGrey,White rgb_code_dictionary = { (252, 252, 252): 15, (199, 200, 223): 20, (84, 163, 173): 11, (248, 227, 148): 18,
figure = Person(Vector(0, 0, -10)) print(figure.head(Yellow, 30)) print(figure.hat(White, HelmetClassic)) print(figure.torso(White, TorsoWithClassicSpacePattern)) print(figure.backpack(White, Vector(0, -2, 0))) print(figure.hips(White)) print(figure.left_leg(White, 0)) print(figure.right_leg(White, 0)) print(figure.left_arm(White, -45)) print(figure.left_hand(White, 0)) print(figure.left_hand_item(Light_Grey, Vector(0, -11, -12), 0, Torch)) # Torch print(figure.right_arm(White, 0)) print(figure.right_hand(White, 0)) print('') rover = Group(Vector(80, 48, 20), Identity()) print( Piece(Light_Grey, Vector(0, 0, 0), Identity(), Plate2X2WithRedWheels_Complete_, rover)) print( Piece(Black, Vector(30, 6, 0), Identity().rotate(90, YAxis), Tyre6_50X8OffsetTread, rover)) print( Piece(Black, Vector(-30, 6, 0), Identity().rotate(90, YAxis), Tyre6_50X8OffsetTread, rover)) print( Piece(Light_Grey, Vector(0, 0, -80), Identity(), Plate2X2WithRedWheels_Complete_, rover)) print( Piece(Black, Vector(30, 6, -80),
# figure = Person(Vector(0, 0, -10)) # print(figure.head(Yellow, 30)) # print(figure.hat(White, "193B")) # print(figure.torso(White, "973P90")) # print(figure.backpack(White, Vector(0, -2, 0))) # print(figure.hips(White)) # print(figure.left_leg(White, 0)) # print(figure.right_leg(White, 0)) # print(figure.left_arm(White, -45)) # print(figure.left_hand(White, 0)) # print(figure.left_hand_item(Grey, Vector(0, -11, -12), 0, "3959") # Torch) # print(figure.right_arm(White, 0)) # print(figure.right_hand(White, 0)) # print() rover = Group(Vector(0, 48, 60), Identity().rotate(-15, YAxis)) print( Piece(Light_Grey, Vector(0, 0, 0), Identity(), Plate2X2WithRedWheels_Complete_, rover)) print( Piece(Rubber_Black, Vector(30, 6, 0), Identity().rotate(90, YAxis), Tyre6_50X8OffsetTread, rover)) print( Piece(Rubber_Black, Vector(-30, 6, 0), Identity().rotate(90, YAxis), Tyre6_50X8OffsetTread, rover)) print( Piece(Light_Grey, Vector(0, 0, -80), Identity(), Plate2X2WithRedWheels_Complete_, rover)) print( Piece(Rubber_Black, Vector(30, 6, -80), Identity().rotate(90, YAxis), Tyre6_50X8OffsetTread, rover))
import sys from ldraw.colours import * from ldraw.figure import * from ldraw.geometry import Identity, XAxis from ldraw.parts import Parts from ldraw.pieces import Group, Piece if len(sys.argv) != 2: sys.stderr.write("Usage: %s <parts file>\n" % sys.argv[0]) sys.exit(1) parts = Parts(sys.argv[1]) group = Group(Vector(0, 0, -40), Identity()) figure = Person(group = group) figure.head(Yellow, part = parts.Heads["Head with Monocle, Scar, and Moustache Pattern"]) figure.hat(Black, parts.Hats["Top Hat"]) figure.torso(Black, parts.Torsos["Torso with Black Suit, Red Shirt, Gold Clasps Pattern"]) figure.left_arm(Black, 70) figure.left_hand(White, 0) figure.right_arm(Black, -30) figure.right_hand(White, 0) figure.right_hand_item(ChromeSilver, Vector(0, -58, -20), 0, parts.parts["Minifig Tool Magnifying Glass"]) figure.hips(Black) figure.left_leg(Black, 50) figure.right_leg(Black, -40) group.position = Vector(-100, 40, -120)