[mod] Grafitti API (grafitti)

Post Reply
User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

[mod] Grafitti API (grafitti)

by AspireMint » Post

Grafitti API

Easily create images of any size, choose from palette and paint image!

Example code to create 2 brushes and 2 formspecs (see screnshots):

Code: Select all

grafitti.register_grafitti("mymod:bubble", {image = "bubble.png"})
grafitti.register_grafitti("mymod:heart", {image = "heart.png"})
grafitti.palette_build("mymod:heart_and_buble")
grafitti.register_brush("mymod:brush_1", {
    description = "Heart and buble Brush",
    inventory_image = "brush_1.png",
    wield_image = "brush_1.png^[transformR270",
    palette = "mymod:heart_and_buble",
    recipe = {{"default:dirt"}}
})

grafitti.register_grafitti("mymod:nyancat1x1", {
    image = "nyancat.png",
})
grafitti.register_grafitti("mymod:nyancat4x4", {
    image = "nyancat.png",
    size = {x=4, y=4},
})
grafitti.register_grafitti("mymod:nyancat16x16", {
    image = "nyancat.png",
    size = {x=16, y=16},
})
grafitti.palette_build("mymod:nyancat_images")
grafitti.register_brush("mymod:brush_2", {
    description = "Nyancat Brush",
    inventory_image = "brush_2.png",
    wield_image = "brush_2.png^[transformR270",
    palette = "mymod:nyancat_images",
    recipe = {{"default:stone"}}
})
Screenshots:
Image
Image

Image

96x96 MT icon:
Image
Image

Download:
https://github.com/AspireMint/grafitti/ ... master.zip
or browse code https://github.com/AspireMint/grafitti

Dependencies:
none

License:
GNUv3

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: [mod] Grafitti API (grafitti)

by aristotle » Post

Cool! I am downloading it! Thank you! :D
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

Chibi ghost
Member
Posts: 845
Joined: Fri Jan 08, 2016 21:17
In-game: Ghost

Re: [mod] Grafitti API (grafitti)

by Chibi ghost » Post

impressive

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [mod] Grafitti API (grafitti)

by Beerholder » Post

Looks very nice AspireMint! :D

I am back from holiday and besides continuing to work on multi_map, I wanted to test some of my mods with 0.5.0 and latest versions of depends, starting with painted_3d_armor.

Would it make sense that I check if I can make grafitti work with my painted armor mod? I.e. being able to use registered grafittis on armor and shields somehow?

Let me know what you think!

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: [mod] Grafitti API (grafitti)

by AspireMint » Post

Thank you!
Beerholder: good idea, but your mod actually supports only 6x6 canvas and is hardcoded.
Im getting runtime error when i use other canvases.

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [mod] Grafitti API (grafitti)

by Beerholder » Post

AspireMint wrote:Thank you!
Beerholder: good idea, but your mod actually supports only 6x6 canvas and is hardcoded.
Im getting runtime error when i use other canvases.
Well for the painting mod support part I decided one 6x6, 12x12 and 24x24 as hard coded sizes as that makes it easy to resize the armor texture in order to fit the banner. They should work though (although I made a mistake with the offset still, which I just fixed). But I did not run into runtime errors ... O_o shall do some more testing then, can you post the error and line number where it occurs in my painted armor thread please?

As for grafitti support, I would make some custom bridge code, and support texture sizes such as 16x16 and 32x32 by doing some resize trickery with the armor textures. I *should* be able to make it work for 16x16 and 32x32 ... I will give it a first try today/ tomorrow and report back in my own thread!

For my information, is it your intention for grafitti to support the "multiples of 2", i.e. 8x8, 16x16, 32x32, or also values inbetween, i.e. 20x20, 40x40, etc?

Thanks! :-)

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: [mod] Grafitti API (grafitti)

by AspireMint » Post

> "6x6, 12x12 and 24x24"
- also 16x16 works for me

> "can you post the error and line number where it occurs in my painted armor thread please?"
- oh, i tried 32x32 and 64x64 canvases. Nvm, my bad. So i put it here:
minetest/src/server.cpp:73: run: A fatal error occured: String too long for serializeString

> "is it your intention for grafitti to support the "multiples of 2", i.e. 8x8, 16x16, 32x32, or also values inbetween, i.e. 20x20, 40x40, etc?"
- any size :-)

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [mod] Grafitti API (grafitti)

by Beerholder » Post

AspireMint wrote: - oh, i tried 32x32 and 64x64 canvases. Nvm, my bad. So i put it here:
minetest/src/server.cpp:73: run: A fatal error occured: String too long for serializeString
Did you use the canvases from the painting mod, not the ones from painted 3d armor (the so called armor canvases)? Yeah unfortunately that does not work :-( Maybe I should do a resize in case it is an unsupported size ...

Also, the painting mod builds a string of single pixel texture combines, like this (position=color.png, where color.png is a single 1x1 pixel texture of specified color):

Code: Select all

^[combine:12x12:10,22=violet.png:11,22=red.png:10,23=black.png:
Looks like the error comes from the fact that there are too many pixels being combined, making too large a string for serlialization by the engine. Strange that there is a limit, possibly because it serializes to a DB column I guess ...... Good to know, I shall set a limit then and log a sane/ readable error.
AspireMint wrote: > "is it your intention for grafitti to support the "multiples of 2", i.e. 8x8, 16x16, 32x32, or also values inbetween, i.e. 20x20, 40x40, etc?"
- any size :-)
Ok, any size it is then!! :-) Means I will have to do resizes of the texture (and the armor texture), but that is perfectly doable!

Thanks! :-D

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [mod] Grafitti API (grafitti)

by ShadMOrdre » Post

AspireMint,

I've tried to get both this and your white_patterns mods working on 0.4.17 stable, but each time it crashes the server with pipeworks or some other mod throwing errors, but no indication as to what this mod is now conflicting with.

It is only the addition of either of these mods that causes server crash.

Is this mod meant for MT 0.5.0 only?

Shad MOrdre

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [mod] Grafitti API (grafitti)

by sorcerykid » Post

I love the look of those textures. I really want to figure out how to incorporate this into the world of JT2, since graffiti in a dystopian, stone world seems like the perfect fit. I just wish there was a way to add colors (although the white does look pretty snazzy).

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests