Paste: Merry Christmas UI

Author: CapitalEx
Mode: factor
Date: Sun, 25 Dec 2022 23:46:41
Plain Text |
! Copyright (C) 2022 CapitalEx
! See http://factorcode.org/license.txt for BSD license.

USING: accessors colors kernel make math pair-rocket random
ranges sequences strings ui.gadgets ui.gadgets.labels
ui.gadgets.packs ui.gadgets.panes ;
IN: merry-christmas

CONSTANT: branch { 42 42 42 42 42 64 }

: <center-pile> (   -- gadget ) <pile> 0.5 >>align ;
: row-size      ( n -- n      ) 2 * 1 +            ;
: branches      ( n -- label  )
    row-size <iota> [ drop branch random ] "" map-as <label> ;

: crown ( n -- gadgets ) [0..b) [ branches ] map ;
: trunk (   -- label   ) "_| |_" <label>         ;
: christmas-tree ( gadget -- gadget )
    <center-pile>
        10 crown add-gadgets
        trunk    add-gadget add-gadget ;

: merry-christmas ( gadget -- gadget )
    "MERRY CHRISTMAS" <label> add-gadget ;

: happy-holidays ( gadget -- gadget )
    "HAPPY HOLIDAYS" <label> add-gadget ;

: and-a-happy-new-years ( gadget -- gadget )
    <center-pile>
        "AND" 
            <label> add-gadget 
        "A HAPPY NEW YEARS" 
            <label> add-gadget add-gadget ;

: merry-christmas. ( -- )
    <center-pile>
        christmas-tree
        merry-christmas
        happy-holidays
        and-a-happy-new-years
    gadget. ;

New Annotation

Summary:
Author:
Mode:
Body: