コード例 #1
0
def draw():
	p5.colorMode(p5.RGB)
	p5.background(0)

	if len(projection):
		p5.pushMatrix()
		p5.colorMode(p5.HSB)
		p5.translate(width/4, height/4)
		p5.scale(width/2, height/2)
		for point, label in zip(projection, labels):
			p5.stroke(p5.color(label * 26., 255, 255))
			p5.point(point[0], point[1])			

		p5.popMatrix()
        #send osc to MaxPatch
		probability_lda = model.predict_proba([getAmplitude(recent)])
		send_osc_message("/lda",probability_lda)

		probability_svc = clf.predict_proba([getAmplitude(recent)])
		send_osc_message("/svm",probability_svc)

		cur = model.transform([getAmplitude(recent)])
		cur = cur[0]
		cur = (cur - p_min) / (p_max - p_min)
		global predicted
		if predicted == None:
			predicted = cur
		else:
			predicted = predicted * .9 + cur * .1
		p5.stroke(p5.color(0, 0, 255))
		p5.ellipse(width/4 + predicted[0] * width/2, height/4 + predicted[1] * height/2, 10, 10)

	elif len(recent):
		# draw time-amplitude
		p5.pushMatrix()
		p5.translate(0, height/2)
		p5.scale(width / N, height/2)
		p5.stroke(255)
		p5.noFill()
		p5.beginShape()
		for x, y in enumerate(recent):
			p5.vertex(x, y)
		p5.endShape()
		p5.popMatrix()

		# draw frequency-amplitude
		amp = getAmplitude(recent)
		p5.pushMatrix()
		p5.translate(0, height)
		p5.scale(width, -height)
		p5.stroke(255)
		p5.noFill()
		p5.beginShape()
		for x, y in enumerate(amp):
			p5.vertex(math.log(1+x, len(amp)), pow(y, .5))
		p5.endShape()
		p5.popMatrix()
コード例 #2
0
ファイル: square_limit-4.py プロジェクト: MoMaT/slides
def rot45(f):
	p.rotate(-math.pi / 4)
	p.scale(1 / math.sqrt(2))
コード例 #3
0
ファイル: square_limit-3.py プロジェクト: MoMaT/slides
def flip(f):
	p.translate(240, 0)
	p.scale(-1, 1)
コード例 #4
0
ファイル: square_limit-6.py プロジェクト: MoMaT/slides
def beside(f, g):
	p.scale(0.5, 1)
	f()
	p.translate(240, 0)
コード例 #5
0
ファイル: square_limit-6.py プロジェクト: MoMaT/slides
def above(f, g):
	p.scale(1, 0.5)
	f()
	p.translate(0, 240)
コード例 #6
0
ファイル: square_limit-9.py プロジェクト: MoMaT/slides
def beside(*args):
	scale = 1.0 / len(args)
	p.scale(scale, 1)
	for f in args[:-1]:
		f()
		p.translate(240, 0)
コード例 #7
0
ファイル: square_limit-9.py プロジェクト: MoMaT/slides
def above(*args):
	scale = 1.0 / len(args)
	p.scale(1, scale)
	for f in args[:-1]:
		f()
		p.translate(0, 240)
コード例 #8
0
ファイル: square_limit-9.py プロジェクト: MoMaT/slides
#!/usr/bin/evn python
# coding=utf-8
"""
Composition. Square Limit.

"""
import math
import pyprocessing as p

p.size(800, 800)
p.background(255)
p.scale(3.3)

img = p.loadImage("fish.png")

def fish():
	p.image(img, -80, -80)

def blank():
	pass

def transform(t, *args):
	def wrapper(*args):
		def wrapped_f():
			p.pushMatrix()
			t(*args)  # perform transformation t
			args[-1]()  # call last argument as function
			p.popMatrix()
		return wrapped_f
	return wrapper