1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Line numbering and coordinates.

Posted by Gabra on May 24, 2008

A field with line numbers would be nice.
A small field that shows the coordinates of the mouse when it is in the output area would also improve the application.

Thanks for a very nice project.


 
Posted by Gaston on May 25, 2008

Yes, line numbers would be great!



Posted by anonymous on May 25, 2008

I totally agree with both suggestions.



Posted by mdk on Jun 02, 2008

yes line numbers would definitely be great, and mouse coordinates would definitely help, no more guessing where to place elements and would certainly help with debugging



Posted by Edwin on Jun 02, 2008

If you use no rotations and translations, I guess you could draw a semi-transparant grid yourself...
Then just turn it off when you're finished.



Posted by ideambulate on Jun 06, 2008

Here's a possible temporary solution. It has some handy options for making flexible or square grids, showing position-numbers, and so forth.

def alignmentgrid(vsplits=3,hsplits=3,alpha=0.4,numbers=False,square=False,draw=True):
    '''This function produces a simple grid of lines, intended to help users
    position their objects.  Returns a path object describing the grid.
    
     The vsplits argument sets how many width-divisions you want to break your canvas into
     
     The hsplits argument sets how many height-divisions you want to break your canvas into
     
     The alpha argument sets the alpha of the overlay path, between 0.0 and 1.0
     
     The numbers argument, a boolean, toggles numerical visual aides.
     
     The square argument forces the grid to have square components, normalizing
     based on the smallest grid-rectangle dimension that would normally have been produced
     
     The draw argument, a boolean, determines whether or not to draw the grid before returning.'''
    
    # Makes certain arguments are in a useful range.
    if hsplits < 1 or hsplits > HEIGHT:
        hs = 1
    else:
        hs = hsplits
        
    if vsplits < 1 or vsplits > WIDTH:
        vs = 1
    else:
        vs = vsplits
        
    if alpha > 1:
        a = 1.0
    elif alpha < 0:
        a = 0.0
    else:
        a = alpha
    
    # Determine the compartment sizes
    hc = HEIGHT*1.0 / hs
    vc = WIDTH*1.0 / vs
    
    if square and hc != vc:
        if hc < vc:
            vc = hc
            vs = int(WIDTH/vc +1)
        else:
            hc = vc
            hs = int(HEIGHT/hc +1)
    
    
    
    push()
    stroke(None)
    fill(0,a)
    
    # Build the grid path
    gridpath = None
    for x in range(1,vs+1):
        r = rect(vc*x,0,1,HEIGHT,draw=False)
        if gridpath:
            gridpath = gridpath.union(r)
        else:
            gridpath = r
            
    for y in range(1,hs+1):
        r = rect(0,hc*y,WIDTH,1,draw=False)
        if gridpath:
            gridpath = gridpath.union(r)
        else:
            gridpath = r
    
    
 
    # Add text numbers for reference, if desired.
    if numbers:
        fontsize(8)
        font("Courier")   
        for x,y in grid(vs+1,hs+1,vc,hc):
            t = '('+str(int(x))+','+str(int(y))+')'
            if y == 0:
                text(t,x,y+8,WIDTH)
            else:
                text(t,x,y,WIDTH)
 
    
    # Draw it, if desired.
    if draw:
        drawpath(gridpath)
        
    return gridpath
    pop()



Posted by Edwin on Jun 07, 2008

Cool!