Paint program

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.
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Paint program

Post by iPoisonxL »

Yes, but remember; canvases are not an option right now.

All I'm looking for is that the FPS just boosts a little bit more. I'm currently locked at 13 FPS, and I need 25-30. It's not really meant to be a smooth drawing thing, it's meant to have some kind of input lag.

EDIT: FPS shifts from 13-18.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Paint program

Post by micha »

You should definitely try to go with imageData. They reason, why drawing it is faster, is because you only need to call one drawing-function. While for the pixel-by-pixel approach you call a drawing-command for each pixel. Besides the drawing, each function call has some overhead (communication between LÖVE and OpenGL), which makes this approach so slow.
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Paint program

Post by iPoisonxL »

micha wrote:Besides the drawing, each function call has some overhead (communication between LÖVE and OpenGL), which makes this approach so slow.
Thanks for explaining this to me. I'll try out imageData.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: Paint program

Post by Luke100000 »

Maybe something like that:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      pixels[mouse.x][mouse.y]=true
   end
end
User avatar
tavuntu
Citizen
Posts: 65
Joined: Mon Dec 24, 2012 6:56 am
Contact:

Re: Paint program

Post by tavuntu »

Yeah but with that last example you only can draw a pixel once (it's an example, I know, just saying).
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Paint program

Post by iPoisonxL »

Luke100000 wrote:Maybe something like that:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      pixels[mouse.x][mouse.y]=true
   end
end
This is how it is right now (well, something like that). The love.update process isn't what's lagging it, it's the drawing process. Not sure why, someone else says it's because LOVE does an OpenGL thingy every pixel. (480,000)

Oh, and also I added 9 shades and 5 colors to play around with. I kinda like the lagginess, I can make Space Creation Simulator 2013. It might be a bit hard to see the colors, but they're in there.
SCS2013.png
SCS2013.png (18.5 KiB) Viewed 5052 times
lol

P.S. I went from love.graphics.point(x,y) to love.graphics.rectangle(x,y,1,1) to make brighter pixels.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
User avatar
Luke100000
Party member
Posts: 232
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: Paint program

Post by Luke100000 »

tavuntu wrote:Yeah but with that last example you only can draw a pixel once (it's an example, I know, just saying).
If you mean me:
you can write:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      for x=-5, 5 do
         for y=-5, 5 do
            pixels[mouse.x+x][mouse.y+y]=true
         end
      end
   end
end
Now you can draw an big rectangle.
Only circles are the problem. :awesome:
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

Re: Paint program

Post by DaedalusYoung »

That's still drawing every pixel individually. Not in the update function, but in the draw function. And that's what's making it slow. If you had to make a drawing on paper, would you rather make a rectangle by drawing 25 dots, or would you draw 4 lines?
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Paint program

Post by Ranguna259 »

How about every 5 seconds or by adding an array limit to the pixel table the screen gets saved into an ImageData, cleans the pixel table and draws the imageData ?

I'm going to try that.

EDIT: Nah, it re-draws every single pixel anyways :/

EDIT2: Actualy.. It has a limit because calling screenshot on every frame would slow down the FPS.
imageData with pixel limiter.love
(474 Bytes) Downloaded 202 times
EDIT3: Got a new ideia, everytime the mouse gets released then the current pixels get drawn to the imageData.
EDIT4: And that's paint for you, dunno why it get's alpha'ed every time it takes a screenshot.. That's up to you to fix ;)
Attachments
paint.love
(1022 Bytes) Downloaded 195 times
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

Re: Paint program

Post by iPoisonxL »

Wow, that's pretty cool! I like the first file you provided, since it's some kind of space creation software. I'll try to learn from that, makes sense. Thanks lots.

Code: Select all

      L
    L Ö
    Ö V
L Ö V E
Ö B E
V E
E Y
Website
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 55 guests