Skip to content

Commit

Permalink
more wp-content/uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuo committed May 17, 2023
1 parent a20ebce commit 0b10482
Show file tree
Hide file tree
Showing 973 changed files with 351 additions and 0 deletions.
Binary file added wp-content/uploads/2009/02/webicon1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon31.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added wp-content/uploads/2009/02/webicon32.png
Binary file added wp-content/uploads/2009/02/webicon33.png
Binary file added wp-content/uploads/2009/02/webicon34.png
Binary file added wp-content/uploads/2009/02/webicon35.png
Binary file added wp-content/uploads/2009/02/webicon36.png
Binary file added wp-content/uploads/2009/02/webicon37.png
Binary file added wp-content/uploads/2009/02/webicon38.png
Binary file added wp-content/uploads/2009/02/webicon39.png
Binary file added wp-content/uploads/2009/02/webicon4.png
Binary file added wp-content/uploads/2009/02/webicon40.png
Binary file added wp-content/uploads/2009/02/webicon41.png
Binary file added wp-content/uploads/2009/02/webicon42.png
Binary file added wp-content/uploads/2009/02/webicon43.png
Binary file added wp-content/uploads/2009/02/webicon44.png
Binary file added wp-content/uploads/2009/02/webicon45.png
Binary file added wp-content/uploads/2009/02/webicon46.png
Binary file added wp-content/uploads/2009/02/webicon47.png
Binary file added wp-content/uploads/2009/02/webicon48.png
Binary file added wp-content/uploads/2009/02/webicon49.png
Binary file added wp-content/uploads/2009/02/webicon5.png
Binary file added wp-content/uploads/2009/02/webicon6.png
Binary file added wp-content/uploads/2009/02/webicon7.png
Binary file added wp-content/uploads/2009/02/webicon7a.png
Binary file added wp-content/uploads/2009/02/webicon8.png
Binary file added wp-content/uploads/2009/02/webicon9.png
Binary file added wp-content/uploads/2009/03/01-150x150.gif
Binary file added wp-content/uploads/2009/03/01.gif
Binary file added wp-content/uploads/2009/03/02-xerox-8010-star.gif
Binary file added wp-content/uploads/2009/03/03-apple-lisa-1.gif
Binary file added wp-content/uploads/2009/03/05-visi-on-300x187.gif
Binary file added wp-content/uploads/2009/03/05-visi-on.gif
Binary file added wp-content/uploads/2009/03/06-visi-on-300x187.jpg
Binary file added wp-content/uploads/2009/03/06-visi-on.jpg
Binary file added wp-content/uploads/2009/03/07-mac-os-1.gif
Binary file added wp-content/uploads/2009/03/1-150x150.png
Binary file added wp-content/uploads/2009/03/10-windows-1.gif
Binary file added wp-content/uploads/2009/03/11-150x150.jpg
Binary file added wp-content/uploads/2009/03/11-windows-11.gif
Binary file added wp-content/uploads/2009/03/12-irix-3-300x192.jpg
Binary file added wp-content/uploads/2009/03/12-irix-3.jpg
Binary file added wp-content/uploads/2009/03/13-windows-2.gif
Binary file added wp-content/uploads/2009/03/14-windows-21.gif
Binary file added wp-content/uploads/2009/03/15-os-2-1-300x224.gif
Binary file added wp-content/uploads/2009/03/15-os-2-1.gif
Binary file added wp-content/uploads/2009/03/16-os-2-11-300x224.gif
Binary file added wp-content/uploads/2009/03/16-os-2-11.gif
Binary file added wp-content/uploads/2009/03/17-nextstep-1.jpg
Binary file added wp-content/uploads/2009/03/18-os-2-12.gif
Binary file added wp-content/uploads/2009/03/19-windows-3.gif
Binary file added wp-content/uploads/2009/03/20-windows-31.gif
Binary file added wp-content/uploads/2009/03/22-macos-7.jpg
Binary file added wp-content/uploads/2009/03/25-os-2-2-300x224.gif
Binary file added wp-content/uploads/2009/03/25-os-2-2.gif
Binary file added wp-content/uploads/2009/03/26-os-2-21-300x224.gif
Binary file added wp-content/uploads/2009/03/26-os-2-21.gif
Binary file added wp-content/uploads/2009/03/27-windows-951.gif
Binary file added wp-content/uploads/2009/03/28-windows-95.gif
Binary file added wp-content/uploads/2009/03/29-os-2-warp-4.jpg
Binary file added wp-content/uploads/2009/03/30-os-2-warp-41.jpg
Binary file added wp-content/uploads/2009/03/31-macos-8-300x224.jpg
Binary file added wp-content/uploads/2009/03/31-macos-8.jpg
Binary file added wp-content/uploads/2009/03/32-windows-98.jpg
Binary file added wp-content/uploads/2009/03/33-kde-1.jpg
Binary file added wp-content/uploads/2009/03/34-gnome-1-150x150.gif
Binary file added wp-content/uploads/2009/03/34-gnome-1.gif
Binary file added wp-content/uploads/2009/03/35-mac-osx-1.jpg
Binary file added wp-content/uploads/2009/03/36-windows-xp.jpg
Binary file added wp-content/uploads/2009/03/37-kde-3.jpg
Binary file added wp-content/uploads/2009/03/38-windows-vista.jpg
Binary file added wp-content/uploads/2009/03/39-mac-osx-leopard.jpg
Binary file added wp-content/uploads/2009/03/40-kde.jpg
Binary file added wp-content/uploads/2009/03/ankshsvn-300x236.png
Binary file added wp-content/uploads/2009/03/ankshsvn.png
Binary file added wp-content/uploads/2009/03/auto-300x105.gif
Binary file added wp-content/uploads/2009/03/auto.gif
Binary file added wp-content/uploads/2009/03/cccpairprogramming.jpg
Binary file added wp-content/uploads/2009/03/dp_book-150x150.jpg
Binary file added wp-content/uploads/2009/03/ecl-297x300.gif
Binary file added wp-content/uploads/2009/03/ecl.gif
Binary file added wp-content/uploads/2009/03/fcomment10.gif
Binary file added wp-content/uploads/2009/03/fcomment11.gif
Binary file added wp-content/uploads/2009/03/fcomment12.gif
Binary file added wp-content/uploads/2009/03/fcomment13.gif
Binary file added wp-content/uploads/2009/03/fcomment2.gif
Binary file added wp-content/uploads/2009/03/fcomment3.gif
Binary file added wp-content/uploads/2009/03/fcomment4.gif
Binary file added wp-content/uploads/2009/03/fcomment5.gif
Binary file added wp-content/uploads/2009/03/fcomment6.gif
Binary file added wp-content/uploads/2009/03/fcomment7.gif
Binary file added wp-content/uploads/2009/03/fcomment8.gif
Binary file added wp-content/uploads/2009/03/fcomment9.gif
Binary file added wp-content/uploads/2009/03/gldt92-161x270.png
Binary file added wp-content/uploads/2009/03/gldt92-179x300.png
Binary file added wp-content/uploads/2009/03/gldt92-612x1024.png
Binary file added wp-content/uploads/2009/03/gldt92-768x1285.png
Binary file added wp-content/uploads/2009/03/gldt92.png
Binary file added wp-content/uploads/2009/03/hello_world.png
Binary file added wp-content/uploads/2009/03/jano-300x277.gif
Binary file added wp-content/uploads/2009/03/jano.gif
Binary file added wp-content/uploads/2009/03/makelinux.jpg
Binary file added wp-content/uploads/2009/03/subclipse-300x168.png
Binary file added wp-content/uploads/2009/03/subclipse.png
Binary file added wp-content/uploads/2009/03/tortoisesvn.png
Binary file added wp-content/uploads/2009/03/versions-300x193.jpg
Binary file added wp-content/uploads/2009/03/versions.jpg
Binary file added wp-content/uploads/2009/03/vim-300x282.png
Binary file added wp-content/uploads/2009/03/vim.png
Binary file added wp-content/uploads/2009/03/warehouse2-300x240.jpg
Binary file added wp-content/uploads/2009/03/warehouse2.jpg
Binary file added wp-content/uploads/2009/03/webicon3-150x150.png
Binary file added wp-content/uploads/2009/03/webmail1-150x150.jpg
Binary file added wp-content/uploads/2009/03/zcover-150x150.jpg
Binary file added wp-content/uploads/2009/04/107.jpg
Binary file added wp-content/uploads/2009/04/116.jpg
Binary file added wp-content/uploads/2009/04/18-150x150.jpg
Binary file added wp-content/uploads/2009/04/18.jpg
Binary file added wp-content/uploads/2009/04/26searchbut.jpg
Binary file added wp-content/uploads/2009/04/37.jpg
Binary file added wp-content/uploads/2009/04/70.jpg
Binary file added wp-content/uploads/2009/04/88bluedesign.jpg
Binary file added wp-content/uploads/2009/04/agencylayout.jpg
Binary file added wp-content/uploads/2009/04/akismet-150x150.jpg
Binary file added wp-content/uploads/2009/04/anger-150x150.gif
Binary file added wp-content/uploads/2009/04/anger-200x200.gif
Binary file added wp-content/uploads/2009/04/anger.gif
Binary file added wp-content/uploads/2009/04/asus-eee-pc-s101.jpg
Binary file added wp-content/uploads/2009/04/cartoonclick.jpg
Binary file added wp-content/uploads/2009/04/cfl28layout.jpg
Binary file added wp-content/uploads/2009/04/cleang28.jpg
Binary file added wp-content/uploads/2009/04/click.jpg
Binary file added wp-content/uploads/2009/04/compaq-slt-286.jpg
Binary file added wp-content/uploads/2009/04/design-studio2-big.gif
Binary file not shown.
Binary file added wp-content/uploads/2009/04/final-large.jpg
Binary file added wp-content/uploads/2009/04/final-small.gif
Binary file added wp-content/uploads/2009/04/final.gif
Binary file added wp-content/uploads/2009/04/final.jpg
Binary file added wp-content/uploads/2009/04/final.png
Binary file added wp-content/uploads/2009/04/final1.png
Binary file added wp-content/uploads/2009/04/finalnav.jpg
Binary file added wp-content/uploads/2009/04/finalprofdesign.jpg
Binary file added wp-content/uploads/2009/04/finished300x146.jpg
Binary file added wp-content/uploads/2009/04/headertutfin.jpg
Binary file added wp-content/uploads/2009/04/heap-300x96.png
Binary file added wp-content/uploads/2009/04/heap.png
Binary file added wp-content/uploads/2009/04/home-300x168.jpg
Binary file added wp-content/uploads/2009/04/home.jpg
Binary file added wp-content/uploads/2009/04/linux_bonus_22_2.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_1.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_102_2.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_132_1.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_2.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_3.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_4.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_63_2.jpg
Binary file added wp-content/uploads/2009/04/linux_crash_82_2.jpg
Binary file added wp-content/uploads/2009/04/listinsertion.png
Binary file added wp-content/uploads/2009/04/macbook-air.jpg
Binary file added wp-content/uploads/2009/04/macportable.jpg
Binary file added wp-content/uploads/2009/04/menusample.jpg
Binary file added wp-content/uploads/2009/04/ncurses_example.jpg
Binary file added wp-content/uploads/2009/04/osborne1-300x241.jpg
Binary file added wp-content/uploads/2009/04/osborne1.jpg
Binary file added wp-content/uploads/2009/04/overall-150x150.jpg
Binary file added wp-content/uploads/2009/04/platinum-medium.jpg
Binary file added wp-content/uploads/2009/04/powerbook-165c.jpg
Binary file added wp-content/uploads/2009/04/previewsiteutt.png
Binary file added wp-content/uploads/2009/04/programmer-150x150.jpg
Binary file added wp-content/uploads/2009/04/programmer-200x200.jpg
Binary file added wp-content/uploads/2009/04/programmer.jpg
Binary file added wp-content/uploads/2009/04/python_ncursespy.jpg
Binary file added wp-content/uploads/2009/04/quick-300x96.png
Binary file added wp-content/uploads/2009/04/quick.png
Binary file added wp-content/uploads/2009/04/result.gif
Binary file added wp-content/uploads/2009/04/royfinal.jpg
Binary file added wp-content/uploads/2009/04/selection-300x96.png
Binary file added wp-content/uploads/2009/04/selection.png
Binary file added wp-content/uploads/2009/04/shell-300x96.png
Binary file added wp-content/uploads/2009/04/shell.png
Binary file added wp-content/uploads/2009/04/sleekweb20final.jpg
Binary file added wp-content/uploads/2009/04/snake-150x150.jpg
Binary file added wp-content/uploads/2009/04/snake-300x243.jpg
Binary file added wp-content/uploads/2009/04/snake-334x270.jpg
Binary file added wp-content/uploads/2009/04/snake.jpg
Binary file added wp-content/uploads/2009/04/sony-zoom-300x225.jpg
Binary file added wp-content/uploads/2009/04/sony-zoom.jpg
Binary file added wp-content/uploads/2009/04/step53.png
Binary file added wp-content/uploads/2009/04/sun-oracle.jpg
Binary file added wp-content/uploads/2009/04/tornfinal.jpg
351 changes: 351 additions & 0 deletions wp-content/uploads/2009/04/visualise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,351 @@
#!/usr/bin/env python
"""
Some of these algorithms are all rather literally from Knuth - as a
consequence they're not very Pythonic, and not terribly readable.
In some cases I've modified the algorithm to make sure that all items are
present once and only once in the array of sortables every time we
memoizePath (i.e. that the algorithm is in-place).
Page numbers refer to The Art of Computer Programming vol. 3.
This code is in the public domain - do whatever you like with it.
"""
import random, math, sys
from optparse import OptionParser
import cairo

