Changeset 9151 for src/django_gheat/website
- Timestamp:
- May 5, 2011, 11:13:51 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/tile.py
r9150 r9151 5 5 # Rick van der Zwet <info@rickvanderzwet.nl> 6 6 from django.core.management import setup_environ 7 from django.db.models import Max 7 8 from django.http import HttpResponse 8 9 from gheat.models import * … … 45 46 46 47 47 def add_circle(self, center, radius, colour=(255,0,0)): 48 # Quirky hack to generate lineair gradient circles and merge them with the parent. 48 def add_circle(self, center, radius, colour=(255,0,0), transparancy=0): 49 """ 50 Hack to add lineair gradient circles and merge with the parent. The 51 transparancy can be configured to make the circles to fade out in the 52 beginning 53 """ 54 # Make calculations and ranges a whole bunch more easy 55 radius = int(math.ceil(radius)) 56 49 57 new_surf = pygame.Surface(self.surf.get_size(),flags=pygame.SRCALPHA) 58 alpha_per_radius = float(2.55 * (100 - transparancy)) / radius 50 59 for r in range(radius,1,-1): 51 pygame.draw.circle(new_surf,colour + (255 - (r * (float(255)/radius)),),center,r,0) 60 alpha = (radius - r) * alpha_per_radius 61 pygame.draw.circle(new_surf,colour + (alpha,),center,r,0) 52 62 self.surf.blit(new_surf,(0,0),special_flags=pygame.BLEND_RGBA_MAX) 53 63 … … 182 192 latitude__lte=nw_deg.lat,latitude__gte=se_deg.lat, 183 193 longitude__lte=se_deg.lon,longitude__gte=nw_deg.lon) 194 195 # XXX: Signal is not normalized in the database making it unknown when a 196 # signal is said to be 100% or when it is actually less, currently seems to 197 # copy the raw reported values 198 MAX_SIGNAL = 50 184 199 185 200 def dif(x,y): … … 207 222 # different patterns. 208 223 # 209 im.add_circle((xcoord,ycoord),float(meting.signaal) / meters_per_pixel,(255,0,0) )224 im.add_circle((xcoord,ycoord),float(meting.signaal) / meters_per_pixel,(255,0,0),MAX_SIGNAL - meting.signaal) 210 225 211 226 log.info("BoundingBox NW: %s" % nw_deg)
Note:
See TracChangeset
for help on using the changeset viewer.