draw
Parameters
- self:*IconWidget
- *IconWidget
Source
Implementation
pub fn draw(self: *IconWidget) void {
const rs = self.data().parent.screenRectScale(self.data().contentRect());
var texOpts: dvui.RenderTextureOptions = .{ .rotation = self.data().options.rotationGet() };
const white: ?dvui.Color = .white;
const as_bytes = std.mem.asBytes;
if (std.mem.eql(u8, as_bytes(&self.icon_opts.fill_color), as_bytes(&white)) and
std.mem.eql(u8, as_bytes(&self.icon_opts.stroke_color), as_bytes(&white)))
{
// user is rasterizing icon with defaults (white), so always use
// colormod (so icons default to text color)
texOpts.colormod = self.data().options.color(.text);
} else if (self.data().options.color_text) |ct| {
// user is customizing icon rasterization, only colormod if they passed
// a text color
texOpts.colormod = ct;
}
dvui.renderIcon(
self.name,
self.tvg_bytes,
rs,
texOpts,
self.icon_opts,
) catch |err| {
dvui.logError(@src(), err, "Could not render icon", .{});
};
}