Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

I want to know how to render widget(s) individually. >:)

(1 edit) (+1)

Well, I had intended to allow an explanation to reflect a specific use-case, but I suppose I can concoct something.

The app.render[] function can be called with a widget, as with a card:


Let's say we want to save a "screenshot" of only the widgets on a card, and ignore the background.

 

Create an image interface the size of the card, iterate over the widgets of the card, rendering each and pasting it (with transparency) onto the image, reflecting their position on the card, and then write[] that image, prompting the user for a location to save it:

i:image[card.size]
each wid in card.widgets
 i.paste[app.render[wid] wid.pos 1]
end
write[i]


You could also, for example, selectively avoid rendering some of the widgets, either by "drop"-ing them from card.widgets by name before iterating over them:

each wid in ("button2","the forbidden one") drop card.widgets
 # ... draw everything but those two specific ones
end

Or conditionally avoiding/permitting a certain kind of widget:

each wid in card.widgets
 if !wid.type~"field"
  # ... draw everything except for nasty fields
 end
end

You can also use Lil's query language and/or widget naming conventions to locate widgets of interest:

each wid in extract value where value..name like "fancy_*" from card.widgets
 # ... draw only the widgets which are fancy
end

Et cetera, et cetera. How's that?