Ejemplo n.º 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()
Ejemplo n.º 2
0
def setup():
	p.size(SIZE, SIZE)
	p.background(0)
	p.colorMode(p.HSB, 360, 100, 100)
Ejemplo n.º 3
0
def setup():
	p.size(400, 400)
	p.colorMode(p.HSB, 360, 100, 100)
	p.fill(30, 100, 100)
	p.noStroke()
	p.noLoop()
Ejemplo n.º 4
0
def setup():
    p.size(600, 200)
    p.colorMode(p.HSB, 360, 100, 100)
    p.noStroke()
    add(random.randint(0, 600), random.randint(0, 200))
Ejemplo n.º 5
0
#!/usr/bin/evn python
# coding=utf-8
"""
Rings.

"""
import math
import random
import pyprocessing as p

COLOURS = [(45,25,100), (345,50,65), (10,60,90), (30,50,100)]

p.size (600, 200)
p.colorMode(p.HSB, 360, 100, 100)
p.noStroke()

def rings():
	p.background(292, 40, 30)

	for i in range(30):
		x = random.randint(0, 600)
		y = random.randint(0, 200)
		n = random.randint(3, 30)
		radius = random.randint(10, 100)
		size = random.randint(3, 15)
		colour = random.choice(COLOURS)

		p.fill(*colour)
		for i in range(n):
			angle = i * 2*math.pi / n
			new_x = x + math.cos(angle) * radius