예제 #1
0
def test_ldr2svg(mocked_parts_lst):
    from ldraw.tools.ldr2svg import ldr2svg
    tool_test(
        lambda f: ldr2svg(
            INPUT_PATH, f, vector_position('100,100,100'),
            vector_position('0,0,0'),
            SVGArgs(800, 800, background_colour=ImageColor.getrgb('#123456'))),
        '.svg')
예제 #2
0
def test_ldr2png(mocked_parts_lst):
    from ldraw.tools.ldr2png import ldr2png
    tool_test(
        lambda f: ldr2png(
            INPUT_PATH, f, vector_position('0,0,0'),
            vector_position('200,200,200'),
            PNGArgs(1, widthxheight('200x200'), ImageColor.getrgb('#FF0000'),
                    ImageColor.getrgb('#123456'))), '.png')
예제 #3
0
def main():
    """ ldr2pov main function """

    description = """Converts the LDraw file to a POV-Ray file.
    
The camera position is a single x,y,z argument where each coordinate
should be specified as a floating point number.
The look at position is a single x,y,z argument where each coordinate
should be specified as a floating point number.
The optional sky colour is a single red,green,blue argument where
each component should be specified as a floating point number between
0.0 and 1.0 inclusive.

"""
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('ldraw_file')
    parser.add_argument('pov_file')
    parser.add_argument('camera_position', type=vector_position)
    parser.add_argument('look_at_position',
                        type=vector_position,
                        default=vector_position("0,0,0"))
    parser.add_argument('--sky')

    args = parser.parse_args()

    ldr2pov(args.ldraw_file, args.pov_file, args.camera_position,
            args.look_at_position, args.sky)
예제 #4
0
def main():
    """ ldr2png main function """
    description = """Converts the LDraw file to a PNG file.
    
The image size must be specified in the format <width>x<height> where the width
and height are measured in pixels.

The camera and look-at positions are x,y,z arguments in LDraw scene coordinates
where each coordinate should be specified as a floating point number.

The eye to viewport distance is specified as a floating point number representing
a length in LDraw scene coordinates. Its default value is 1.0.

The optional sky background and stroke colours are PNG colours, either specified as
#rrggbb or as a named colour.

"""

    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('ldraw_file')
    parser.add_argument('png_file')
    parser.add_argument('image_size', type=widthxheight)
    parser.add_argument('camera_position', type=vector_position)
    parser.add_argument('--look_at_position', required=False, default=vector_position('0,0,0'))
    parser.add_argument('--distance', type=float, default=1.0)
    parser.add_argument('--stroke-colour', dest='stroke_colour', type=ImageColor.getrgb)
    parser.add_argument('--sky', default=ImageColor.getrgb('#000000'), type=ImageColor.getrgb)

    args = parser.parse_args()

    png_args = PNGArgs(args.distance, args.image_size, args.stroke_colour, args.sky)

    ldr2png(args.ldraw_file, args.png_file, args.look_at_position, args.camera_position, png_args)
예제 #5
0
def main():
    """ ldr2svg main function """
    description = """Converts the LDraw file to a SVG file.
    
The viewport size is specified as a pair of floating point numbers representing
lengths in LDraw scene coordinates separated by an \"x\" character.

The camera and look-at positions are x,y,z argument in LDraw scene coordinates
where each coordinate should be specified as a floating point number.

The optional sky background colour is an SVG colour, either specified as
#rrggbb or as a named colour.

"""
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('ldraw_file')
    parser.add_argument('svg_file')
    parser.add_argument('viewport_size', type=widthxheight)
    parser.add_argument('camera_position', type=vector_position)
    parser.add_argument('--look_at_position',
                        type=vector_position,
                        required=False,
                        default=vector_position("0,0,0"))
    parser.add_argument('--sky')
    background_color = '#ffffff'

    args = parser.parse_args()
    svg_args = SVGArgs(args.viewport_size[0],
                       args.viewport_size[1],
                       background_colour=background_color)

    ldr2svg(args.ldraw_file, args.svg_file, args.camera_position,
            args.look_at_position, svg_args)
예제 #6
0
def test_ldr2pov(mocked_parts_lst):
    from ldraw.tools.ldr2pov import ldr2pov
    tool_test(
        lambda f: ldr2pov(INPUT_PATH, f, vector_position('100,100,100'),
                          vector_position('0,0,0'), '#123456'), '.pov')