Draw Single Pixel?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Draw Single Pixel?
I can't find out how to draw a single pixel, and change it's color. Is it love.graphics.point? Thanks!
Re: Draw Single Pixel?
Yes, [wiki]love.graphics.point[/wiki] is one way to do it. Another would be drawing 1x1 rectangles with [wiki]love.graphics.rectangle[/wiki]. You can select the color for if you call [wiki]love.graphics.setColor[/wiki] beforehand.
Code: Select all
love.graphics.setColor(255, 0, 0) -- Red point.
love.graphics.point(10.5, 10.5)
love.graphics.setColor(255, 255, 0) -- Yellow rectangle.
love.graphics.rectangle("fill", 15, 10, 1, 1)
love.graphics.setColor(255, 255, 255) -- Don't forget to set the color back to white or you'll ask yourself why your images look weird.
Shallow indentations.
Re: Draw Single Pixel?
I'm using the rectangle method, and it's really really slow. It gets about 1 frame per 10 - 15 seconds! Is there any way to speed this up?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Draw Single Pixel?
Yeah, not draw things pixel per pixel. What is it you want to achieve? There is probably a better way to go about it.
Help us help you: attach a .love.
Re: Draw Single Pixel?
Here's the latest working build. https://dl.dropboxusercontent.com/u/157 ... ild-2.love
It's a ComputerCraft emulator, with a high resolution. I want to keep the simpleness of CC, but be able to use full graphics.
It's a ComputerCraft emulator, with a high resolution. I want to keep the simpleness of CC, but be able to use full graphics.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Draw Single Pixel?
In that case, it might be a good idea to look into Shaders (or PixelEffects, as they are called in 0.8.0). There are some threads on these forums that can help you get started (especially Share a Shader).
Help us help you: attach a .love.
Re: Draw Single Pixel?
Drawing stuff pixel by pixel tends to be terribly slow. Shaders are a very flexible and fast way. Another possibility is to logically separate your drawing into pieces that don't change often, and draw them to some kind of buffer instead of directly drawing them to the screen. The buffer can then be quickly drawn on screen. LÖVE has two kinds of buffers: canvas and spritebatch. They work a little differently and I think canvases would probably fit your needs best.
I personally find working with canvases much easier than working with shaders, but it doesn't fit every situation.
Another possibility that I don't think is likely to fit your needs is to make a multithreaded program, with a second thread building images with ImageData:setPixel and then sending Images to the main thread to be drawn. This fits if you really want real pixel-by-pixel control but it's messy to work with and ineffient.
I personally find working with canvases much easier than working with shaders, but it doesn't fit every situation.
Another possibility that I don't think is likely to fit your needs is to make a multithreaded program, with a second thread building images with ImageData:setPixel and then sending Images to the main thread to be drawn. This fits if you really want real pixel-by-pixel control but it's messy to work with and ineffient.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Draw Single Pixel?
Thanks, but I can't seem to find a pixel thing. What am I doing wrong?
Who is online
Users browsing this forum: No registered users and 5 guests