Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render themes: SVG resources #60

Closed
Longri opened this issue Jul 13, 2016 · 13 comments
Closed

Render themes: SVG resources #60

Longri opened this issue Jul 13, 2016 · 13 comments
Milestone

Comments

@Longri
Copy link

Longri commented Jul 13, 2016

add svg constructor for Bitmap
Implement SVG loading for theme symbol

I will do that with PR in the next days.

Tests with iOS framework are successful

@devemux86 devemux86 changed the title add svg constructor for Bitmap Render themes: SVG resources Jul 14, 2016
@devemux86 devemux86 added this to the 0.6.0 milestone Jul 14, 2016
@devemux86
Copy link
Collaborator

devemux86 commented Jul 14, 2016

I have under testing a working implementation with the proper infrastructure.
It requires several intermediate steps to work properly:

  • Allow symbols without texture atlas
  • Read resources from files, besides internal assets
  • Tags scaling e.g. dy
  • ...

So wait a bit until I push all the commits. 😄

@devemux86
Copy link
Collaborator

Tests with iOS framework are successful

Very good news! 👍

@Longri
Copy link
Author

Longri commented Jul 14, 2016

Allow symbols without texture atlas

thats not god! The Textureatlas has one Texture with all Symbols! If you change this to single Texture you need many performance for swap Textures with render any Symbol! And Texture swaping cost performance!

So wait a bit until I push all the commits.

Yes I wait and hope your implementation on Android and Desktop is implementable at iOS

@devemux86
Copy link
Collaborator

devemux86 commented Jul 14, 2016

thats not god! The Textureatlas has one Texture with all Symbols! If you change this to single Texture you need many performance for swap Textures with render any Symbol! And Texture swaping cost performance!

Nevertheless a library should be versatile.
If users need having the symbols in a regular folder collection, library could provide that option.

BTW how do you think SVG symbols should be stored in a render theme?
As files, as SVG atlas, as ...?

@Longri
Copy link
Author

Longri commented Jul 14, 2016

I think the best way is to create the Textureatlas at runtime.
Some Themer like Klaus from Freizeitkarte, use SVG and BMP.

Wen a Theme is loaded, so we created all the symbols into Textureatlas!

Maybe we can Buffer this Textureatlas on Feilesystem for the next load.

@devemux86
Copy link
Collaborator

devemux86 commented Jul 14, 2016

Note that now only symbols are read from texture atlas.
Patterns and textures are still loaded from separate files.

Runtime creation is more complicated (needs a writer too) and I'd leave it as a future step.
For start we need to support properly all known functionality and then will see how to proceed.

@Longri
Copy link
Author

Longri commented Jul 16, 2016

Runtime creation is more complicated (needs a writer too) and I'd leave it as a future step.
For start we need to support properly all known functionality and then will see how to proceed.

no, is not complicated!

`
public static TextureAtlas createTextureAtlasFromImages(FileHandle folder) {

    int pageWidth = 2048;
    int pageHeight = 2048;
    int padding = 2;
    boolean duplicateBorder = false;

    PixmapPacker packer = new PixmapPacker(pageWidth, pageHeight, Pixmap.Format.RGBA8888, padding, duplicateBorder);

    ArrayList<FileHandle> fileHandleArrayList = new ArrayList<FileHandle>();
    getHandles(folder, fileHandleArrayList);

    for (FileHandle fileHandle : fileHandleArrayList) {

        Pixmap pixmap = null;
        String name = null;

        //check for svg or png
        if (fileHandle.extension().equalsIgnoreCase("svg")) {
            try {
                pixmap =CanvasAdapter.decodeSvg(fileHandle.read(), 1, 100, 100, 100, fileHandle.hashCode()).getPixmap();
                name = fileHandle.name();
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (fileHandle.extension().equalsIgnoreCase("png")) {
            pixmap = CanvasAdapter.decodeBitmap(fileHandle.read()).getPixmap();
            name = fileHandle.name();
        }

        if (pixmap != null) packer.pack(name, pixmap);

    }
    TextureAtlas atlas = packer.generateTextureAtlas(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear, false);
    packer.dispose();
    return atlas;
}

public static void getHandles(FileHandle begin, ArrayList<FileHandle> handles) {
    FileHandle[] newHandles = begin.list();
    for (FileHandle f : newHandles) {
        if (f.isDirectory()) {
            getHandles(f, handles);
        } else {
            handles.add(f);
        }
    }
}

`

this code is tested!

@devemux86
Copy link
Collaborator

Hmm we'd need to include a libGDX dependency on core module for that..

@Longri
Copy link
Author

Longri commented Jul 16, 2016

Yes, but I think that Libgdx is the better way here.
The Libgdx is constantly developed and a lot of things from VTM basing on the code of Libgdx!

@devemux86
Copy link
Collaborator

devemux86 commented Jul 16, 2016

I created #63 for SVG texture atlas, to see what can be done.

@devemux86
Copy link
Collaborator

devemux86 commented Jul 16, 2016

I pushed the needed SVG infrastructure, along with implementations:

@devemux86
Copy link
Collaborator

devemux86 commented Jul 16, 2016

@Longri you can proceed for the iOS in IosGraphics.decodeSvgBitmapImpl method.

e.g. see the AndroidGraphics / AndroidSvgBitmap or AwtGraphics / AwtSvgBitmap classes.

@devemux86
Copy link
Collaborator

@Longri provided the iOS implementation via PR #69.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants