Created
October 30, 2024 01:27
-
-
Save mworzala/a110c34ecd2aa057c934a4ac600649c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Vec2 = { | |
x: number, | |
y: number, | |
} | |
-- METADATA | |
declare function javaClass(name: string) | |
-- SPRITE CONFIGURATION | |
declare class Sprite end | |
export type AnySprite = Sprite | string | |
declare class SliceOpts end | |
-- Slices like a vanilla chest. The prefixHeight is the height of the header, | |
-- right after should be the slots followed by any height footer. | |
declare function rowSlice(prefixHeight: number): SliceOpts | |
-- all | vertical, horizontal | top, right, bottom, left | |
export type NineSliceCtor = ((number) -> SliceOpts) & ((number, number) -> SliceOpts) & ((number, number, number, number) -> SliceOpts) | |
declare nineSlice: NineSliceCtor | |
declare function stretch(): SliceOpts | |
export type SpriteOpts = { | |
originX: number?, | |
originY: number?, | |
slice: SliceOpts?, | |
} | |
declare function sprite(path: string, opts: SpriteOpts?): AnySprite | |
-- BASE COMPONENTS | |
declare class AnyComponent | |
function frame(self, width: number, height: number): AnyComponent | |
end | |
export type AnyViewProps = { | |
background: AnySprite?, | |
} | |
export type AnyContainerProps = AnyViewProps & { | |
[number]: AnyComponent, -- Children | |
} | |
-- Basics | |
declare function label(opts: any): AnyComponent | |
declare function button(opts: any): AnyComponent | |
declare function text(opts: any): AnyComponent | |
export type CTextOpts = { | |
value: string, | |
} | |
declare function ctext(opts: CTextOpts): AnyComponent | |
-- Layout Primitives | |
export type HStackOpts = AnyContainerProps | |
declare function hstack(opts: HStackOpts): AnyComponent | |
export type VStackOpts = AnyContainerProps | |
declare function vstack(opts: VStackOpts): AnyComponent | |
-- View Declaration | |
export type ComponentOpts = VStackOpts & { | |
displayName: string?, | |
} | |
-- Implicitly a HStack | |
declare function view(o: ComponentOpts): {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment