# Advanced Examples ## 1. Dynamic Health Bar with Variables This example shows how to use `Painter.vars` to update a bar smoothly. ```javascript // Server Script PlayerEvents.tick(event => { const { player } = event; // Set unique variable for this player Painter.vars.set('hp_' + player.uuid, player.health); Painter.sync(player); }); PlayerEvents.loggedIn(event => { Painter.paint(event.player, { hp_bar: { type: 'gradient', x: 10, y: 10, w: '$hp_' + event.player.uuid + ' * 5', // 5 pixels per HP point h: 10, colorL: '#FF0000', colorR: '#FF5555', draw: 'gui' } }); }); ``` ## 2. Animated Background Texture Using math to scroll a texture. ```javascript Painter.paint(event.player, { scrolling_bg: { type: 'rectangle', w: '$screenW', h: '$screenH', texture: 'minecraft:textures/block/nether_portal.png', u0: 'time * 0.1', v0: 'time * 0.1', u1: '(time * 0.1) + 1', v1: '(time * 0.1) + 1' } }); ``` ## 3. Rainbow Text with HSV Using the `hsv()` function for a smooth rainbow cycle without any server-side tick logic. ```javascript Painter.paint(event.player, { rainbow_msg: { type: 'text', text: 'RAINBOWS!', x: 10, y: 50, color: 'hsv(time * 0.2, 1, 1)', // Cycles through the full hue spectrum draw: 'gui' } }); ``` ## 4. Dynamic Mana Display with Variable Injection Combining variables with text `$var` injection for a live-updating label. ```javascript // Server Script PlayerEvents.tick(event => { const { player } = event; Painter.vars.set('mana_' + player.uuid, getMana(player)); Painter.sync(player); }); PlayerEvents.loggedIn(event => { const uid = event.player.uuid; Painter.paint(event.player, { mana_label: { type: 'text', text: 'Mana: $mana_' + uid, x: 10, y: 30, color: 'rgb(0.2, 0.6, 1)', draw: 'gui' }, mana_bar: { type: 'rectangle', x: 10, y: 42, w: '$mana_' + uid + ' * 2', h: 6, color: 'rgb(0.2, 0.6, 1)', draw: 'gui' } }); }); ```