def intRGB(r, g, b):
return (r/255.0, g/255.0, b/255.0)

HIGHLIGHT=intRGB(0xff, 0x72, 0x72)

class NiceCtx(cairo.Context):
defaultBorderColour = intRGB(0x7d, 0x7d, 0x7d)
def stroke_border(self, border):
src = self.get_source()
width = self.get_line_width()
self.set_source_rgba(*self.defaultBorderColour)
self.stroke_preserve()
self.set_source(src)
self.set_line_width(width - (border * 2))
self.stroke()


class Canvas:
def __init__(self, width, height):
self.width, self.height = width, height
self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
self.background(1, 1, 1)

def ctx(self):
return NiceCtx(self.surface)

def background(self, r, g, b):
c = self.ctx()
c.set_source_rgb(r, g, b)
c.rectangle(0, 0, self.width, self.height)
c.fill()
c.stroke()

def save(self, fname):
self.surface.write_to_png(fname)


class Sortable:
def __init__(self, i):
self.i = i
self.path = []

def __cmp__(self, other):
return cmp(self.i, other.i)

def __repr__(self):
return str(self.i)


class TrackList:
def __init__(self, itms):
self.lst = [Sortable(i) for i in itms]

def __getattr__(self, attr):
return getattr(self.lst, attr)

