Search Unity

[Released] Bitmap Drawing API v0.8 (open source)

Discussion in 'Assets and Asset Store' started by hatuf, Jun 12, 2014.

  1. hatuf

    hatuf

    Joined:
    Jan 6, 2013
    Posts:
    8
    I've just finished and uploaded my project to GitHub:
    https://github.com/ProtoTurtle/UnityBitmapDrawing

    Example project here:
    https://github.com/ProtoTurtle/BitmapDrawingExampleProject

    This uses a MIT license so you can do pretty much anything with it as long as you keep the license intact. Commercial projects, further open source, etc. are all fine.

    Bitmap Drawing API
    At it's core this library provides and easy way to manipulate your textures as bitmaps. I find it very useful for visual debugging, creating procedural art or creating tools. You only need one file!

    You have an existing texture or you create an empty texture and you can draw lines, circles and rectangles on it (filled with color or just the outline).

    Features



      • DrawPixel(position, color) - Draws a pixel but with the top left corner being position (x = 0, y = 0)
      • DrawLine(start, end, color) - Draws a line between two points
      • DrawCircle(position, radius, color) - Draws a circle
      • DrawFilledCircle(position, radius, color) - Draws a circle filled with a color
      • DrawRectangle(rectangle, color) - Draws a rectangle or a square
      • DrawFilledRectangle(rectangle, color) - Draws a rectangle or a square filled with a color
      • FloodFill(position, color) - Starts a flood fill of a certaing at the point


    Uses Extension Methods so it's super simple to start using, you only type
    Code (csharp):
    1. using ProtoTurtle.BitmapDrawing;
    And all the bitmap drawing methods are available to your Texture2D instances.



    I'm looking for feedback on this and I'm taking feature requests. I just wanted to get this first version out and see if there's any interest in this tool.


    Coming up next:
    - Faster flood fill (the bottleneck is mostly comparing Unity's Color structs) - if anyone has a good idea about this, please let me know! Running the flood fill with ints instead of Colors makes it a ton faster but then the problem is converting the Colors to ints and then back to Colors for SetPixels.
    - A buffer of the bitmap that get's uploaded on Apply() but doesn't do any SetPixel() calls before that.
     
  2. Patico

    Patico

    Joined:
    May 21, 2013
    Posts:
    886
    Sounds cool! Why you don't publish this on asset store?
     
  3. hatuf

    hatuf

    Joined:
    Jan 6, 2013
    Posts:
    8
    Thanks, I'll post it in the Asset Store too so more people can find it. edit: It's submitted to Asset Store too, I'll update when it's available.
     
    Last edited: Jun 12, 2014
  4. hatuf

    hatuf

    Joined:
    Jan 6, 2013
    Posts:
    8
  5. huanyingtianhe

    huanyingtianhe

    Joined:
    Sep 7, 2015
    Posts:
    1
    I'm looking a drawline function that could support the line width...
     
  6. DeeCeptor

    DeeCeptor

    Joined:
    Aug 4, 2013
    Posts:
    33
    Hi. I know this is an old thread, but I was wondering if it's possible to adapt the code to do outlines. Ex: You have an image composed of only 2 colours, and a black pixel is drawn wherever the colours change/meet. Thanks.