def draw(self, x, y, w=40, h=40): try: from web import _ctx except: pass from nodebox.graphics import RGB for r,g,b in self: _ctx.colormode(RGB) _ctx.fill(r,g,b) _ctx.rect(x, y, w, h) x += w
def draw(self, x, y, w=40, h=40): try: from web import _ctx except: pass from plotdevice.grobs import RGB for r,g,b in self: _ctx.colormode(RGB) _ctx.fill(r,g,b) _ctx.rect(x, y, w, h) x += w
def preview(theme): try: from web import _ctx except: pass # Use the darkest swatch as background. r, g, b = theme.darkest c = _ctx.color(r, g, b) c.brightness *= 0.5 c.brightness = max(0.1, c.brightness) c.brightness = 0.15 _ctx.background(c) #_ctx.background(0.1) from random import random, choice for i in range(100): r, g, b = choice(theme) _ctx.fill(r, g, b) r, g, b = choice(theme) _ctx.stroke(r, g, b) _ctx.strokewidth(random() * 30) r = random() * 100 _ctx.oval(random() * 400, random() * 400, r, r) # Draw swatches. _ctx.nostroke() theme.draw(20, 480) # Theme info colored in the lightest swatch. r, g, b = theme.lightest _ctx.fontsize(18) _ctx.fill(r, g, b) _ctx.text(theme.label + u" | " + str(theme.id), 20, 540) _ctx.fontsize(_ctx.fontsize() / 2) _ctx.text(", ".join(theme.tags), 20, 555, width=400) #web = ximport("web") #size(500, 650) #themes = search("office") #theme = themes[0] #preview(theme)
def preview(theme): try: from web import _ctx except: pass # Use the darkest swatch as background. r,g,b = theme.darkest c = _ctx.color(r, g, b) c.brightness *= 0.5 c.brightness = max(0.1, c.brightness) c.brightness = 0.15 _ctx.background(c) #_ctx.background(0.1) from random import random, choice for i in range(100): r,g,b = choice(theme) _ctx.fill(r,g,b) r,g,b = choice(theme) _ctx.stroke(r,g,b) _ctx.strokewidth(random()*30) r = random()*100 _ctx.oval(random()*400, random()*400, r, r) # Draw swatches. _ctx.nostroke() theme.draw(20, 480) # Theme info colored in the lightest swatch. r,g,b = theme.lightest _ctx.fontsize(18) _ctx.fill(r,g,b) _ctx.text(theme.label + u" | " + str(theme.id), 20, 540) _ctx.fontsize(_ctx.fontsize()/2) _ctx.text(", ".join(theme.tags), 20, 555, width=400) #web = ximport("web") #size(500, 650) #themes = search("office") #theme = themes[0] #preview(theme)