def memoizePath(self):
for i, v in enumerate(self):
v.path.append(i)


class PathDrawer:
def __init__(self, width, height, line, border, highlights, prefix):
self.width, self.height = width, height
self.line, self.border = line, border
self.highlights, self.prefix = highlights, prefix

def _lineCoords(self, elem, l):
init = 0.02 # Proportional initial length
lst = []
xscale = (1.0-init)/len(elem.path)
yscale = 1.0/l
lst.append((0, yscale/2 + (yscale * elem.path[0])))
lst.append((init, yscale/2 + (yscale * elem.path[0])))
for i, v in enumerate(elem.path):
lst.append(((xscale * i) + init, yscale/2 + (yscale * v)))
lst.append((1, lst[-1][1]))
return lst

def draw(self, algo):
c = Canvas(self.width, self.height)
# Clearer when drawn in this order
l = reversed(algo.lst)
ctx = c.ctx()
for elem in l:
for i in self._lineCoords(elem, len(algo.lst)):
ctx.line_to(self.width * i[0], self.height * i[1])
ctx.set_line_cap(cairo.LINE_CAP_BUTT)
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
if elem.i in self.highlights:
ctx.set_source_rgb(*HIGHLIGHT)
else:
x = 1 - (float(elem.i)/len(algo.lst)*0.7)
ctx.set_source_rgb(x, x, x)
ctx.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
ctx.set_line_width(self.line)
ctx.stroke_border(self.border)
c.save("%s%s.png"%(self.prefix, algo.name))


