예제 #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
def draw():
    stroke_cap(1)
    line(10, 10, 50, 10)
    point(70, 10)

    stroke_cap(2)
    line(10, 30, 50, 30)
    point(70, 30)

    stroke_cap(4)
    line(10, 50, 50, 50)
    point(70, 50)
예제 #3
0
파일: pattern.py 프로젝트: MoMaT/slides
#!/usr/bin/evn python
# coding=utf-8
"""
Pattern.

"""
import pyprocessing as p

p.size(255, 255)

for x in range(256):
	for y in range(256):
		colour = x ^ y
		p.stroke(colour)
		p.point(x, y)

p.run()


"""
^ is bitwise exclusive or (xor)

0 ^ 0 = 1 ^ 1 = 0
1 ^ 0 = 0 ^ 1 = 1

Example: 100101 ^ 101001 = 001100

"""
	def render(self):
		p.stroke(0)
		p.point(self.x, self.y)