Pull requests

#17 Declined
Repository
DLaicH/love-canvas_getPixel love-canvas_getPixel
Branch
canvas_getPixel
Repository
rude/love love
Branch
default

added Canvas:getPixel(x, y)

Author
  1. DLaicH
Reviewers
Description

This fork is based on 0.8.0, because that's the version of LÖVE I've been using. I played around with merging the current tip of rude/love into my changes, but I'd never used Mercurial before, and I don't think my merge came out quite right. I decided I'd just send you my revisions to 0.8.0 as a separate branch and let you incorporate it into the current code base as you see fit.

The feature I've added is a getPixel(x, y) method for the Canvas object, which I modeled after ImageData's getPixel method. I created this out of my annoyance with the current method of obtaining pixel data, which is to create a full ImageData object and run getPixel() on that. That approach isn't bad for occasional or one-time use, but it causes framerates to plummet into the single digits if executed every frame. The method I've devised uses a similar method, but it only queries OpenGL for one pixel, and it returns that pixel's data directly rather than instantiating an ImageData or other object. Because of this, it does not cause a significant framerate drop on my system, even when performed in every iteration of the draw loop.

Usage: r, g, b, a = Canvas:getPixel( x, y )

  • Learn about pull requests

Comments (4)

  1. DLaicH author

    It also bypasses DevIL entirely, which I'm sure adds some additional performance advantages over the ImageData approach.

  2. DLaicH author

    Shoot, I didn't realize that you couldn't delete branches until I read some articles about the differences between Mercurial and Git. Sorry about that. You probably wouldn't want my branch in your repository permanently even if you do decide to incorporate my feature.

    Which brings me to another question. What is the preferred way of offering you code revisions using Bitbucket/Mercurial?