A small scene generator project

This (incomplete) scene generator is designed to help create scenes using a bitmap image. The idea is that you can create solid rectangular shapes that identify where specific types of visual objects should be displayed on the screen, and each colour you associate with each given type.

For example:

Where dark green is associated with SimpleButton, Lime is associated with Bitmap, and Light Blue is associated with a TextField, this outputs in the following:

As you can tell, it’s not perfect yet, and my maths has been getting worse these past few years so might need some help to perfect it. Other than that, I hope that you can make use of it. Perhaps it can be useful in making your games, and perhaps it would be faster to make than before. :slight_smile:

This is an interesting idea :smile:

Flash might also be good for layouts, or perhaps other software that doesn’t require a license?

Yeah, I’m trying to figure out an algorithm that detects each individual rectangle better than it currently does.

Currently, the way I achieve the current results is by going left-to-right, row by row, and identifying each pixel colour to detect variations in colours. The problem with this method is that when you get to the row indicating the dark green and light blue, is that on each row, it thinks that it is a new rectangle.

Larsius suggested to use the compare function, but I find it difficult to make a use of it. The whole idea of using only one Bitmap image is to identify the x and y positions of the original Bitmap image.

So assuming that you don’t know what the image actually looks like, you need to provide an algorithm that detects each edge of any given solid rectangle, and identify it as just one rectangle, instead of many.

I’m finding it extremely difficult to accomplish, so I would definitely appreciate some voluntary help in accomplishing this task. :smile:

I think it’s a good idea, personally. It came to mind after finding it difficult to provide a location for visual objects on the screen and having to guess where they should be. At least with a Bitmap image and a few colour associations, you don’t have to worry too much.

GIMP could be used, as well as many other pieces of software, to make it possible :smile: Paint.NET, which is what I use(d) to create bitmap images. It would certainly be a different way of looking at designing scenes, that’s for sure :smile:

PNG format doesn’t seem like the right way to store a bunch of rectangles. Why not XML?

You could make a GUI for dragging rectangles around, export those rectangles as XML, and then import the rectangles into your app. No need to iterate through every single pixel in a bitmap; just use a premade XML parser!

Or what if you had a simpler way to code it? Something like this:

title.centerX();
title.alignTop();

picture.alignRight();
picture.below(title, 10);

menuButton[0].alignLeft();
menuButton[0].below(title, 10);
    
for(i in 1...menuButtons.length) {
    menuButton[i].alignLeft();
    menuButton[i].below(menuButton[i - 1], 10);
}

footer.centerX();
footer.alignBottom();

I don’t like XML, I’ve always preferred JSON for a format. I think that’s just inherent in my hatred for HTML in general (never liked web design). Nevertheless, I think I will take your suggestion on board.

I am considering creating a “editor” portion of this library, using a -D define editor so that it builds the editor instead of the test code. I’m going to rewrite the generator as well, to take on-board the changes I’m making and also the addition of the editor itself. It’s just going to be a very simple way of drawing rectangles of different colours that identify different objects on the screen.

This would be the same as above, just instead of using a Bitmap image, use JSON-formatted data instead. I suppose it does make more sense now that I think about it.

I agree with player_03, that having a bitmap seems total overkill and really prone to errors, apart from trying to “parse” a bitmap it adds huge complication to a work flow by having to edit a bitmap and still define colours based on what you wanted to end up with. Configuration certainly seems the way to go here.

A little off topic, but coincidently i just wrote a blog post about XML, JSON & YAML ( http://haxeui.org/blog/2015/11/21/1448109840000.html ). No reason you couldnt support all of them (though JSON is certainly easier to parse if you arent interested in maintaining typed objects as a result):

You can get typed objects from JSON; just use a typedef.

1 Like