class Algorithm:
def __init__(self, entries):
self.name = self.__class__.__name__
self.lst = TrackList(entries)
self.lst.memoizePath()
self.sort(self.lst)


class Bubble(Algorithm):
def sort(self, lst):
bound = len(lst)-1
while 1:
t = 0
for j in range(bound):
if lst[j] > lst[j+1]:
lst[j], lst[j+1] = lst[j+1], lst[j]
lst.memoizePath()
t = j
if t == 0:
break
bound = t


class ListInsertion(Algorithm):
"""
Broadly based on the list insertion sort on p 97.
"""
def sort(self, lst):
for i in range(1, len(lst)):
for j in range(i):
if lst[i] < lst[j]:
x = lst.pop(i)
lst.insert(j, x)
lst.memoizePath()


class Shell(Algorithm):
"""
Shell's method, p. 84
"""
def sort(self, lst):
t = [5, 3, 1]
for h in t:
for j in range(h, len(lst)):
i = j - h
r = lst[j]
flag = 0
while i > -1:
if r < lst[i]:
flag = 1
lst[i+h], lst[i] = lst[i], lst[i+h]
i -= h
lst.memoizePath()
else:
break
lst[i+h] = r


class Selection(Algorithm):
"""
Selection Sort, p. 139
"""
def sort(self, lst):
for j in range(len(lst)-1, 0, -1):
m = lst.index(max(lst[:j])) # No, this is not efficient ;)
lst[m], lst[j] = lst[j], lst[m]
lst.memoizePath()


