Note: Clicking on the clock switches between running ("window") and icon mode.
EDIT: Removed the color definitions; they don't add anything to the demo.
Code: Select all
color = {
aliceblue = {240, 248, 255},
antiquewhite = {250, 235, 215},
aqua = { 0, 255, 255},
aquamarine = {127, 255, 212},
--- rest of colors
}
alpha = {
total = 000,
transparent = 000,
trans = 000,
half = 128,
semitrans = 128,
translucid = 128,
translucide = 128,
translucent = 128,
semiopaque = 128,
opaque = 255,
none = 255,
-- add the needed ones
}
function setColor(wantedColor,wantedAlpha)
love.graphics.setColor( wantedColor[1], wantedColor[2], wantedColor[3], wantedAlpha )
end
Well, I not sure if you gain much advantage and if you gain very much in shortness or speed over my 2 argument method in a function (unless you doing realtime alpha effects). Also doing "setColor(C_DIMTEXT, A_DIMTEXT)" would turn your code same lenght than your "love.graphics.setColor (DIMTEXT)". Note, I also keep something like a custom color variable file for project colors and use like like you DIMTEXT, BRIGHTEXT assign variables. As drawback when using my method, you had to create a C_DIMTEXT and A_DIMTEXT but would bring flexibility, independence, and less named colors/table size/code size.scirath wrote:I like the idea of naming the alpha channels like that, coffee. It's pretty intuitive.
For my needs, I had to simplify it further--just "one" argument vs. "two" in this case--because I'm using it in what's shaping up to be a rather large project (a GUI of sorts -- eyecandy render test here: http://imagebin.org/192681 ). ....And I find myself having to type in long sequences of colors over & over again. The call to runTimeKeeper() in itself takes five RGBAs (even though I'm really only using the RGB components for the demo), and that's only a single line. So, I'm being lazy in a way, and just getting it all done at once.
Code: Select all
function drawTestWindow(name,element,x,y,w,h,COLOR,FILLCOLOR,TITLECOLOR)
--some code
end
Code: Select all
drawTestWindow("Render Test",TITLED+CLOSEABLE+FRAMED+DRAGABLE,150,150,400,200,LightSlateGray80,FireBrick80,White80)
Code: Select all
drawTestWindow("Render Test",TITLED+CLOSEABLE+FRAMED+DRAGABLE,150,150,400,200,{{color.LightSlateGray},alpha.active},{{color.FireBrick},alpha.active},{{color.White},alpha.active})
-- i'm not even sure i got all those curly braces right lol
Code: Select all
drawTestWindow("Render Test",true,true,true,true,false,false,false,false,false,false,false,false,false,false,150,150,400,200,119,136,153,205,178,34,34,205,255,255,255,205)
-- this would use a different function declaration, of course
For such complicated API my way is to change the API so you woud do:scirath wrote:The advantage for me is in being able to glance at my code and not having to scan 4 or 5 lines to spot/change something. It's just the way my brain works.
For example, say I'm developing my windows' appearance...
I can callCode: Select all
function drawTestWindow(name,element,x,y,w,h,COLOR,FILLCOLOR,TITLECOLOR) --some code end
vs.Code: Select all
drawTestWindow("Render Test",TITLED+CLOSEABLE+FRAMED+DRAGABLE,150,150,400,200,LightSlateGray80,FireBrick80,White80)
Code: Select all
drawTestWindow("Render Test",TITLED+CLOSEABLE+FRAMED+DRAGABLE,150,150,400,200,{{color.LightSlateGray},alpha.active},{{color.FireBrick},alpha.active},{{color.White},alpha.active}) -- i'm not even sure i got all those curly braces right lol
Code: Select all
window=newTestWindow():setTitle("Render Test"):setPosition(150, 150):setWidth(400,200)
:setFillColor(color.White)
:setColor(color.Black)
:draw()
Users browsing this forum: No registered users and 50 guests