Exemplo n.º 1
0
    def save_img(self):
        in_file  = self.in_line.text()
        step     = self.step_line.text()
        words    = self.words_line.text()

        if step.isdigit():
            step = int(step)
        else:
            step = 3

        if words == "":
            words = "#"

        if not os.path.exists(in_file):
            QMessageBox().warning(None, "Error", "Input file does not exist",
                    QMessageBox.StandardButton.Ok)
            return
        output_file = self.get_output_file()

        if not (output_file.lower().endswith(".jpg") or
                output_file.lower().endswith(".png") or
                output_file.lower().endswith(".jpeg")):
            output_file += ".jpg"

        a = Ascii(in_file)
        a.word_artify(words, step)
        a.save(output_file)
Exemplo n.º 2
0
def main():
    parser = OptionParser()
    parser.add_option("-o", "--out", dest = "filename", default = "out.jpg",
            help = "The filename you want your final image saved as")
    parser.add_option("-w", "--words", dest = "words", default = "#",
            help = "Use words to create your image")
    parser.add_option("-s", "--step", dest = "step", type = "int", default = 3,
            help = "choose the distance of your characters")
    parser.add_option("-d", "--density", action="store_true", dest='density',
            help="adding the flag converts the image based on visual density")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print "Failed to provide an input image"
        return

    a = Ascii(in_file)
    if (options.density):
        a.density_artify(step=options.step)
    else:
        a.artify(options.words, options.step)
    a.save(options.filename)
Exemplo n.º 3
0
def main():
    parser = OptionParser()
    parser.add_option("-o", "--out", dest = "filename", default = "out.jpg",
            help = "The filename you want your final image saved as")
    parser.add_option("-w", "--words", dest = "words", default = "#",
            help = "Use words to create your image")
    parser.add_option("-s", "--step", dest = "step", type = "int", default = 3,
            help = "choose the distance of your characters")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print "Failed to provide an input image"
        return

    a = Ascii(in_file)
    a.artify(options.words, step=options.step)
    a.save(options.filename)
Exemplo n.º 4
0
    def save_img(self):
        in_file = self.in_line.text()
        step = self.step_line.text()
        words = self.words_line.text()

        if step.isdigit():
            step = int(step)
        else:
            step = 3

        if words == "":
            words = "#"

        if not os.path.exists(in_file):
            QMessageBox().warning(None, "Error", "Input file does not exist",
                                  QMessageBox.StandardButton.Ok)
            return
        output_file = self.get_output_file()

        if not (output_file.lower().endswith(".jpg")
                or output_file.lower().endswith(".png")
                or output_file.lower().endswith(".jpeg")):
            output_file += ".jpg"

        a = Ascii(in_file)
        a.word_artify(words, step)
        a.save(output_file)
Exemplo n.º 5
0
def main():
    parser = OptionParser()
    parser.add_option("-o",
                      "--out",
                      dest="filename",
                      default="out.jpg",
                      help="The filename you want your final image saved as")
    parser.add_option("-w",
                      "--words",
                      dest="words",
                      default="#",
                      help="Use words to create your image")
    parser.add_option("-s",
                      "--step",
                      dest="step",
                      type="int",
                      default=3,
                      help="choose the distance of your characters")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print "Failed to provide an input image"
        return

    a = Ascii(in_file)
    a.artify(options.words, step=options.step)
    a.save(options.filename)
Exemplo n.º 6
0
def main():
    parser = OptionParser()
    parser.add_option("-o",
                      "--out",
                      dest="filename",
                      default="out.jpg",
                      help="The filename you want your final image saved as")
    parser.add_option("-w",
                      "--words",
                      dest="words",
                      default="#",
                      help="Use words to create your image")
    parser.add_option("-s",
                      "--step",
                      dest="step",
                      type="int",
                      default=3,
                      help="Choose the distance of your characters")
    parser.add_option(
        "-d",
        "--density",
        action="store_true",
        dest='density',
        help="Adding the flag converts the image based on visual density")
    parser.add_option("-t",
                      "--terminal",
                      action="store_true",
                      dest='terminal',
                      help="Print ascii image to terminal")

    (options, args) = parser.parse_args()

    if len(args) > 0:
        in_file = args[0]
    else:
        print("Failed to provide an input image")
        return

    a = Ascii(in_file)

    if options.density:
        a.density_artify(step=options.step)
        a.save(options.filename)

    elif options.terminal:
        a.terminal_artify()

    else:
        a.word_artify(options.words, options.step)
        a.save(options.filename)
Exemplo n.º 7
0
# Part of solution to day 17 of AOC 2019, "Set and Forget".
# https://adventofcode.com/2019/day/17

from ascii import Ascii

analyser = Ascii()

# analyser.load_test_screen('test_screen_1.txt')
analyser.refresh_screen()

analyser.render_screen()

analyser.turn_right()

# Find robot's path to end of scaffolding.
path_ahead = True
while path_ahead:
    analyser.forward()
    path_ahead = analyser.seek()

# Send path the robot followed to stdout.
for step in analyser.robot_trail:
    print(step, end='')
    if step not in {'R', 'L'}:
        print(' ', end='')
Exemplo n.º 8
0
# Part of solution to day 17 of AOC 2019, "Set and Forget".
# https://adventofcode.com/2019/day/17


from ascii import Ascii

this_ascii = Ascii()
this_ascii.refresh_screen()
this_ascii.render_screen()

# "What is the sum of the alignment parameters for the scaffold intersections?"
total = 0

# Check every location in the screen to see if it is an intersection.
for y in range(this_ascii.max_y + 1):
    for x in range(this_ascii.max_x + 1):
        if this_ascii.is_intersection(test_vertex=(x, y)):
            alignment_parameter = x * y
            total += alignment_parameter

print('Part 1:', total)