Permalink
Browse files

Merge branch 'release/0.2'

  • Loading branch information...
Dennis Fink
Dennis Fink committed Apr 6, 2012
2 parents 4b70e0a + 499e94f commit c21f2860936364bfde3afbf97174585d01324d6c
Showing with 44 additions and 30 deletions.
  1. +0 −28 .gitignore
  2. +44 −0 image.py
  3. +0 −2 morse.py
View
@@ -1,28 +0,0 @@
-*.py[co]
-
-# Packages
-*.egg
-*.egg-info
-dist
-build
-eggs
-parts
-bin
-var
-sdist
-develop-eggs
-.installed.cfg
-
-# Installer logs
-pip-log.txt
-
-# Unit test / coverage reports
-.coverage
-.tox
-nosetests.xml
-
-#Translations
-*.mo
-
-#Mr Developer
-.mr.developer.cfg
View
@@ -0,0 +1,44 @@
+#!/usr/bin/python2
+# -*- coding: utf-8 -*-
+
+import morse
+import Image
+
+def draw(string, file):
+
+ if "." not in string or "-" not in string or "/" not in string or "//" not in string:
+ string = morse.encode(string)
+
+ words = string.split("//")
+
+ i = []
+ for word in words:
+ letters = word.split("/")
+
+ for letter in letters:
+ charletter = list(letter)
+ for x in charletter:
+ if x == ".":
+ i.append(1)
+ elif x == "-":
+ i.append(1)
+ i.append(1)
+ i.append(1)
+ else:
+ continue
+ i.append(0)
+ i.append(0)
+ i.append(0)
+ #draw.line((i,0,i+7,0), fill=0)
+ i.append(0)
+ i.append(0)
+ i.append(0)
+ i.append(0)
+
+ while i[-1] == 0:
+ i.pop()
+
+ im = Image.new("1", (len(i),1))
+ im.putdata(i)
+ im.save(file, "PNG")
+
View
@@ -151,7 +151,6 @@ def encode(string=""):
morseword = []
for letter in letters:
morseletter = alphabet_to_morse[letter]
- #print(letter," ",morseletter)
morseword.append(morseletter)
word = "/".join(morseword)
@@ -169,7 +168,6 @@ def decode(string=""):
characterword = []
for letter in letters:
- #print(letter)
characterletter = morse_to_alphabet[letter]
characterword.append(characterletter)

0 comments on commit c21f286

Please sign in to comment.