Exemplo n.º 1
0
def _getLenColor(a):
	rcent = 0 
	gcent = .5
	bcent = 1.0
	if a <= gcent:
		ptr = a/gcent
		col = _linterp( array((1.0, 0.0, 0.0)), array((0.0, 1.0, 0.0)), ptr)
	elif a > gcent:
		ptg = (a-gcent)/bcent
		col = _linterp( array((0.0, 1.0, 0.0)), array((0.0, 0.0, 1.0)), ptg)
	col = vnorm(vnorm(col)**.6)
	return tuple(col)
Exemplo n.º 2
0
def showColorWheel(cv):
	if "colorwheel" in cv.graph.plots:
		del(cv.graph.plots['colorwheel'])
	fp = cv.graph.frontPlane()
	cent = fp[0]+.9*fp[1]+.9*fp[2]
	cent = cent + .1*cv.graph.forward
	rad = cv.graph.up*.05*min(vnorm(fp[1], False), vnorm(fp[2], False))
	# cent = fp[0]+.5*fp[1]+.5*fp[2] +.1*cv.graph.forward
	# rad = cv.graph.up*.5*vnorm(fp[1], False)
	sang = 0
	aw = pi/48
	dl=glGenLists(1)
	glNewList(dl, GL_COMPILE)
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
	while(sang < 2*pi):
		nrad = rotateAround(rad, cv.graph.forward, aw)
		col = _getAngleColor(sang+aw/2)
		sang+=aw
		glBegin(GL_POLYGON)
		materialColor(col)
		glVertex3fv(cent+.5*rad)
		glVertex3fv(cent+rad)
		glVertex3fv(cent+nrad)
		glVertex3fv(cent+.5*nrad)
		glEnd()
		rad=nrad
	# cent = cent -.1*cv.graph.forward
	# for ang in [30, 45, 115, 150]:
	# 	a1 = ang*pi/180
	# 	rad = cv.graph.up*.05*min(vnorm(fp[1], False), vnorm(fp[2], False))
	# 	rad1 = rotateAround(rad, cv.graph.forward, a1)
	# 	a2 = 2*pi - a1
	# 	rad2 = rotateAround(rad, cv.graph.forward, a2)
	# 	materialColor((.1, .1, .1))
	# 	glLineWidth(2.0)
	# 	glBegin(GL_LINES)
	# 	glVertex3fv(cent)
	# 	glVertex3fv(cent+rad1)
	# 	glVertex3fv(cent)
	# 	glVertex3fv(cent+rad2)
	# 	glEnd()
	glEndList()
	cv.graph.addCustomDisplayList(dl, name="colorwheel")
	cv.graph.OnDraw()
Exemplo n.º 3
0
def _getAngleColor(a):
	# rcent = pi/4
	# gcent = 5*pi/4
	# bcent = 7*pi/4
	rcent = 0 + pi/6
	gcent = 2*pi/3 +pi/6
	bcent = 4*pi/3 +pi/6
	if a <= rcent or a >= bcent:
		rr = (2*pi - bcent)
		ptr = ((a+rr) % (2*pi))/(rcent+rr)
		col = _linterp( array((0.0, 0.0, 1.0)), array((1.0, 0.0, 0.0)), ptr)
	elif a<= gcent:
		a = a - rcent
		gcent = gcent - rcent
		ptg = a/gcent
		col = _linterp( array((1.0, 0.0, 0.0)), array((0.0, 1.0, 0.0)), ptg)
	else:
		a = a - gcent
		bcent = bcent - gcent
		ptb = a/bcent
		col = _linterp( array((0.0, 1.0, 0.0)), array((0.0, 0.0, 1.0)), ptb)
	col = vnorm(vnorm(col)**.6)
	#col = col/col.max()
	return tuple(col)
Exemplo n.º 4
0
def lunimanceByMeta(cv):
	tags=set([])
	for e in cv.getVisible():
		for k in e.getInheritedAttributes():
			if k.startswith("meta_"):
				tags.add(k)
	d = [{"Name":"Which Tag",
			"Type":"List",
			"Value":list(tags)},
		{"Name":"Min Value",
		"Value":0.0},
		{"Name":"Max Value",
		"Value":100.0}]
	l = cv.askParam(d)
	if not l:
		return
	vals = [e.attrib(l[0], True) for e in cv.getVisible()]
	vals = _castVals(vals)
	for e in cv.getVisible():
		v = e.attrib(l[0], True)
		v = vals[v]
		v = (v - l[1])/(l[2]-l[1])
		c = e.attrib('color', True) or (255, 255, 255)
		c=convertColor(c, 'gl')
		c2 = 3*vnorm(array(c))
		if not any(isnan(c2)):
			c = c2
		else:
			c = array(c)
		c = tuple(c*v)
		pycol=convertColor(c, 'py')
		e.setAttrib('color', pycol)
		pn=cv.getPlotName(e)
		cv.graph.plots[pn]['color']=c
		cv.graph.recalc(pn)
	cv.graph.OnDraw()