def get_default_style(argon): return layout.default.inherit( renderer = renderer, background = None, background_color = rgba(255, 255, 255), font = argon.default_font, color = rgba(255, 255, 255), align = layout.Align(0, 0), )
def render_overlay(self, argon): argon.clear(rgba(0,0,0,0)) argon.render_rectangle(self.intron.rect, box7, color = rgba(0x00, 0x00, 0xFF, 0x80)) mark = rgba(0x00, 0x00, 0xFF) if isinstance(self.mutator, Selection): start, stop = self.mutator.start, self.mutator.stop for box in self.intron.references(): if box.in_range(start, stop): rect = box.selection_marker(start, stop) argon.render_rectangle(rect, color=mark)
def __init__(self, argon, font): self.argon = argon self.default = layout.default.inherit( font = font, background = None, color = rgba(0xf6, 0xf3, 0xe8), spacing = 10, ) self.namecolor = self.default.inherit( color = rgba(0xe5, 0x78, 0x6d), ) self.unknown_list = self.default.inherit( background = (argon.patch9('border.png'), rgba(0x24, 0x24, 0x24)), padding = (5,5,5,5), spacing = 0, )
def on_frame(now): argon.render.bind() argon.clear(rgba(0x30, 0x30, 0x30)) frame.render(argon) #argon.render.rectangle((0,0, 200, 200), box7) argon.show_performance_log() argon.render.unbind()
def draw(self, argon): out = [] rect = pad(self.intron.rect, (7,7,7,7)) white = rgba(255,255,255) out.extend([ (rect, white, argon.patch9('marker.png')) ]) out.extend(selection(self.intron, rgba(0x80,255,255,0x80), argon.plain, self.start, self.stop)) out.extend(selection(self.intron, white, argon.plain, self.head, self.head)) font = self.root.font width, height = argon.resolution out.extend([ ((0,0,width,font.height*1.2), rgba(0,0,0), argon.plain), ((0,font.baseline), "-- list input --", rgba(0x80, 0x80, 0x80), font), ]) argon.render(out)
def render_overlay(self, argon): argon.clear(rgba(0,0,0,0)) slot = find_slot(main_frame.contents, self.sel.struct, self.sel.index) if slot is not None: argon.render_rectangle(slot.rect, box7, color = rgba(32, 32, 255, 128)) if slot is not None and isinstance(self.sel, Selection): head = self.sel.head start, stop = self.sel.start, self.sel.stop for box in slot.references(): if box.in_range(start, stop): rect = box.selection_marker(start, stop) argon.render_rectangle(rect, color = rgba(0, 0, 255, 128)) if box.in_range(head, head): rect = box.selection_marker(head, head) argon.render_rectangle(rect, color = rgba(255, 255, 255, 255)) if slot is None: argon.render_rectangle((0,0,main_frame.width, main_frame.height), box7, color = rgba(255, 255, 0, 192))
def draw(self, argon): out = [] rect = pad(self.intron.rect, (7,7,7,7)) white = rgba(255,255,255) out.extend([ (rect, white, argon.patch9('marker.png')) ]) for intron in self.intron.subintrons(): if intron.index == self.which: rect = pad(intron.rect, (7,7,7,7)) out.append((rect, rgba(255,255,0), argon.patch9('marker.png'))) font = self.root.font width, height = argon.resolution out.extend([ ((0,0,width,font.height*1.2), rgba(0,0,0), argon.plain), ((0,font.baseline), "-- struct input --", rgba(0x80, 0x80, 0x80), font), ]) argon.render(out)
def on_frame(now): ## reload visualizer if it changed. if argon.previous_sys_check + 2.0 < now: if load_visualizer(langtype, at_reload=True): print 'trying to reload visualizer' main_frame.contents = visualizer(document) main_frame.dirty = True argon.previous_sys_check = now argon.clear(rgba(0x80, 0x90, 0xA0)) main_frame.render(argon)
def update(self, argon): texture = self.texture if texture.width != self.width or texture.height != self.height: texture.resize(self.width, self.height) self.framebuffer.bind() argon.use_program((self.width, self.height)) argon.clear(rgba(0x30,0x30,0x30)) self.contents.measure(None) self.contents.arrange(None, self.scroll) self.contents.render(argon) argon.use_program(argon.resolution) self.framebuffer.unbind()
def on_frame(time): width, height = argon.resolution hw = width / 2 hh = height / 2 argon.clear(rgba(0x40, 0x40, 0x40)) frame.render(argon) x, y = argon.pos argon.render_rectangle((x-32, y-32, 64, 64), circle64, color=rgba(0x1,0x0,0,0x80)) if argon.average_latency > 0: argon.render_text( (0, height - font.height + font.baseline), "FPS %.2f" % (1.0 / argon.average_latency), font ) argon.render_text( (200, height - font.height + font.baseline), get_str(frame.mode.mutator), font, )
#!/usr/bin/env python2 import sys, os from argon import Argon, rgba from frame import Frame, Overlay, LayoutController from schema import mutable, fileformat_flat import layout import renderer green = rgba(0x95, 0xe4, 0x54) cyan = rgba(0x8a, 0xc6, 0xf2) red = rgba(0xe5, 0x78, 0x6d) lime = rgba(0xca, 0xe6, 0x82) gray = rgba(0x99, 0x96, 0x8b) whiteish = rgba(0xf6, 0xf3, 0xe8) class default_theme(object): background = rgba(0x24, 0x24, 0x24) symbol_color = whiteish keyword_color = cyan string_color = lime number_color = red object_color = gray malform_color = red theme = default_theme filename = (sys.argv[1] if len(sys.argv) > 1 else 'scratch.flat') if os.path.exists(filename): document = fileformat_flat.load_file(filename, mutable) else: document = mutable.Document([])
if background: argon.render_rectangle(node.rect, background, color) if isinstance(node, layout.Label): font = node.style['font'] argon.render_text( node.baseline_pos, node.source, font, color, ) default = layout.default.inherit( font = font, renderer = sys_renderer, background = None, color = rgba(255,255,255), spacing = 7, ) struct_style = default.inherit( background = box7, padding = (14,14,14,14), ) red_style = default.inherit( color = rgba(255,0,0) ) yellow_style = default.inherit( color = rgba(128,128,0) ) def refresh(intron):
from argon import rgba from box import Box blackish = rgba(0x00, 0x00, 0x00, 0x40) whiteish = rgba(0xf6, 0xf3, 0xe8) blueish = rgba(0x00, 0xf3, 0xe8, 0x80) def clamp(low, high, value): return min(high, max(low, value)) class Segment(object): def __init__(self, width, text): self.width = width self.text = text def line_break(width, words, space_width): table = [(0.0, 0)] for stop in range(1, len(words)+1): start = stop - 1 c = words[start].width best = (width-c)**2.0 + table[start][0], start start -= 1 while start >= 0 and c <= width: c += words[start].width + space_width p = (width-c)**2.0 + table[start][0] if p <= best[0] and c <= width: best = p, start start -= 1 table.append(best) lines = [] j = len(words) while j > 0:
from argon import hsva, rgba from box import Box white = rgba(255,255,255) black = rgba(0,0,0) class Colorpicker(Box): def __init__(self, argon): self.hue = 0.0 self.saturation = 0.0 self.value = 1.0 self.gradient = argon.image('hue-saturation-360x256.png') Box.__init__(self, 0, 0, 480+20, 256+20) self.which = -1 @property def rgba(self): return hsva(self.hue, self.saturation, self.value).rgba def update(self): self.major = Box(self.left+10+0, self.top+10, 360, 256) self.minor = Box(self.left+10+360, self.top+10, 30, 256) self.preview = Box(self.left+10+390, self.top+10, 90, 256) def render(self, argon): self.update() v1 = hsva(self.hue, self.saturation, 1.0).rgba x0, y0 = self.major.interpolate((self.hue/360.0, self.saturation)) x1, y1 = self.minor.interpolate((0, 1-self.value)) argon.render([ (self.rect, black, argon.plain), (self.major.rect, white.mix(black, self.value), self.gradient),
from frame import Frame, Overlay from schema.base import Constant, Struct from schema import proxy, analyzer from schema.mutator import Mutator from schema.selection import Selection, BufferSelection, StringSelection, ListSelection from schema.language import language, Synthetizer from schema.flatfile import load_file, save_file from navigation import * import macron import layout import os, sys def in_module(path): return os.path.join(os.path.dirname(__file__), path) background_color = rgba(0x24, 0x24, 0x24) green = rgba(0x95, 0xe4, 0x54) cyan = rgba(0x8a, 0xc6, 0xf2) red = rgba(0xe5, 0x78, 0x6d) lime = rgba(0xca, 0xe6, 0x82) gray = rgba(0x99, 0x96, 0x8b) back = rgba(0x24, 0x24, 0x24) whiteish = rgba(0xf6, 0xf3, 0xe8) class DefaultTheme(object): pass mode = None def set_mode(new_mode): global mode