new classes from rukano, see docs

This commit is contained in:
redlock 2011-03-14 22:47:18 +01:00
parent c7e0435862
commit 37928569ba
10 changed files with 139 additions and 6 deletions

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Image</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Image&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Image from file</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, file, x, y, color, size, orientation)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw()</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the image<br></BODY></HTML>

View File

@ -1 +1 @@
<HTML><HEAD><TITLE>Line</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw a line</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, x, y, tx, ty)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i></BODY></HTML>
<HTML><HEAD><TITLE>Line</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; draw a line</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, x, y, tx, ty, color) -- wats the dealio for polylines?</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw(width, style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the line<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Point</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Point&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is a point</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, x, y, color, size, style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw()</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the point<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Polygon</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Polygon&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; some vertice stuff</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, vertices, color, style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw(style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the polygon<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Rect</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Rect&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is a rectangle</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, x, y, width, height, color, style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw(style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the rectangle<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Sequencer</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Sequencer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a simple Sequencer with callback functions on every beat, bar or phrase</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self,bpm, timeSig, phraseLength)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update(dt)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;counts the time and calls the appropriate functions<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Text</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; characters</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, x, y, text, rotation, scaleX, scaleY)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw(text)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display text on screen<br></BODY></HTML>

View File

@ -0,0 +1 @@
<HTML><HEAD><TITLE>Triangle</TITLE><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9d1c12}p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}span.s1 {font: 18.0px Helvetica}span.s2 {color: #0026b4}span.Apple-tab-span {white-space:pre}</style></HEAD><BODY><h3>Triangle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; has three sides</h3><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function(self, vertices, color, style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i> Constructor</i><h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw(style)</h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw the triangle<br></BODY></HTML>

View File

@ -32,6 +32,7 @@ local upack = vstruct.unpack
osc.client = {}
osc.client.host = "localhost"
osc.client.ip = nil
osc.client.port = 57110
osc.client.timeout = 0
@ -43,7 +44,7 @@ IMMEDIATE = string.rep('0', 31) .. '1'
function osc.client:send( data )
local ip, port = assert(socket.dns.toip(osc.client.host)), osc.client.port
local ip, port = osc.client.ip or assert(socket.dns.toip(osc.client.host)), osc.client.port
-- create a new UDP object
local udp = assert(socket.udp())
udp:settimeout(0)

View File

@ -178,7 +178,6 @@ end
Circle = Class(function(self, x, y, r, s, color)
self.r = r or 10
self.s = s or 16
self.color = color
-- call constructor of Drawable
Drawable.construct(self,x,y,color)
end)
@ -252,7 +251,7 @@ end
--[[
POINT
--]]
-- @Point
-- @Point: is a point
Point = Class(function(self, x, y, color, size, style)
local color=color or ""
local size=size or 1
@ -279,7 +278,7 @@ end
--[[
Sequencer
--]]
--@Sequencer: a simple Sequencer with callback functions on every beat, bar or phrase
Sequencer = Class(function(self,bpm, timeSig, phraseLength)
self.timer = 0
self.frame = 0
@ -299,6 +298,7 @@ Sequencer = Class(function(self,bpm, timeSig, phraseLength)
end)
Sequencer:inherit(Object)
-- #counts the time and calls the appropriate functions
function Sequencer:update(dt)
self.timer = self.timer + dt
self.frame = self.frame + 1
@ -319,9 +319,134 @@ function Sequencer:update(dt)
end
end
end
--[[
POLYGON
--]]
-- @Polygon: some vertice stuff
Polygon = Class(function(self, vertices, color, style)
local color=color or {255,255,255,255}
self.style = style or "line"
-- todo: ask for odd/even number of table
if type(vertices) ~= "table" then
print("vertices has to be a even table!")
end
self.vertices = vertices
-- first vertice = x, y
local x=vertices[1]
local y=vertices[2]
-- TODO: compute center
-- call constructor of Drawable
Drawable.construct(self,x,y,color)
end)
Polygon:inherit(Drawable)
-- #draw the polygon
function Polygon:draw(style)
local style=style or self.style
love.graphics.setColor(unpack(self.color))
love.graphics.polygon(style, self.vertices)
end
--[[
RECT
--]]
-- @Rect: is a rectangle
Rect = Class(function(self, x, y, width, height, color, style)
local color=color or {255,255,255,255}
self.style = style or "line"
self.width = width
self.height = height
-- TODO: compute center
-- call constructor of Drawable
Drawable.construct(self,x,y,color)
end)
Rect:inherit(Drawable)
-- #draw the rectangle
function Rect:draw(style)
local style=style or self.style
love.graphics.setColor(unpack(self.color))
love.graphics.rectangle(style, self.position.x, self.position.y, self.width, self.height)
end
--[[
TRIANGLE
--]]
-- @Triangle: has three sides
Triangle = Class(function(self, vertices, color, style)
local color=color or {255,255,255,255}
self.style = style or "line"
-- todo: ask for 6 number of table
if type(vertices) ~= "table" then
print("vertices has to be a even table!")
end
self.vertices = vertices
-- first vertice = x, y
local x=vertices[1]
local y=vertices[2]
-- TODO: compute center
-- call constructor of Drawable
Drawable.construct(self,x,y,color)
end)
Triangle:inherit(Drawable)
-- #draw the triangle
function Triangle:draw(style)
local style=style or self.style
love.graphics.setColor(unpack(self.color))
love.graphics.triangle(style, unpack(self.vertices))
end
--[[
TEXT
--]]
-- @Text: characters
Text = Class(function(self, x, y, text, rotation, scaleX, scaleY)
local color=color or {255,255,255,255}
self.text=text or "LICK WITH LOVE"
self.rotation=rotation or 0
self.scaleX = scaleX or 1
self.scaleY = scaleY or 1
self.font = "implement fonts?..."
-- TODO: compute center
-- call constructor of Drawable
Drawable.construct(self,x,y,color)
end)
Text:inherit(Drawable)
-- #display text on screen
function Text:draw(text)
local text = text or self.text
love.graphics.setColor(unpack(self.color))
love.graphics.print(
text,
self.position.x,
self.position.y,
self.rotationr,
self.scaleX,
self.scaleY
)
end
-- EXAMPLE:
-- (put in love.load):
-- coco = Circle(300,300)