Changeset 175

Show
Ignore:
Timestamp:
10/01/07 15:37:11 (14 months ago)
Author:
fdb
Message:

vdiff and two compliance tests for NodeBox?.

Location:
nodebox/trunk/src
Files:
10 added
5 modified
2 copied

Legend:

Unmodified
Added
Removed
  • nodebox/trunk/src/Changes.txt

    r159 r175  
    99* Colors are no longer calibrated in RGB color space. This gives correct results. 
    1010* Added new outputmode command that you can set to CMYK or RGB. All colors will adhere to the color mode. 
     11* NodeBox is now packaged: DrawingPrimitives is obsoleted in favor of nodebox.graphics. 
     12  This also means you can work directly with the context: 
     13 
     14    from nodebox.graphics import Context 
     15        ctx = Context() 
     16        ctx.background(None) # Make transparent PNG 
     17        ctx.size(300, 300) 
     18        ctx.rect(0, 0, 100, 100, fill=(0.5, 0.1, 0.3)) 
     19        ctx.save("test.png") # Supported: PDF, PNG, TIFF, JPEG, GIF 
     20 
    1121* BezierPath, Image and Text objects support copying: path.copy() gives you a fresh copy you can transform. 
    1222* Text input now gets converted to unicode, which means you can do: 
     
    2838    canvas.clear() # The canvas is now empty when drawn on-screen 
    2939     
    30 * NodeBox is now packaged: DrawingPrimitives is obsoleted in favor of nodebox.graphics. 
    31 * Access NodeBox from the command line: 
     40* Access NodeBox from the command line for very simple scripts: 
    3241 
    3342    from nodebox.console import make_movie 
  • nodebox/trunk/src/DrawingPrimitives.py

    r159 r175  
    66import nodebox.graphics.cocoa 
    77from nodebox.graphics.cocoa import * 
     8from nodebox.util import * 
    89 
    910__all__ = nodebox.graphics.cocoa.__all__ 
  • nodebox/trunk/src/nodebox/graphics/cocoa.py

    r159 r175  
    210210        if path is None: 
    211211            self._nsBezierPath = NSBezierPath.bezierPath() 
    212         elif isinstance(path, list): 
     212        elif isinstance(path, (list,tuple)): 
    213213            self._nsBezierPath = NSBezierPath.bezierPath() 
    214214            self.extend(path) 
     
    293293        self._segment_cache = None 
    294294        for el in pathElements: 
    295             self.append(el) 
     295            if isinstance(el, (list, tuple)): 
     296                x, y = el 
     297                if len(self) == 0: 
     298                    cmd = MOVETO 
     299                else: 
     300                    cmd = LINETO 
     301                self.append(PathElement(cmd, ((x, y),))) 
     302            elif isinstance(el, PathElement): 
     303                self.append(el) 
     304            else: 
     305                raise NodeBoxError, "Don't know how to handle %s" % el 
    296306 
    297307    def append(self, el): 
     
    480490            params = len(args) 
    481491 
    482         if params == 1 and isinstance(args[0], Color): 
     492        if params == 1 and args[0] is None: 
     493            clr = NSColor.colorWithDeviceWhite_alpha_(0.0, 0.0) 
     494        elif params == 1 and isinstance(args[0], Color): 
    483495            clr = args[0]._cmyk 
    484496        elif params == 1 and isinstance(args[0], NSColor): 
     
    15581570    def drawpath(self, path, **kwargs): 
    15591571        BezierPath.checkKwargs(kwargs) 
    1560         if isinstance(path, list): 
    1561             path = BezierPath(self, path, kwargs) 
     1572        if isinstance(path, (list, tuple)): 
     1573            path = self.BezierPath(path, **kwargs) 
    15621574        path.inheritFromContext(kwargs.keys()) 
    15631575        path.draw() 
  • nodebox/trunk/src/nodebox/util/__init__.py

    r159 r175  
    1 __all__ = ('grid', 'random', 'files', 'autotext') 
     1from random import choice 
     2 
     3__all__ = ('grid', 'random', 'choice', 'files', 'autotext') 
    24 
    35### Utilities ### 
  • nodebox/trunk/src/nodebox/util/vdiff.py

    r18 r175  
    145145        except: 
    146146            threshold = 0 
    147         statistics(fname1, fname2, threshold)      
     147        statistics(fname1, fname2, threshold) 
  • nodebox/trunk/src/tests/vdiff/tests.py

    r15 r175  
    11import os, glob 
    2 import vdiff 
     2from nodebox.util import vdiff 
    33 
    4 TEST_PATH = 'vdiff-tests' 
     4TEST_PATH = 'images' 
    55create_compare_image = True 
    66 
     
    2424<meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    2525<title>vdiff tests</title> 
    26 <link rel="stylesheet" type="text/css" href="vdiff-tests/vdiff.css" media="all"> 
     26<link rel="stylesheet" type="text/css" href="images/vdiff.css" media="all"> 
    2727</head> 
    2828<body> 
     
    5656fp.write(html) 
    5757fp.close() 
     58 
     59print "Generated test-results.html"