From 2bee32f97dd4cb4902b0da3ecba8a5f74cb7c251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kom=D1=8Fpa?= Date: Fri, 16 Jul 2010 12:11:53 +0300 Subject: [PATCH] Support for prop() in eval() --- src/mapcss/StyleChooser.py | 11 +++++++++-- src/mapcss/webcolors/webcolors.py | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mapcss/StyleChooser.py b/src/mapcss/StyleChooser.py index 8ba2afa..c25a435 100644 --- a/src/mapcss/StyleChooser.py +++ b/src/mapcss/StyleChooser.py @@ -18,6 +18,7 @@ from Rule import Rule from webcolors.webcolors import whatever_to_cairo as colorparser +from webcolors.webcolors import cairo_to_hex from Eval import Eval class StyleChooser: @@ -88,14 +89,20 @@ class StyleChooser: ## // Update StyleList object_id = 1 - + for r in self.styles: ### FIXME: here we should do all the eval()'s ra = {} for a,b in r.iteritems(): if __builtins__["type"](b) == self.eval_type: + combined_style = {} + for t in sl: + combined_style.update(t) + for p,q in combined_style.iteritems(): + if "color" in p: + combined_style[p] = cairo_to_hex(q) ## FIXME: properties && metrics - b = b.compute(tags,{}, scale, zscale) + b = b.compute(tags,combined_style, scale, zscale) ra[a] = b r = ra ra = {} diff --git a/src/mapcss/webcolors/webcolors.py b/src/mapcss/webcolors/webcolors.py index 09322dd..68d22fa 100644 --- a/src/mapcss/webcolors/webcolors.py +++ b/src/mapcss/webcolors/webcolors.py @@ -851,7 +851,8 @@ def whatever_to_rgb(string): def whatever_to_cairo(string): a = whatever_to_rgb(string) return a[0]/255.,a[1]/255.,a[2]/255., - +def cairo_to_hex (cairo): + return rgb_to_hex((cairo[0]*255,cairo[1]*255,cairo[2]*255,))