def create_bot(src=None, grammar=NODEBOX, format=None, outputfile=None, iterations=1, buff=None, window=False, title=None, fullscreen=None, server=False, port=7777, show_vars=False, vars=None, namespace=None): """ Create a canvas and a bot with the same canvas attached to it bot parameters :param grammar: DRAWBOT or NODEBOX - decides what kind of bot is created :param vars: preset dictionary of vars from the called canvas parameters: ... everything else ... See create_canvas for details on those parameters. """ canvas = create_canvas(src, format, outputfile, iterations > 1, buff, window, title, fullscreen=fullscreen, show_vars=show_vars) if grammar == DRAWBOT: from shoebot.grammar import DrawBot bot = DrawBot(canvas, namespace=namespace, vars=vars) else: from shoebot.grammar import NodeBot bot = NodeBot(canvas, namespace=namespace, vars=vars) if server: from shoebot.sbio import SocketServer socket_server = SocketServer(bot, "", port=port) return bot
class TestText(unittest.TestCase): def setUp(self): sink = CairoImageSink("output-text.png") canvas = CairoCanvas(sink) self.bot = NodeBot(canvas=canvas) def test_text_saves_params(self): """ Verify parameters are saved and returned by the expected properties. """ # There was a bug where using fontsize, weight or style was causing a crash. text = self.bot.text( "Hello vector graphics", 10, 250, font="Bitstream Vera", fontsize=64, weight="bold", style="italic", ) self.assertEqual(text.text, "Hello vector graphics") self.assertEqual(text.x, 10) self.assertEqual(text.y, 250) self.assertEqual(text.font, "Bitstream Vera") self.assertEqual(text.fontsize, 64) self.assertEqual(text.weight, "bold") self.assertEqual(text.style, "italic")
def create_bot( src=None, format=None, outputfile=None, iterations=1, buff=None, window=False, title=None, fullscreen=None, server=False, port=7777, show_vars=False, vars=None, namespace=None, ): """ Create a canvas and a bot with the same canvas attached to it bot parameters :param vars: preset dictionary of vars from the called canvas parameters: ... everything else ... See create_canvas for details on those parameters. """ multifile = True if iterations and iterations > 1 else False canvas = create_canvas( src=src, format=format, outputfile=outputfile, multifile=multifile, buff=buff, window=window, title=title, fullscreen=fullscreen, show_vars=show_vars, ) bot = NodeBot(canvas, namespace=namespace, vars=vars) if server: from shoebot.sbio import SocketServer socket_server = SocketServer(bot, "", port=port) return bot
def setUp(self): sink = CairoImageSink("output-bezier-pathelement.png") canvas = CairoCanvas(sink) self.bot = NodeBot(canvas=canvas)
def setUp(self): sink = CairoImageSink("output-text.png") canvas = CairoCanvas(sink) self.bot = NodeBot(canvas=canvas)