Added colors to ActionScript export
This commit is contained in:
parent
06d8d18618
commit
854f0fc6e2
52
base.js
52
base.js
|
|
@ -62,6 +62,17 @@ function ave(x, y, fac) {
|
|||
return y - fac*(y-x)
|
||||
}
|
||||
|
||||
function decimalToHex(d, padding) {
|
||||
var hex = Number(d).toString(16);
|
||||
padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
|
||||
|
||||
while (hex.length < padding) {
|
||||
hex = "0" + hex;
|
||||
}
|
||||
|
||||
return hex;
|
||||
}
|
||||
|
||||
|
||||
function getObjectClass(obj) {
|
||||
/* Returns the class name of the argument or undefined if
|
||||
|
|
@ -310,7 +321,8 @@ function Layer (parent) {
|
|||
function Shape() {
|
||||
// Not part of the ActionScript spec, but necessary.
|
||||
this._shapedata = []
|
||||
this.fill = "#000000"
|
||||
this.fill = "#123456"
|
||||
this.line = "#FEDCBAFF".substr(0,7)
|
||||
this._draw = function (frame,frame2,r) {
|
||||
if (!frame2) {
|
||||
this._x = frame._x
|
||||
|
|
@ -318,19 +330,54 @@ function Shape() {
|
|||
this._xscale = frame._xscale
|
||||
this._yscale = frame._yscale
|
||||
this._rotation = frame._rotation
|
||||
if (frame.fill) {
|
||||
this.filr = parseInt(parseInt(frame.fill.replace("#",""),16)/65536)
|
||||
this.filg = parseInt(parseInt(frame.fill.replace("#",""),16)/256)%256
|
||||
this.filb = parseInt(parseInt(frame.fill.replace("#",""),16))%256
|
||||
this.linr = parseInt(parseInt(frame.line.replace("#",""),16)/65536)
|
||||
this.ling = parseInt(parseInt(frame.line.replace("#",""),16)/256)%256
|
||||
this.linb = parseInt(parseInt(frame.line.replace("#",""),16))%256
|
||||
this.fill = "#"+decimalToHex(this.filr,2)+decimalToHex(this.filg,2)+decimalToHex(this.filb,2)
|
||||
this.line = "#"+decimalToHex(this.linr,2)+decimalToHex(this.ling,2)+decimalToHex(this.linb,2)
|
||||
}
|
||||
} else {
|
||||
this._x = ave(frame2._x, frame._x, r)
|
||||
this._y = ave(frame2._y, frame._y, r)
|
||||
this._xscale = ave(frame2._xscale, frame._xscale, r)
|
||||
this._yscale = ave(frame2._yscale, frame._yscale, r)
|
||||
this._rotation = ave(frame2._rotation ,frame._rotation, r)
|
||||
if (frame2.fill) {
|
||||
this.filr2 = parseInt(parseInt(frame2.fill.replace("#",""),16)/65536)
|
||||
this.filg2 = parseInt(parseInt(frame2.fill.replace("#",""),16)/256)%256
|
||||
this.filb2 = parseInt(parseInt(frame2.fill.replace("#",""),16))%256
|
||||
this.filra = parseInt(parseInt(frame.fill.replace("#",""),16)/65536)
|
||||
this.filga = parseInt(parseInt(frame.fill.replace("#",""),16)/256)%256
|
||||
this.filba = parseInt(parseInt(frame.fill.replace("#",""),16))%256
|
||||
this.filr = parseInt(ave(this.filr2, this.filra, r))
|
||||
this.filg = parseInt(ave(this.filg2, this.filga, r))
|
||||
this.filb = parseInt(ave(this.filb2, this.filba, r))
|
||||
this.fill = "#"+decimalToHex(this.filr,2)+decimalToHex(this.filg,2)+decimalToHex(this.filb,2)
|
||||
}
|
||||
if (frame2.line) {
|
||||
this.linr2 = parseInt(parseInt(frame2.line.replace("#",""),16)/65536)
|
||||
this.ling2 = parseInt(parseInt(frame2.line.replace("#",""),16)/256)%256
|
||||
this.linb2 = parseInt(parseInt(frame2.line.replace("#",""),16))%256
|
||||
this.linra = parseInt(parseInt(frame.line.replace("#",""),16)/65536)
|
||||
this.linga = parseInt(parseInt(frame.line.replace("#",""),16)/256)%256
|
||||
this.linba = parseInt(parseInt(frame.line.replace("#",""),16))%256
|
||||
this.linr = parseInt(ave(this.linr2, this.linra, r))
|
||||
this.ling = parseInt(ave(this.ling2, this.linga, r))
|
||||
this.linb = parseInt(ave(this.linb2, this.linba, r))
|
||||
this.line = "#"+decimalToHex(this.linr,2)+decimalToHex(this.ling,2)+decimalToHex(this.linb,2)
|
||||
}
|
||||
}
|
||||
//log(this._x)
|
||||
cr.save()
|
||||
cr.translate(this._x,this._y)
|
||||
cr.rotate(this._rotation*Math.PI/180)
|
||||
cr.scale(this._xscale*1.0, this._yscale*1.0)
|
||||
cr.fillStyle = this.fill;
|
||||
cr.fillStyle = this.fill.substr(0,7);
|
||||
cr.strokeStyle = this.line.substr(0,7);
|
||||
for (i in this._shapedata) {
|
||||
if (this._shapedata[i][0]=="M") {
|
||||
cr.moveTo(this._shapedata[i][1],this._shapedata[i][2])
|
||||
|
|
@ -347,6 +394,7 @@ function Shape() {
|
|||
cr.stroke()
|
||||
}
|
||||
cr.restore()
|
||||
cr.beginPath()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ def shape(x, y, fill=None):
|
|||
shape.shapedata = [["M",0,0]]
|
||||
return shape
|
||||
|
||||
root = svlgui.Group()
|
||||
root = svlgui.Group(skipl=True)
|
||||
root.name = "_root"
|
||||
root.level = True
|
||||
root.onMouseDown = onMouseDownGroup
|
||||
|
|
@ -367,6 +367,9 @@ def bring_to_front(widget=None):
|
|||
def about(widget=None):
|
||||
svlgui.alert("Lightningbeam v1.0-alpha1\nLast Updated: "+update_date()+
|
||||
"\nCreated by: Skyler Lehmkuhl\nBased on SWIFT")
|
||||
|
||||
def preferences(widget=None):
|
||||
prefwin = svlgui.PreferencesWindow()
|
||||
|
||||
|
||||
svlgui.menufuncs([["File",
|
||||
|
|
@ -384,7 +387,7 @@ svlgui.menufuncs([["File",
|
|||
"Copy",
|
||||
"Paste",
|
||||
"Delete",
|
||||
"Preferences"],
|
||||
("Preferences",preferences,"")],
|
||||
["Timeline",
|
||||
("Add Keyframe",add_keyframe,"F5"),
|
||||
"Add Blank Keyframe",
|
||||
|
|
|
|||
25
svlgui.py
25
svlgui.py
|
|
@ -146,7 +146,7 @@ if sys.platform=="linux2":
|
|||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Label as OSXLabel, RadioGroup as OSXRadioGroup, RadioButton as OSXRadioButton
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, ModalDialog
|
||||
from GUI import StdCursors, Alerts, FileDialogs, Font
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
|
|
@ -167,7 +167,7 @@ elif sys.platform=="win32":
|
|||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Label as OSXLabel, RadioGroup as OSXRadioGroup, RadioButton as OSXRadioButton
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, ModalDialog
|
||||
from GUI import StdCursors, Alerts, FileDialogs, Font
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
|
|
@ -189,7 +189,7 @@ elif sys.platform=="darwin":
|
|||
from GUI import Window as OSXWindow, Button as OSXButton, Image as OSXImage
|
||||
from GUI import Frame as OSXFrame, Color as OSXColor, Grid as OSXGrid
|
||||
from GUI import Label as OSXLabel, RadioGroup as OSXRadioGroup, RadioButton as OSXRadioButton
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors
|
||||
from GUI import Column, Row, ScrollableView, TextEditor, Colors, ModalDialog
|
||||
from GUI import StdCursors, Alerts, FileDialogs, Font
|
||||
from GUI.StdMenus import basic_menus, file_cmds, print_cmds
|
||||
from GUI.Files import FileType
|
||||
|
|
@ -223,6 +223,7 @@ if SYSTEM=="osx":
|
|||
m.send_to_back.enabled = 1
|
||||
m.import_to_stage.enabled = 1
|
||||
m.import_to_library.enabled = 1
|
||||
m.preferences_cmd.enabled = 1
|
||||
|
||||
#def create_sc(self):
|
||||
# pass
|
||||
|
|
@ -422,7 +423,8 @@ def menufuncs(j):
|
|||
#menu = GUI.Menu("Test", [("Run", 'run_file')])
|
||||
menus.append(menu)
|
||||
else:
|
||||
cmds={"Save":"save_cmd", "Open":"open_cmd","About Lightningbeam...":"about_cmd"}
|
||||
cmds={"Save":"save_cmd", "Open":"open_cmd","About Lightningbeam...":"about_cmd",\
|
||||
"Preferences":"preferences_cmd"}
|
||||
[setattr(app,cmds[k[0]],k[1]) for k in i if (k[0] in cmds)]
|
||||
|
||||
class VBox(Widget):
|
||||
|
|
@ -1174,6 +1176,7 @@ class Shape (object):
|
|||
maxy = property(getmaxy)
|
||||
def print_html(self):
|
||||
retval = "var "+self.name+" = new Shape();\n"+self.name+"._shapedata = "+str(self.shapedata)+";\n"
|
||||
retval += self.name+".fill = \""+self.fillcolor.rgb+"\";\n"+self.name+".line = \""+self.linecolor.rgb+"\";\n"
|
||||
return retval
|
||||
|
||||
class framewrapper (object):
|
||||
|
|
@ -1927,12 +1930,12 @@ class ColorSelectionWindow:
|
|||
self.window.destroy()
|
||||
raise ObjectDeletedError
|
||||
canvas = Canvas(336,208)
|
||||
group = Group()
|
||||
group = Group(skipl=True)
|
||||
def dummy(*args):
|
||||
pass
|
||||
group._onMouseMove = dummy
|
||||
canvas.add(group,0,0)
|
||||
im = Image("media/colors.png")
|
||||
im = Image("media/colors.png",skipl=True)
|
||||
group.add(im)
|
||||
group.window = win
|
||||
group.canvas = canvas
|
||||
|
|
@ -1942,6 +1945,16 @@ class ColorSelectionWindow:
|
|||
group.onMouseDown = onClickRectLine
|
||||
win.place(canvas._int(),left=0,top=0,right=0,bottom=0,sticky="news",scrolling="")
|
||||
win.show()
|
||||
|
||||
class PreferencesWindow:
|
||||
def __init__(self):
|
||||
if SYSTEM=="osx":
|
||||
win = ModalDialog(closable=True,width=500,height=500)
|
||||
frame = Frame()
|
||||
win.place(frame._int(), left=0, top=0, right=0, bottom=0, sticky="nsew")
|
||||
label = Label("Path to Flash Debugger: ")
|
||||
frame.layout_self([label,0,None,0,None,"nw",""])
|
||||
win.present()
|
||||
|
||||
def main():
|
||||
#Executes the main loop for whatever GUI is running
|
||||
|
|
|
|||
Loading…
Reference in New Issue