Skip to content

Instantly share code, notes, and snippets.

@diverted247
Created March 28, 2013 16:40
Show Gist options
  • Save diverted247/5264761 to your computer and use it in GitHub Desktop.
Save diverted247/5264761 to your computer and use it in GitHub Desktop.
A small light.ly hello world app.
//imports
appjs : import = js/app.js
core: import = light/core.js
html: import = light/html.js
easeljs : import = js/easel.js
//references
application:@ = core.application
event:@ = core.listener
hc:@ = html.canvas
cs:@ = createjs.Shape
ct:@ = createjs.Text
cg:@ = createjs.Graphics
cst:@ = createjs.Stage
app:application
canvas:hc
addTo:! = document.body[0]
resize:event
method:@ = appjs.resize
this:@ = window
stage:cst
canvas:@ = app.canvas
snapToPixel:bool = true
panel:cs
graphic:cg
beginFill:!
cg.getRGB:!
0:n=150
1:n=150
2:n=150
drawRoundRect:!
0:n=0
1:n=0
2:n=250
3:n=1000
4:n=0
x:n=10
y:n=10
addTo:! = app.stage
text:createjs.Text
text = "Hello Light.ly - Composition Framework"
font = "100px 'Ashley Inline MT W00'"
color = "#000"
snapToPixel:bool = true
textAlign = "center"
textBaseline = "middle"
addTo:! = app.stage
//call init in appjs
appjs.init:!
@diverted247
Copy link
Author

Light is a line based format. It reads top to bottom by line and whitespace matters!

Light parses this into an array that is executed in 2 passes. First pass we import libs via the loader and map all types to make sure there are no errors. Second pass we render top to bottom. Indentation denotes nesting under the prior level object.

Each line has a simple format: name : type = value

The goal is to have a light configuration language and runtime to setup an app from scratch from component parts via composition. In my experience, most apps are just trees of objects wired within objects, light makes this process linear and easy to read, write, & extend. Plus once you get the hang of it, it is fun.

More soon, I have this app running in an early build integrated with easeljs.

Ted :)

@pdehaan
Copy link

pdehaan commented Mar 28, 2013

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment