Colour Spectrum (Fixed)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
nate890
Prole
Posts: 25
Joined: Tue Jan 24, 2012 10:50 pm

Colour Spectrum (Fixed)

Post by nate890 »

Code: Select all

local colours={}

for i=1,255 do
	table.insert(colours,{0,0,i})
end
for i=1,255 do
	table.insert(colours,{0,i,255})
end
for i=1,255 do
	table.insert(colours,{0,i,0})
end
for i=1,255 do
	table.insert(colours,{i,255,0})
end
for i=1,255 do
	table.insert(colours,{i,0,0})
end

local x=800
local y=600

function love.draw()
	for i=1,#colours do
		love.graphics.setColor(unpack(colours[i]))
		love.graphics.rectangle("fill",x/#colours*(i-x),0,x/#colours,y)
	end
end
Trying to create a quick colour spectrum, I get the error "24 - Incorrect draw mode -501.333333333333", what's this mean? How can I fix this?
Last edited by nate890 on Fri Jan 27, 2012 12:26 pm, edited 2 times in total.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Colour Spectrum (Odd Error)

Post by MarekkPie »

RGB-values are integers from 0-255, so you are both (according to your error) outside the bounds, and using decimal values as an input. (AKA Don't divide by 255.)
nate890
Prole
Posts: 25
Joined: Tue Jan 24, 2012 10:50 pm

Re: Colour Spectrum (Odd Error)

Post by nate890 »

MarekkPie wrote:RGB-values are integers from 0-255, so you are both (according to your error) outside the bounds, and using decimal values as an input. (AKA Don't divide by 255.)
Oops, didn't notice, was using the same table from other code I wrote. Anyway, that wasn't the error, ended up fixing it.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Colour Spectrum (Odd Error)

Post by MarekkPie »

You also don't have a width or a height in your rectangle.
nate890
Prole
Posts: 25
Joined: Tue Jan 24, 2012 10:50 pm

Re: Colour Spectrum (Odd Error)

Post by nate890 »

MarekkPie wrote:You also don't have a width or a height in your rectangle.
I thought it was rectangle(pos.x,pos.y,size.x,size.y) ?

Anyway, I have this, no error, but doesn't seem to work (Nothing shows)

Code: Select all

love.graphics.rectangle("fill",x/#colours*(i-(x/#colours)),0,x/#colours,y)
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Colour Spectrum (Odd Error)

Post by MarekkPie »

nate890 wrote:
MarekkPie wrote:You also don't have a width or a height in your rectangle.
I thought it was rectangle(pos.x,pos.y,size.x,size.y) ?

Anyway, I have this, no error, but doesn't seem to work (Nothing shows)

Code: Select all

love.graphics.rectangle("fill",x/#colours*(i-(x/#colours)),0,x/#colours,y)
Sorry, those commas looked like periods to me.
nate890
Prole
Posts: 25
Joined: Tue Jan 24, 2012 10:50 pm

Re: Colour Spectrum (Odd Error)

Post by nate890 »

Sorry, those commas looked like periods to me.
No problem.

Anyway, do you know why this doesn't seem to show up on the screen? Assuming my calculations are incorrect because I really don't understand how Love2D quite works, yet.

Code: Select all

love.graphics.rectangle("fill",x/#colours*(i-(x/#colours)),0,x/#colours,y)
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Colour Spectrum (Odd Error)

Post by MarekkPie »

Try not unpacking the colors. Love can read the table as well. It seems as if that's the line that is giving you issues (I'm assuming 24 is the line where the error occurs and there isn't any other code in your file to shift the numbers.)
nate890
Prole
Posts: 25
Joined: Tue Jan 24, 2012 10:50 pm

Re: Colour Spectrum (Odd Error)

Post by nate890 »

MarekkPie wrote:Try not unpacking the colors. Love can read the table as well. It seems as if that's the line that is giving you issues (I'm assuming 24 is the line where the error occurs and there isn't any other code in your file to shift the numbers.)
Even if it reads the tables, I still don't see nothing. Maybe my formula is incorrect and the rectangles aren't showing up on the screen?
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Colour Spectrum (Odd Error)

Post by MarekkPie »

So is the error the error code in the first post? Or can you not see anything, but it runs?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 81 guests