The graphics state functions are non nullable field, but in the java script they are set initially to null in the java script
alpha antialias brush font pen
So I changed it to, but now the initial states are probably incorrect, but at least they are not null.
fan.fwt.Graphics.prototype.m_brush = fan.gfx.Color.makeRgb(255,255,255)
fan.fwt.Graphics.prototype.m_pen = new fan.gfx.Pen()
fan.fwt.Graphics.prototype.m_font = new fan.gfx.Font()
fan.fwt.Graphics.prototype.m_antialias = false
fan.fwt.Graphics.prototype.m_alpha = 0
This is a solution, but think is good to think a bit better about the initial state of the paint object. Since in the current situation certain field are set in the paint function each time it is called.
You always get a new Graphics context instance every time paint is called, so thats ok. We currently default the fields in fan.fwt.Graphics.paint - so we can just add those in there.
Also just FYI:
(1) General rule is to always set your default field values in your constructor. We properly order our types so a serial parse of the JavaScript works. But if you define fields in the global context, you will likely attempt to access a type that has not yet been defined.
(2) As another general rule, you should never invoke a Fantom object using new in JavaScript - because that will not invoke the Fantom make constructor, and can leave the object in an invalid state. So you should always use the static make call, for example, fan.gfx.Point.make(0,0)
jessevdam Wed 27 Jul 2011
The graphics state functions are non nullable field, but in the java script they are set initially to null in the java script
alpha antialias brush font pen
So I changed it to, but now the initial states are probably incorrect, but at least they are not null.
This is a solution, but think is good to think a bit better about the initial state of the paint object. Since in the current situation certain field are set in the paint function each time it is called.
andy Wed 27 Jul 2011
You always get a new Graphics context instance every time paint is called, so thats ok. We currently default the fields in fan.fwt.Graphics.paint - so we can just add those in there.
Also just FYI:
(1) General rule is to always set your default field values in your constructor. We properly order our types so a serial parse of the JavaScript works. But if you define fields in the global context, you will likely attempt to access a type that has not yet been defined.
(2) As another general rule, you should never invoke a Fantom object using
new
in JavaScript - because that will not invoke the Fantommake
constructor, and can leave the object in an invalid state. So you should always use the staticmake
call, for example,fan.gfx.Point.make(0,0)
andy Wed 27 Jul 2011
Pushed a fix