From b19d236830f01641503892ffb0b6ec80c7043fbf Mon Sep 17 00:00:00 2001 From: Justis Peters Date: Wed, 20 Jun 2012 00:51:53 -0400 Subject: [PATCH] added ability to write to an existing pygame.Surface --- pytagcloud/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pytagcloud/__init__.py b/pytagcloud/__init__.py index aabe01d..3433543 100755 --- a/pytagcloud/__init__.py +++ b/pytagcloud/__init__.py @@ -349,8 +349,11 @@ def create_tag_image( fontname=fontname, rectangular=rectangular) - image_surface = Surface((sizeRect.w, sizeRect.h), SRCALPHA, 32) - image_surface.fill(background) + if type(output) == pygame.Surface: + image_surface = output + else: + image_surface = Surface((sizeRect.w, sizeRect.h), SRCALPHA, 32) + image_surface.fill(background) for tag in tag_store: image_surface.blit(tag.image, tag.rect) pygame.image.save(image_surface, output)