class Heap(Algorithm):
"""
Algorithm from http://en.wikipedia.org/wiki/Heapsort
"""
def sift(self, lst, start, count):
root = start
while (root * 2) + 1 < count:
child = (root * 2) + 1
if child < (count-1) and lst[child] < lst[child+1]:
child += 1
if lst[root] < lst[child]:
lst[root], lst[child] = lst[child], lst[root]
lst.memoizePath()
root = child
else:
return

def sort(self, lst):
start = (len(lst)/2)-1
end = len(lst)-1
while start >= 0:
self.sift(lst, start, len(lst))
start -= 1
while end > 0:
lst[end], lst[0] = lst[0], lst[end]
lst.memoizePath()
self.sift(lst, 0, end)
end -= 1


class Quick(Algorithm):
"""
http://www.cs.indiana.edu/classes/a348-dger/lectures/tsort/1.0.2/QSortAlgorithm.java
"""
def sort(self, lst, left=0, right=None):
if right is None:
right = len(lst) - 1
l = left
r = right
if l <= r:
mid = lst[(left+right)/2]
while l <= r:
while l <= right and lst[l] < mid:
l += 1
while r > left and lst[r] > mid:
r -= 1
if l <= r:
lst[l], lst[r] = lst[r], lst[l]
lst.memoizePath()
l+=1
r-=1
if left < r:
self.sort(lst, left, r)
if l < right:
self.sort(lst, l, right)



def main():
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option(
"-a",
dest="algorithm",
default=False,
type="choice",
choices=["quick", "heap", "selection", "insertion", "bubble", "shell"],
help="Draw only a named algorithm."
)
parser.add_option(
"-n",
dest="numelements",
default="20",
type="int",
help="Generate a random sorting sequence of length n"
)
parser.add_option(
"-f",
dest="readfile",
help="Read data from file"
)
parser.add_option(
"-p",
dest="prefix",
help="File name prefix.",
default=""
)
parser.add_option(
"-d",
dest="dump",
default=False,
action="store_true",
help="Dump sequence"
)
parser.add_option(
"-x",
dest="width",
type="int",
default=700,
help="Image width"
)
parser.add_option(
"-y",
dest="height",
type="int",
default=300,
help="Image height"
)
parser.add_option(
"-l",
dest="line",
type="int",
default=6,
help="Total line width"
)
parser.add_option(
"-b",
dest="border",
type="int",
default=1,
help="Border width"
)
parser.add_option(
"-i",
dest="highlight",
type="int",
default=[],
action="append",
help="Highlight digit N (0-based). Can be passed muiltiple times."
)
options, args = parser.parse_args()
if args:
parser.error("Script takes no arguments.")
if options.readfile:
txt = file(options.readfile).read().split()
lst = [int(i) for i in txt]
else:
lst = range(options.numelements)
random.shuffle(lst)
if options.highlight:
if max(options.highlight) > (len(lst)-1):
parser.error("Highlight element > than list length.")
if options.dump:
for i in lst:
print i,
ldrawer = PathDrawer(
options.width,
options.height,
options.line,
options.border,
options.highlight,
options.prefix
)
for i in [Quick, Heap, Selection, ListInsertion, Bubble, Shell]:
name = i.__name__
if options.algorithm:
if not options.algorithm.lower() == name.lower():
continue
print >> sys.stderr, name
a = i(lst)
ldrawer.draw(a)


if __name__ == "__main__":
main()
Binary file added wp-content/uploads/2009/04/web-medium.jpg
Binary file added wp-content/uploads/2009/04/zeniths-minisport.jpg
Binary file added wp-content/uploads/2009/05/flow_charts.png
Loading

0 comments on commit 0b10482

Please sign in to comment.