Ignore:
Timestamp:
Apr 29, 2012, 7:59:27 PM (13 years ago)
Author:
rick
Message:

Weed out whole bunch of unused code, to avoid huge dependency listing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/wlheatmap/tile.py

    r9662 r10615  
    1616import time
    1717
    18 # Rending with PIL and computation with numpy has proven to be to slow to be
    19 # usable, but is still in here for refence purposes.
    20 try:
    21   from PIL import Image
    22   import ImageDraw
    23   import numpy as np
    24 except ImportError:
    25   pass
    2618
    2719class PyGamePicture():
     
    7062      pygame.draw.circle(new_surf,combined_colour,center,r,0)
    7163    self.surf.blit(new_surf,(0,0),special_flags=pygame.BLEND_RGBA_MAX)
    72 
    73 
    74 class PILPicture():
    75   """ Basic PIL class, allowing simple image manipulations """
    76   im = None
    77   def __init__(self, method, size):
    78     self.im = Image.new(method, size)
    79     self.data = np.array(self.im)
    80 
    81   def write(self,fh,format='png'):
    82         self.im.save(fh,format)
    83 
    84   def make_circle(self,draw, center, radius,colour=(0,255,0)):
    85     """ Cicle gradient is created by creating smaller and smaller cicles """
    86     (center_x, center_y) = center
    87     for i in range(0,radius):
    88       draw.ellipse(
    89         (center_x - radius + i,
    90          center_y - radius + i,
    91          center_x + radius - i,
    92          center_y + radius - i
    93         ),
    94         colour +(255 * i/(radius * 2),)
    95       )
    96 
    97   def add_circle(self, center, radius, colour):
    98     """ Adding a new cicle is a matter of creating a new one in a empty layer
    99     and merging it with the current one
    100 
    101     XXX: Very heavy code, should actually only work on the data arrays, instead
    102     of doing all the magic with high-level images """
    103 
    104     im_new = Image.new("RGBA", self.im.size)
    105     draw = ImageDraw.Draw(im_new)
    106     self.make_circle(draw, center, radius, colour)
    107    
    108     data2 = np.array(im_new)
    109    
    110     # Add channels to make new images
    111     self.data = self.data + data2
    112     self.im = Image.fromarray(self.data)
    113 
    11464
    11565
Note: See TracChangeset for help on using the changeset viewer.