Forum Replies Created
-
AuthorPosts
-
can’t get that to work. To be honest it feels more like a kludge?
It is much better to have a simple command:
method WindowResize( x:int, y:int, width:int, height:int)
I don’t need to know about ‘frame’ I just need to know I want to Resize the Window. which is how the os deals with stuff, the event system, etc, and other languages!
Frame won’t change the bounds it will however change the position of the window!
There is also no reference to frame apart from a single line of (not) help text!
So Frame is basically not documented and doesn’t operate as it should either!
My addition stands.
Here’s the complete vevtor2d class
This has all the code for loading saving and drawing a single object
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129Class Vector2dmethod New()End methodmethod New( shape:Vector2d )_points = New float[ shape._count ]If shape._count > 0 ThenLocal k:intFor k = 0 Until shape._count_points[k] = shape._points[k]Next' _points = shape._pointsEnd if_count = shape._count_lineCount = shape._lineCount_filled = shape._filledEnd methodmethod New( points:float[], count:int, filled:bool )Local lines:int = (count - 2 ) * .5_points = New float[ count ]If count > 0 ThenLocal k:intFor k = 0 Until count_points[k] = points[k]NextEnd If' _points = points_count = count_lineCount = lines_filled = filledEnd methodmethod Load( file:Stream )If not file then returnlocal filled:byte = file.ReadByte()If filled = 1 Then_filled = TrueElse_filled = FalseEnd Iflocal count:int = file.ReadInt()_points = New Float[ count ]Local k:intLocal pos:int = 0For k = 1 To count_points[ pos ] = file.ReadFloat()pos += 1Next_count = count_lineCount = (count * .5)-1End methodmethod Save( file:Stream )If not file then ReturnIf _filled Thenfile.WriteByte( 1 )Elsefile.WriteByte( 0 )End Iffile.WriteInt( _count )Local k:intLocal pos:int = 0For k = 1 To _countfile.WriteFloat( _points[ pos ] )pos += 1NextEnd methodmethod Draw( canvas:Canvas, x:int, y:int, x1:int, y1:int )Local xx:float = (x1 - x) * .5Local yy:float = (y1 - y) * .5Local zoom:float = xxIf yy < xx Then zoom = yyDraw( canvas, x + xx, y + yy, zoom )End methodmethod Draw( canvas:Canvas, x:int, y:int, zoom:float )If _lineCount < 1 Then Returnlocal k:intLocal px:int = 0Local py:int = 1Local px1:int = 2Local py1:int = 3Local x1:float = x + _points[px] * zoomLocal y1:float = y + _points[py] * zoomLocal x2:float = x + _points[px1] * zoomLocal y2:float = y + _points[py1] * zoomfor k = 1 To _lineCountcanvas.DrawLine( x1, y1, x2, y2 )px = px1py = py1px1 += 2py1 += 2x1 = x2y1 = y2If px1 < _count Thenx2 = x + _points[px1] * zoomy2 = y + _points[py1] * zoomEnd IfNextEnd methodField _points:Float[]field _count:int = 0field _lineCount:int = 0field _filled:boolEndinternally it is a single float array so that it can be passed directly to mojo.canvas
it also supports filled polygons, but not proper ones with concave parts – just the default mojo.poly
nice and simple:
here’s the individual routines
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243method Load( file:Stream )If not file then returnlocal filled:byte = file.ReadByte()If filled = 1 Then_filled = TrueElse_filled = FalseEnd Iflocal count:int = file.ReadInt()_points = New Float[ count ]Local k:intLocal pos:int = 0For k = 1 To count_points[ pos ] = file.ReadFloat()pos += 1Next_count = count_lineCount = (count * .5)-1End methodmethod Save( file:Stream )If not file then ReturnIf _filled Thenfile.WriteByte( 1 )Elsefile.WriteByte( 0 )End Iffile.WriteInt( _count )Local k:intLocal pos:int = 0For k = 1 To _countfile.WriteFloat( _points[ pos ] )pos += 1NextEnd methodand the packed ones:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748method Load( filePath:string )Local file:FileStream = FileStream.Open( filePath, "r" )If file Thenlocal Count:int = file.ReadInt()Local pos:int = 0While Not file.EofPrint "vector "+pos_vector[ pos ] = New Vector2d()_vector[ pos ].Load( file )pos += 1WendCount = pos-1_count = pos-1file.Close()App.RequestRender()ElsePrint "file not opened"End ifEnd methodmethod Save( filePath:string )If Count < 0 Then ReturnPrint filePathLocal file:FileStream = FileStream.Open( filePath, "w" )If file Thenfile.WriteInt( Count+1 )Local k:intFor k = 0 To CountIf _vector[ k ] Then_vector[ k ].Save( file )End ifNextfile.Close()ElsePrint "file not opened"End ifEnd method(not)particles complete, stars complete, vector text complete,
Starting to look not too bad….
Attachments:
Hi Matthew
Heres a couple of shots for you showing vector editing built directly into ted21 (which isn’t quite as dead as I would have thought)
Also basic app showing loading of the single vector asset (packs the vector shapes into a single file).
full rotation/scaling of vectors fully supported.
automatic bounds update and basic entity system complete
I’ve got boundsPoint and polyPoint collision implemented as well as bullets. No need for particles as I found a sneakier way of doing them…
Just writing a quick vector font system – using the same vector library
thanks guys – i’ll keep you posted
ok. All working and operational now.
I’ve added list reordering, just drag and drop for new order
Added stuff like undo, select all, etc
undo just really undoes the lat dropped point, but it will work with pre loaded vectors too!
the eyes now function, so if you click an eye, it will show the ghosted version in the drawing area
Here’s the last shot of this in stand alone app form. next up will be to integrate it directly into ted21
P.S. fast loading and saving of binary format too.
As Dmaz said above. any opened vector objects automatically save as they are documents
Attachments:
another way would be to show (some form of dialog/progress control)
update it after each load.
so for 10 loads you would be advancing at 10% after each load
good points
Here’s a quick look at things with new images and left list operational.
You can see I’ve got for clarity and simplicity. in essence you just create a whole block of ‘vector’ objects that can simply be rendered onto the screen. use multiples for different versions, use other as poly collision, etc. All wrapped up in a single unified UI.
Still doing debugging and finalising, but coming along
Attachments:
the collision is an interesting point. I was thinking of having bounds, box, circle, triangle and poly as collision.
I’ll get the basic system operational first
quick shot of progress so far with placeholder buttons and left view (the browser will live on the left)
Attachments:
Wiebow definitely a good idea. I’d love to get something that is open and what people want
All basics now complete:
drawing, moving, selecting, moving and zooming the page
yep, that’s what I thought. I’m working on the selection stuff at the moment.
It looks to me that a vector is a single line, so to construct something move complex would require multiple lines, which requires some form of grouping system.
What I thought with that is: each vector appears to the left in a sort of directory. Just select multiple entries to make an object with many lines. it would also mean you can have layers and onion skinning, etc
I’ve had a brief look over the code – thanks for that by the way
I particularly liked the general concept of the points being stored then rotated, scaled as needed into a new entity – this is exactly the same concept I’m using, so I must be on to something.
Here’s a very early dev shot of the 2d vector editor. I decided to make it look a but different from the usual dark ui so you have no doubt what section you are dealing with. Also the points snap to the lines so no floating points. Again I think this is the best way to do this as it allows very tightly aligned objects
UI elements will be added above the magnify icons (like pen, move, select, etc). The ui is in keeping with the ui I created for viewing images, so there is a consistency across everything
Attachments:
-
AuthorPosts






