def tag(text, *args): if not args: TAG.add(text) else: name = args[0] more = tuple(args[1:]) if isinstance(name, list): name = name[0] more = tuple(args[0][1:]) with TAG(name): tag(text, *more)
def __call__(self): tests = [n for n, m in getmembers(self) if n.startswith("test_")] if self.github_format: self.github(tests) with open("README.md", "w") as html: print >> html, TAG.final() else: with TAG("html"): tag("HexTile Concepts", ["head", "title"]) with TAG("body"): self.github(tests) with open("HexTile.html", "w") as html: print >> html, TAG.final() return self
def __call__(self): tests = [n for n, m in getmembers(self) if n.startswith('test_')] if (self.github_format): self.github(tests) with open('README.md', 'w') as html: print >> html, TAG.final() else: with TAG('html'): tag('HexTile Concepts', ['head', 'title']) with TAG('body'): self.github(tests) with open('HexTile.html', 'w') as html: print >> html, TAG.final() return self
def github(self, tests): timestamp = datetime.now() human = '%A %B/%d/%Y %I:%M:%S %p' place = '%Y%m%d%H%M%S%f' with TAG('h3', align='center'): tag('HexTile Concepts') tag(timestamp.strftime(human), ['p', 'i']) tag(timestamp.strftime(place), ['p', 'i']) for test in tests: exec('self.%s()' % test) return self
def tagged(self): ini = """ var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000); var renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); camera.position.z = 2; camera.position.y = 1; camera.position.x = 1; var rotSpeed = 2e-3; function checkRotation() { var x = camera.position.x, y = camera.position.y, z = camera.position.z; camera.position.x = x * Math.cos(rotSpeed) + z * Math.sin(rotSpeed); camera.position.z = z * Math.cos(rotSpeed) - x * Math.sin(rotSpeed); camera.lookAt(scene.position); }; var render = function () { requestAnimationFrame(render); checkRotation(); renderer.render(scene, camera); }; render(); """ with TAG('html'): with TAG('head'): with TAG('style'): TAG.add("canvas { width: 100%; height: 100%; }\n") with TAG('body'): TAG.add(""" <div align="center"><big><big><big> Dendritic Tubulin (shared path) in One Retinal Bipolar Species </big></big></big><br /> <small><small><small> Copyright(c)2013-2015 Jonathan D. Lettvin, All Rights Reserved. </small></small></small> </div> <table align="center" border="1"><tr><td> <small><small><small> <ul> <li>The general shape is a paraboloid shell.</li> <li>Tubulin strand tips are at rectangular mesh vertices.</li> <li>Tubulin polymers are shown coursing from dendritic spines to axon.</li> <li>Each tubulin polymer is given a relatively unique color.</li> <li>Not shown here is a required tgv subset activating "selector".</li> </ul> </small></small></small> </td><td> <small><small><small> <ul> <li>Dendritic spines are represented by tiny green and red arrows.</li> <li>Dentritic spines act as tgvs (transient gradient vector sensors).</li> <li>green/red tgvs are oriented radially/axially.</li> <li>A sensed gradient becomes a signal that courses down a tubulin.</li> <li>Legacy Paraboloid2/Tubulin.py generates the raw data</li> <li><i>You need a WebGL-enabled browser to see this.</i></li> </ul> </small></small></small> </td></tr></table> """) with TAG('script', src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"): pass with TAG('script', src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r68/three.min.js"): pass with TAG('script'): self.tag_material('R', 0xff0000) self.tag_material('G', 0x00ff00) TAG.add(ini) for N, line in enumerate(self.line): self.tag_tubulin(N, line) TAG.add("render();\n") pass return TAG.final('<!doctype html>\n')
def tag_tubulin(self, L, line): mat = 'mat_%d' % (L) geo = 'geo_%d' % (L) seg = 'seg_%d' % (L) TAG.add('var %s = new THREE.LineBasicMaterial(' % (mat)) value = randint(0, 0xffffff) TAG.add(' {color: 0x%06x, linewidth: 3}' % (value)) TAG.add(');\n') TAG.add('var %s = new THREE.Geometry();\n' % (geo)) TAG.add('%s.vertices.push(' % (geo)) comma = '' for S, segment in enumerate(line): X, Y, Z = segment TAG.add('%snew THREE.Vector3(%f,%f,%f)' % (comma,X,Y,Z)) comma = ',' TAG.add(');\n') TAG.add('var %s = new THREE.Line(%s,%s);\n' % (seg, geo, mat)) TAG.add('scene.add(%s);\n' % (seg)) TAG.add('\n') point = line[0] self.tag_transientVectorSensors(L, geo, seg, point)
def tag_nl(self): TAG.add('\n')
def tag_transientVectorSensors(self, L, geo, seg, point, scale=2e-2): x, y, z = point N = sqrt(x**2+y**2) Rgeo = 'var R%s = new THREE.Geometry();\n' % (geo) Ggeo = 'var G%s = new THREE.Geometry();\n' % (geo) Rseg = 'seg_R%d' % (L) Gseg = 'seg_G%d' % (L) TAG.add(Rgeo+Ggeo+'\n') TAG.add('R%s.vertices.push(' % (geo)) TAG.add('new THREE.Vector3(%f,%f,%f)' % (x,y,z)) TAG.add(',new THREE.Vector3(%f,%f,%f)' % (x,y,z+scale)) TAG.add(');\n') XN, YN = scale*x/N, scale*y/N TAG.add('G%s.vertices.push(' % (geo)) TAG.add('new THREE.Vector3(%f,%f,%f)' % (x,y,z)) TAG.add(',new THREE.Vector3(%f,%f,%f)' % (x+XN,y+YN,z)) TAG.add(');\n') TAG.add('var R%s = new THREE.Line(R%s,Rmat);\n' % (seg, geo)) TAG.add('scene.add(R%s);\n' % (seg)) TAG.add('var G%s = new THREE.Line(G%s,Gmat);\n' % (seg, geo)) TAG.add('scene.add(G%s);\n' % (seg))
def tag_material(self, c, h): TAG.add('var %cmat = new THREE.LineBasicMaterial(' % (c)) TAG.add('{color: 0x%06x, linewidth: 3}' % h) TAG.add(');\n')