Permalink
Browse files

Revert "WARNING API CHANGE: now alpha parameter in fill() function is…

… a number between 0 and 255 as well."

This reverts commit 0e4fca8.
  • Loading branch information...
1 parent 0e4fca8 commit 507f04860914d95d4380477fb9ff8541ebc233b3 @antirez committed Mar 11, 2012
Showing with 28 additions and 34 deletions.
  1. +0 −6 README.md
  2. +4 −4 examples/asteroids.lua
  3. +3 −3 examples/falldown.lua
  4. +5 −5 examples/flames.lua
  5. +8 −8 examples/helicopter.lua
  6. +1 −1 examples/lines.lua
  7. +2 −2 examples/paint.lua
  8. +3 −3 examples/text.lua
  9. +1 −1 examples/triangles.lua
  10. +1 −1 load81.c
View
@@ -61,12 +61,6 @@ Control functions:
* setFPS(fps): Set the frame rate. For default it's set to 30 frames per second.
-Colors and Alpha:
-
-Color components and alpha are in the range 0-255.
-An alpha value of 0 means completely transparent, while a value of 255 means
-completely opaque.
-
KEYBOARD EVENTS
===
@@ -133,11 +133,11 @@ function drawShip(x,y,a)
local triangles = {}
table.insert(triangles,
{x0 = -10, y0 = -10, x1 = 0, y1 = 20, x2 = 10, y2 = -10,
- r = 255, g = 0, b = 0, alpha = 255 })
+ r = 255, g = 0, b = 0, alpha = 1 })
if keyboard.pressed['up'] then
table.insert(triangles,
{x0 = -5, y0 = -10, x1 = 0, y1 = math.random(-25,-20), x2 = 5, y2 = -10,
- r = 255, g = 255, b = 0, alpha = 255 })
+ r = 255, g = 255, b = 0, alpha = 1 })
end
for i,t in pairs(triangles) do
fill(t.r,t.g,t.b,t.alpha)
@@ -153,7 +153,7 @@ end
function drawBullets()
local i,b
for i,b in pairs(bullets) do
- fill(255,255,255,255)
+ fill(255,255,255,1)
rect(b.x-1,b.y-1,3,3)
end
end
@@ -163,7 +163,7 @@ end
function drawAsteroids()
local i,a
for i,a in pairs(asteroids) do
- fill(150,150,150,255)
+ fill(150,150,150,1)
ellipse(a.x,a.y,a.ray,a.ray)
end
end
@@ -95,7 +95,7 @@ function draw()
drawMap();
-- blit hero²
- fill(game.hero.color[1],game.hero.color[2],game.hero.color[3],255);
+ fill(game.hero.color[1],game.hero.color[2],game.hero.color[3],1);
rect(game.hero.pos.x,HEIGHT-( (game.hero.pos.y+game.hero.size.y) - game.map.scroll),game.hero.size.x,game.hero.size.y);
-- scroll the map
@@ -129,7 +129,7 @@ function draw()
-- some debug
--- fill(0,255,0,255)
+-- fill(0,255,0,1)
-- text(100,100,string.format("scroll %d",game.map.scroll))
-- text(100,130,string.format("screen %d*%d => %d*%d",WIDTH,HEIGHT,game.screen.size.x,game.screen.size.y))
-- text(100,160,string.format("speed %d px/s current %d frame %d ratio %f",game.map.speed,game.map.currentSpeed,game.screen.frameFlip,game.map.speedRatio))
@@ -208,7 +208,7 @@ function drawMap()
tile = game.map.data[ny][nx]
if(tile > 0) then
color = game.map.tile.color[tile]
- fill(color[1],color[2],color[3],255)
+ fill(color[1],color[2],color[3],1)
rect(px,py,game.map.tile.size.x,game.map.tile.size.y)
end
px = px+game.map.tile.size.x
View
@@ -26,19 +26,19 @@ function draw()
background(0,0,0)
for i,f in pairs(Flames) do
if f.l > 35 then
- fill(255, 255, 255, 230)
+ fill(255, 255, 255, 0.9)
minMove = 0
elseif f.l > 30 then
- fill(255, 255, 192, 205)
+ fill(255, 255, 192, 0.8)
minMove = 1
elseif f.l > 20 then
- fill(255, 192, 128, 178)
+ fill(255, 192, 128, 0.7)
minMove = 2
elseif f.l > 10 then
- fill(220, 128, 100, 128)
+ fill(220, 128, 100, 0.5)
minMove = 3
else
- fill(160, 128, 80, 76)
+ fill(160, 128, 80, 0.3)
minMove = 5
end
@@ -57,11 +57,11 @@ end
function clear()
background(0,0,0,0)
- fill(255, 255, 255, 255)
+ fill(255, 255, 255, 1)
end
function drawBorder(arr, top)
- fill(127, 127, 127, 255)
+ fill(127, 127, 127, 1)
for i,b in pairs(arr) do
if top == 1 then
@@ -129,7 +129,7 @@ end
function drawHeli()
x = heli.x
y = heli.y
- fill(255, 255, 255, 255)
+ fill(255, 255, 255, 1)
--[[
-- ---------
@@ -141,10 +141,10 @@ function drawHeli()
-- (debug) collision box
- --fill(0, 0, 255, 128)
+ --fill(0, 0, 255, 0.5)
--rect(x, y, heli.w, heli.h)
- fill(255, 255, 255, 255)
+ fill(255, 255, 255, 1)
-- body
rect(x+30, y+10, 50, 30)
triangle(x+30+51, y+10, x+30+52, y+10+30, x+30+50+20, y+9)
@@ -265,14 +265,14 @@ function drawBorders()
end
function drawPoints()
- fill(255,0,0,255)
+ fill(255,0,0,1)
text(WIDTH-50,HEIGHT-20, string.format("%d", points))
end
function drawBlock()
if block == nil then return end
- fill(128,127,127,255)
+ fill(128,127,127,1)
rect(block.x, (HEIGHT/2)-(block.h/2), block.w, block.h)
end
@@ -306,7 +306,7 @@ function draw()
if hit == 1 then
speed = 0
- fill(255,0,0,255)
+ fill(255,0,0,1)
text((WIDTH/2)-40,HEIGHT/2, "we got hit")
end
View
@@ -3,7 +3,7 @@ function setup()
end
function draw()
- fill(math.random(255),math.random(255),math.random(255),math.random(255))
+ fill(math.random(255),math.random(255),math.random(255),math.random())
line (math.random(WIDTH),math.random(HEIGHT),
math.random(WIDTH),math.random(HEIGHT))
end
View
@@ -4,9 +4,9 @@ end
function draw()
if mouse.pressed['1'] then
- fill(255,0,0,50)
+ fill(255,0,0,.2)
else
- fill(0,0,255,50)
+ fill(0,0,255,.2)
end
ellipse(mouse.x,mouse.y,30,30)
end
View
@@ -1,9 +1,9 @@
function draw()
background(0,0,0,0)
- fill(100,50,250,255)
+ fill(100,50,250,1)
text(20,HEIGHT-40,"Please, enter this window with your mouse pointer.")
- fill(255,0,0,255)
+ fill(255,0,0,1)
text(mouse.x,mouse.y,"Hello World!")
- fill(200,200,200,255)
+ fill(200,200,200,1)
text(0,0,string.format("Mouse is at x:%s y:%s",mouse.x,mouse.y))
end
@@ -3,7 +3,7 @@ function setup()
end
function draw()
- fill(math.random(255),math.random(255),math.random(255),math.random(255))
+ fill(math.random(255),math.random(255),math.random(255),math.random())
triangle(math.random(WIDTH),math.random(HEIGHT),
math.random(WIDTH),math.random(HEIGHT),
math.random(WIDTH),math.random(HEIGHT))
View
@@ -126,7 +126,7 @@ int fillBinding(lua_State *L) {
l81.r = lua_tonumber(L,-4);
l81.g = lua_tonumber(L,-3);
l81.b = lua_tonumber(L,-2);
- l81.alpha = lua_tonumber(L,-1);
+ l81.alpha = lua_tonumber(L,-1) * 255;
if (l81.r < 0) l81.r = 0;
if (l81.r > 255) l81.r = 255;
if (l81.g < 0) l81.g = 0;

0 comments on commit 507f048

Please sign in to comment.