Forum Replies Created
-
AuthorPosts
-
Nice looking!
What is the base for editor? Mx1, mx2, bmax, … ?
@Mark
I have idea about mojox – in views like TreeView delegate drawing command to child ‘item’ classes (Node in this case), and then we can easily override this for our custom nodes.
Also there is a way to make TreeView generic:
TreeView<T> where T extends TreeView.Node
So, custom nodes will draw themselves without changing TreeView.
Hi to all.
Let me introduce new improved version.
It based on latest official ted2 sources (1.0.7).
See screenshots below.
What do we have now:
- improved parser
– it can extract variable type from expressions like this:
Monkey1Local img := Image.Load(...) 'so img is Image type– parse lambdas, enums, method’s params
– parse ‘native’ types like @String
- improved autocompletion
– it checks current scope and access mode (public/private)
– added icons and sorting
- improved codetree
– it shows types and params
– added icons
—————–
As in previous version – parser do re-parse on load and on save document.
So if you type variable and don’t see autocompletion – just save the file and try again.
Parser is ‘in progress’, it can parse not all cases. You can notify me here about ‘problem places’.
And problems with autocompletion too.
—————–
If you don’t try Ted2Go yet – do it right now!
And maybe donate me if it’s useful for you.
Sources on github | Compiled windows version (dropbox) | Donate
Have a nice coding!
Your formula looks like a magic for me.
And it’s offtopic here.:)
Litehtml has layout engine only, not contains paint engine. So there is no css support.
About ted2 – you can find some planned features on my fork here https://github.com/engor/Ted2Go
What about official version – I don’t know.
Sorry for belated answer about my poly checking function.
I wrote demo for demonstration. It contains Polygon class and some helpers.
Full code:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280Namespace polytest#Import "<std>"#Import "<mojo>"Using std..Using mojo..Function Main()New AppInstanceLocal wnd := New AppWindow("Polygon Test", 600, 600)Local game := New GameLogicwnd.OnRenderCallback += Lambda(canvas:Canvas)game.Draw(canvas)EndApp.Run()End' AppWindowClass AppWindow Extends WindowField OnRenderCallback:Void(canvas:Canvas)Method New( title:String,width:Int,height:Int,flags:WindowFlags=Null )Super.New( title,New Recti( 0,0,width,height ),flags|WindowFlags.Center )EndMethod OnRender(canvas:Canvas) OverrideApp.RequestRender()OnRenderCallback(canvas)EndEnd' GameLogicClass GameLogicMethod New()Local poly := New Polygon(New Float[](0,0, 150,50, 200,100, 100,150))poly.Origin = New Vec2f(100,50)polyObj = New PolyObjectpolyObj.poly = polypolyObj.pos = New Vec2f(300,300)EndMethod Update()Local p := Mouse.LocationLocal over := polyObj.PointIn(p.x, p.y)polyObj.color = over ? Color.Green Else Color.BluepolyObj.poly.Rotate(0.005)EndMethod Draw(canvas:Canvas)Update() 'hm, update in draw...polyObj.Draw(canvas)EndPrivateField polyObj:PolyObjectEnd' PolyObjectClass PolyObjectField poly:PolygonField pos:Vec2fField color := Color.WhiteMethod Draw(canvas:Canvas)If poly = Null ReturnLocal p := pos-poly.Origincanvas.Translate(p.x,p.y)canvas.Color = colorcanvas.DrawPoly(poly.Points)canvas.Color *= 0.25canvas.DrawRect(poly.Bounds)canvas.Color = Color.Blackcanvas.DrawOval(poly.Origin.x-2, poly.Origin.y-2, 4, 4)EndMethod PointIn:Bool(px:Float, py:Float)px -= pos.x-poly.Origin.x 'bad place to get poly.Originpy -= pos.y-poly.Origin.yReturn poly.PointIn(px, py)EndEnd' PolygonClass PolygonMethod New(xyArray:Float[])_points = New Float[xyArray.Length]For Local k := 0 Until xyArray.Length_points[k] = xyArray[k]NextUpdateBounds()EndMethod New(rect:Rectf)_points = New Float[8]_points[0] = rect.Left_points[1] = rect.Top_points[2] = rect.Right_points[3] = rect.Top_points[4] = rect.Right_points[5] = rect.Bottom_points[6] = rect.Left_points[7] = rect.Bottom_bounds = rectEndProperty Points:Float[]()Return _pointsEndProperty Bounds:Rectf()Return _boundsEndProperty Origin:Vec2f()Return _originSetter(value:Vec2f)_origin = valueEndProperty Rotation:Float()Return _rotationEndMethod Rotate(angle:Float)Local ox := _origin.xLocal oy := _origin.yLocal cos := Cos(angle)Local sin := Sin(angle)For Local k := 0 Until _points.Length Step 2Local px := _points[k]-oxLocal py := _points[k+1]-oy_points[k] = ox + px*cos - py*sin_points[k+1] = oy + px*sin + py*cosNext_rotation = (_rotation + angle) Mod 360.0UpdateBounds()EndMethod Move(dx:Float, dy:Float)For Local k := 0 Until _points.Length Step 2_points[k] += dx_points[k+1] += dyNextLocal v := New Vec2f(dx,dy)_bounds += v_origin += vEndMethod PointIn:Bool(point:Vec2f)If Not _bounds.Contains(point) Then Return FalseReturn PointIn(_points,point)EndMethod PointIn:Bool(px:Float, py:Float)Return PointIn(New Vec2f(px,py))EndFunction PointIn:Bool(xy:Float[], point:Vec2f)Local px := point.x, py := point.yLocal x1:Float, y1:Float, x2:Float, y2:FloatLocal koef:Float, koefA:FloatLocal cnt:Int = xy.LengthLocal sign:Int, sign2:IntFor Local k := 0 Until cnt Step 2x1 = xy[k]y1 = xy[k + 1]If k + 3 < cntx2 = xy[k + 2]y2 = xy[k + 3]Else 'connect with first pointx2 = xy[0]y2 = xy[1]Endifsign = Sgn(x2 - x1)sign2 = Sgn(px - x1)'prevent division by zeroIf sign = 0x2 += 0.0001sign = 1EndifIf sign2 = 0px += 0.0001sign2 = 1EndIf'the slope coefficient (y = k*x + b)koef = (y1 - y2) / (x2 - x1)koefA = (y1 - py) / (px - x1)'checkingIf (sign2 = sign And koefA > koef) Or (sign2 <> sign And koefA < koef)Return FalseEndifNextReturn TrueEnd FunctionPrivateField _points:Float[] 'xy pairs in one dimention arrayField _bounds:Rectf 'bounds used for fast collision detectionField _origin := New Vec2f(0,0)Field _rotation:FloatMethod UpdateBounds()Local minX := _points[0]Local maxX := _points[0]Local minY := _points[1]Local maxY := _points[1]For Local k := 2 Until _points.Length Step 2Local px := _points[k]Local py := _points[k+1]If px < minXminX = pxElseif px > maxXmaxX = pxEndifIf py < minYminY = pyElseif py > maxYmaxY = pyEndifNextIf _bounds = Null Then _bounds = New Rectf_bounds.Left = minX_bounds.Right = maxX_bounds.Top = minY_bounds.Bottom = maxYEndEndLooked nice! keep doing
Working on code parser I just added simple CodeTreeView navigator – I need it to see parsing result.
There are idents only in the tree, that’s enough for the moment.
All variables started with Local, Field and so on is presented here, even if they are deep inside of For, If, etc. Will be fixed later.
CodeTreeView filled on document open, don’t adjust changes yet.
Click on item – jump to line with it.
Attachments:
I’m using the latest version (1.0.6).
But my code is dirty now; I clean up it when complete common features (like checking current scope and getting variable types in := expression.
Now I’m using ‘dev’ branch for undone things.
It’s bad idea to use ‘this’ as var name because it’s reserved word in c++ (into which monkey code translating).
Useful git command for all fork-men:
Monkey1git subtree split -P src/ted2 -b ted2onlySeparate all-and-only ted2 changes into custom branch.
Then we can easily merge with our fork – pull from branch ted2only into fork repo (if repo contains ted2 stuff only, not all monkey2).
Atlas editor is greate thing, good luck with it!
It would be nice to implement Animation creation tool in Ted… but this requires to code some relative stuff like Animator and AnimationClip. Something like in unity3d, simplier of course.
Nice to hear you!
and fast compiling
Because there is just a bit of code. Ted2 is small app
But ‘clean’ compiling (no cached files yet) makes me wait.
What does exactly mean += in this case?
This mean ‘subscribe’ to KeyEventFilter function inside of App.
This Lambda is a listener.
So all listeners subscribed to KeyEventFilter (via += operator) will be called when App begin processing keyboard event.
This call is usual function call, in our case: KeyEventFilter(event)
If there is no one listener subscribed to then nothing happen.
-
AuthorPosts




