DNA
DNA13mo ago

deno_tui Label-class

Hello. I just started testing around with deno_tui and found the DrawObject-Class. How do i actually use this class? Afaik there is no proper documentation to deno_tui at all and especially not for this class specifically.
72 Replies
Beast
Beast13mo ago
DrawObject doesn't do that much by itself, it's used to create TextDrawObject and BoxDrawObject which then are used in components to render on the canvas. To build Tui you probably want to use components instead, if you want to create your own components and use them you can take a look at any of the components in src/components, keep in mind that I'm planning on replacing DrawObjects in the future, I have PR open to do it, will try to finish it as soon as I will have some spare time.
DNA
DNA13mo ago
My problem is just, that i dont know, what i need to use for achieving my goal. Basically, i want to have blocks which consist of 16x16 pixel (16 rows, 32 columns) to display textures. The texture of each "block" has to be adjustable. Is there a component that does this?
Beast
Beast13mo ago
there's a way to workaround this using styles, but that's not good DX at all, it seems like your usecase is actually in need of custom DrawObject I was planning on implementing ShapePainter in my PR which is essentially what you need, but I didn't even start working on it :/ @realdna it totally escaped my head 🤦‍♂️ you could just use Label component for that
Beast
Beast13mo ago
No description
Beast
Beast13mo ago
essentially you could just convert the texture into a string and pass it to the label my brain isn't braining
DNA
DNA13mo ago
I tried that but with a textbox and it didnt work And i gave up I think the label is gonna work Let me try in a few minutes
Beast
Beast13mo ago
https://deno.land/x/tui@2.1.1/src/components/mod.ts you should check that for simple component descriptions textbox is a multiline text input :p
DNA
DNA13mo ago
Lmao Me being braindead Sorry I didnt want to waste your time
Beast
Beast13mo ago
you didn't tui definitely needs better docs
DNA
DNA13mo ago
I just tried that method, but it doesnt seem to work properly for me This is my code:
new Label({
parent: tui,
rectangle: {
column: 0,
row: 0
},
text: textures.stone,
theme: {
base(text) {
return text;
},
},
zIndex: 1,
});
new Label({
parent: tui,
rectangle: {
column: 0,
row: 0
},
text: textures.stone,
theme: {
base(text) {
return text;
},
},
zIndex: 1,
});
DNA
DNA13mo ago
The outcome in terminal:
No description
DNA
DNA13mo ago
When i manually print the text (textures.stone) reading it from the file:
No description
DNA
DNA13mo ago
Beast
Beast13mo ago
Okay, I think I know what's going wrong here, could you file an issue about it please?
DNA
DNA13mo ago