Skip to content
Browse files

- reorganized folders (sorry Aaron :)), added scripts.json and build…

….lua to build your art.js file.
  • Loading branch information...
1 parent 54d9c05 commit 130f601c794d60b6637b42bffcab3a663e1c732a @kamicane kamicane committed Apr 2, 2009
View
1 .gitignore
@@ -0,0 +1 @@
+art.js
View
7 art.widget.js → Source/Base/ART.Widget.js
@@ -1,4 +1,9 @@
-// art.widget.js
+/*
+Script: ART.Widget.js
+
+License:
+ MIT-style license.
+*/
// Base widget class. Based on » http://gist.github.com/85837
View
8 Source/Base/ART.js
@@ -0,0 +1,8 @@
+/*
+Script: ART.js
+
+License:
+ MIT-style license.
+*/
+
+var ART = function(){};
View
0 fonts/mgopen.license.txt → Source/Fonts/MgOpen.License.txt
File renamed without changes.
View
0 fonts/moderna.bold.js → Source/Fonts/MgOpen.Moderna.Bold.js
File renamed without changes.
View
0 fonts/moderna.js → Source/Fonts/MgOpen.Moderna.js
File renamed without changes.
View
7 art.adapter.canvas.js → Source/Paint/ART.Adapter.Canvas.js
@@ -1,4 +1,9 @@
-// Canvas Adapter.
+/*
+Script: ART.Adapter.Canvas.js
+
+License:
+ MIT-style license.
+*/
ART.Adapter.Canvas = new Class({
View
7 art.adapter.js → Source/Paint/ART.Adapter.js
@@ -1,4 +1,9 @@
-// art.adapter.js
+/*
+Script: ART.Adapter.js
+
+License:
+ MIT-style license.
+*/
// Generic adapter base Class.
View
7 art.paint.js → Source/Paint/ART.Paint.js
@@ -1,4 +1,9 @@
-// art.paint.js
+/*
+Script: ART.Paint.js
+
+License:
+ MIT-style license.
+*/
// kappa!
View
7 art.shape.js → Source/Paint/ART.Shape.js
@@ -1,4 +1,9 @@
-// art.shape.js
+/*
+Script: ART.Shape.js
+
+License:
+ MIT-style license.
+*/
// ART.Shape Class stub.
// Will probably support defining shapes as json at some point.
View
7 art.text.js → Source/Paint/ART.Text.js
@@ -1,4 +1,9 @@
-// art.font.js
+/*
+Script: ART.Font.js
+
+License:
+ MIT-style license.
+*/
// ==========================================
// This file implements code from Cufón
View
9 art.button.js → Source/Widgets/ART.Widget.Button.js
@@ -1,8 +1,13 @@
-// art.button.js
+/*
+Script: ART.Widget.Button.js
+
+License:
+ MIT-style license.
+*/
// Button Widget. Work in progress.
-ART.Button = new Class({
+ART.Widget.Button = new Class({
Extends: ART.Widget,
View
25 art.window.js → Source/Widgets/ART.Widget.Window.js
@@ -1,8 +1,13 @@
-// art.window.js
+/*
+Script: ART.Widget.Window.js
+
+License:
+ MIT-style license.
+*/
// Window Widget. Work in progress.
-ART.Window = new Class({
+ART.Widget.Window = new Class({
Extends: ART.Widget,
@@ -190,20 +195,16 @@ ART.Window = new Class({
if (this.options.resize){
+ var drawLines = function(self){
+ self.paint.lineBy({x: -10, y: 10}).moveBy({x: 4, y: 0}).lineBy({x: 6, y: -6}).moveBy({x: 0, y: 4}).lineBy({x: -2, y: 2});
+ };
+
this.paint.start({x: now.width - 4, y: now.height - 14});
- this.paint.lineBy({x: -10, y: 10});
- this.paint.moveBy({x: 4, y: 0});
- this.paint.lineBy({x: 6, y: -6});
- this.paint.moveBy({x: 0, y: 4});
- this.paint.lineBy({x: -2, y: 2});
+ drawLines(this);
this.paint.end({'stroke': true, 'stroke-color': hsb(0, 0, 100, 0.6)});
this.paint.start({x: now.width - 5, y: now.height - 14});
- this.paint.lineBy({x: -10, y: 10});
- this.paint.moveBy({x: 4, y: 0});
- this.paint.lineBy({x: 6, y: -6});
- this.paint.moveBy({x: 0, y: 4});
- this.paint.lineBy({x: -2, y: 2});
+ drawLines(this);
this.paint.end({'stroke': true, 'stroke-color': hsb(0, 0, 0, 0.6)});
}
View
74 Source/scripts.json
@@ -0,0 +1,74 @@
+{
+
+ "Base": {
+
+ "ART": {
+ "deps": [],
+ "desc": "The base ART Class."
+ },
+
+ "ART.Widget": {
+ "deps": ["ART"],
+ "desc": "Barebones ART Widget."
+ }
+
+ },
+
+ "Paint": {
+
+ "ART.Adapter": {
+ "deps": ["ART"],
+ "desc": "ART Graphic Adapter."
+ },
+
+ "ART.Adapter.Canvas": {
+ "deps": ["ART.Adapter"],
+ "desc": "Adds Canvas support to ART.Adapter."
+ },
+
+ "ART.Paint": {
+ "deps": ["ART.Adapter.Canvas"],
+ "desc": "Public Class for painting stuff. Extends ART.Adapter."
+ },
+
+ "ART.Shape": {
+ "deps": ["ART.Paint"],
+ "desc": "Adds some shapes, and implements the shape method to ART.Paint."
+ },
+
+ "ART.Text": {
+ "deps": ["ART.Paint"],
+ "desc": "Adds font drawing support (thanks to Cufón), and implements the text method to ART.Paint."
+ }
+
+ },
+
+ "Fonts": {
+
+ "MgOpen.Moderna": {
+ "deps": ["ART.Text"],
+ "desc": "Open source font to use with ART.Paint."
+ },
+
+ "MgOpen.Moderna.Bold": {
+ "deps": ["ART.Text"],
+ "desc": "Bold version of the Moderna Font."
+ }
+
+ },
+
+ "Widgets": {
+
+ "ART.Widget.Button": {
+ "deps": ["ART.Widget", "ART.Text"],
+ "desc": "Button widget."
+ },
+
+ "ART.Widget.Window": {
+ "deps": ["ART.Widget", "ART.Text"],
+ "desc": "Window widget."
+ }
+
+ }
+
+}
View
5 art.js
@@ -1,5 +0,0 @@
-// art.js
-
-// NS.
-
-var ART = function(){};
View
158 build.lua
@@ -0,0 +1,158 @@
+#!/usr/bin/env lua
+
+--[[
+
+# USAGE:
+
+Full Build
+----------
+
+./build.lua
+
+Partial Build (includes dependancies)
+-------------------------------------
+
+./build.lua ART.Paint ART.Widget
+
+--]]
+
+require "luarocks.require"
+require "json"
+
+-- table.include ()
+-- includes a value in a table if not already present
+
+function table:include(included)
+
+ local present = false
+
+ for key, value in ipairs(self) do
+ if value == included then
+ present = true
+ break
+ end
+ end
+
+ if not present then table.insert(self, included) end
+
+ return self
+
+end
+
+-- Build ()
+-- builds MooTools
+
+local function Build(selected)
+
+ json_path = "Source/scripts.json"
+ scripts_path = "Source/"
+ output_path = "art.js"
+
+ -- scripts {}
+ -- the json structure as a table
+
+ scripts = {}
+
+ -- all {}
+ -- a list of every script
+
+ all = {}
+
+ for folder, files in pairs(json.decode(io.open(json_path):read("*all"))) do
+
+ scripts[folder] = {}
+
+ local folder = scripts[folder]
+
+ for script, props in pairs(files) do
+ folder[script] = props.deps
+ table.insert(all, script)
+ end
+ end
+
+ -- folder_of ()
+ -- returns the folder name from a script
+
+ function folder_of(name)
+
+ for folder, files in pairs(scripts) do
+ for file in pairs(files) do
+ if file == name then return folder end
+ end
+ end
+
+ end
+
+ -- deps_of ()
+ -- returns a table containing the full dependancies of a file
+
+ function deps_of(name)
+
+ local list = {}
+
+ -- if name == "ART" then return list end
+
+ local deps = scripts[folder_of(name)][name];
+
+ for i, script in ipairs(deps) do
+ for j, scr in ipairs(deps_of(script)) do table.include(list, scr) end
+ table.include(list, script)
+ end
+
+ return list
+
+ end
+
+ -- build ()
+ -- builds from a list of scripts
+
+ function build(scripts)
+
+ local list = {}
+
+ for i, name in ipairs(scripts) do
+ for i, dep in ipairs(deps_of(name)) do table.include(list, dep) end
+ table.include(list, name)
+ end
+
+ -- write art
+
+ io.write("\nART Built as " .. output_path .. "\n\n")
+ io.write("Included Scripts: ")
+
+ local mootools = io.open(output_path, "w+")
+
+ for i, file in ipairs(list) do
+ io.write(file .. ".js")
+ local str = io.open(scripts_path .. folder_of(file) .. "/" .. file .. ".js"):read("*all")
+
+ -- %build% replace
+
+ if file == "Core" then
+
+ local ref = io.open('.git/HEAD'):read("*all"):match("ref: ([%w/]+)")
+ ref = io.open('.git/' .. ref):read("*all"):match("(%w+)")
+ str = str:gsub("%%build%%", ref)
+
+ end
+
+ mootools:write(str)
+ if i ~= table.maxn(list) then
+ mootools:write("\n")
+ io.write(", ")
+ end
+ end
+
+ io.write("\n\n")
+
+ end
+
+ -- checks arg
+
+ if table.maxn(selected) == 0 then build(all) else build(selected) end
+
+end
+
+-- builds mootools
+
+Build(arg)

0 comments on commit 130f601

Please sign in to comment.
Something went wrong with that request. Please try again.