Mark Sibly 9 years ago
parent
commit
702042d5de

+ 1 - 1
modules/std/collections/container.monkey2

@@ -3,7 +3,7 @@ Namespace std.collections
 
 
 #rem monkeydoc The IContainer interface is a 'dummy' interface that container classes should implement for compatibility with [[Eachin]] loops.
 #rem monkeydoc The IContainer interface is a 'dummy' interface that container classes should implement for compatibility with [[Eachin]] loops.
 
 
-IContainer does not actually declare any members, but a class that implements IContainer should implement the follow method:
+IContainer does not actually declare any members, but a class that implements IContainer should implement the follow methods:
 
 
 `Method All:IteratorType()` - Gets an iterator to all values in the container.
 `Method All:IteratorType()` - Gets an iterator to all values in the container.
 
 

+ 15 - 1
modules/std/collections/list.monkey2

@@ -1,11 +1,25 @@
 
 
 Namespace std.collections
 Namespace std.collections
 
 
+#rem monkeydoc Convenience type alias for List\<Int\>.
+#end
 Alias IntList:List<Int>
 Alias IntList:List<Int>
+
+#rem monkeydoc Convenience type alias for List\<Float\>.
+#end
 Alias FloatList:List<Float>
 Alias FloatList:List<Float>
+
+#rem monkeydoc Convenience type alias for List\<String\>.
+#end
 Alias StringList:List<String>
 Alias StringList:List<String>
 
 
-#rem monkeydoc The list class provides support for doubly linked lists.
+#rem monkeydoc The List class provides support for linked lists.
+
+A linked list is a container style data structure that provides efficient support for the addition, removal and sequential traversal of objects.
+
+A linked list works by connecting elements together with 'next' and 'previous' references, making it very efficient to get from one element to the next, but not so efficient for accessing arbitrary elements.
+
+This connection between elements is achieved using separate Node objects (there is one per element) which contain references to the next and previous nodes in the list, as well as the actual object managed by the node.
 
 
 Lists implements the [[IContainer]] interface so can be used with [[Eachin]] loops.
 Lists implements the [[IContainer]] interface so can be used with [[Eachin]] loops.
 
 

+ 16 - 1
modules/std/collections/map.monkey2

@@ -1,13 +1,28 @@
 
 
 Namespace std.collections
 Namespace std.collections
 
 
+#rem monkeydoc Convenience type alias for Map\<Int,V\>.
+#end
 Alias IntMap<V>:Map<Int,V>
 Alias IntMap<V>:Map<Int,V>
 
 
+#rem monkeydoc Convenience type alias for Map\<Float,V\>.
+#end
 Alias FloatMap<V>:Map<Float,V>
 Alias FloatMap<V>:Map<Float,V>
 
 
+#rem monkeydoc Convenience type alias for Map\<String,V\>.
+#end
 Alias StringMap<V>:Map<String,V>
 Alias StringMap<V>:Map<String,V>
 
 
-#rem monkeydoc The Map class.
+#rem monkeydoc The Map class provides support for associative maps.
+
+A map is a container style object that provides a mechanism for associating 'key' objects with 'value' objects.
+This is done using an internal node object that contains a reference to both a key and a value, along with information about the node'
+s location within the map.
+
+Each key in a map occurs exactly once - a map cannot contain multiple equivalent keys.
+
+Maps can handle inserting, removing and finding keys in 'O(log2)' time. That is, the time needed to insert, remove or find a key is proportional to log2 of the number of items in the map.
+
 #end
 #end
 Class Map<K,V>
 Class Map<K,V>
 
 

+ 18 - 1
modules/std/collections/stack.monkey2

@@ -1,13 +1,30 @@
 
 
 Namespace std.collections
 Namespace std.collections
 
 
+#rem monkeydoc Convenience type alias for Stack\<Int\>.
+#end
 Alias IntStack:Stack<Int>
 Alias IntStack:Stack<Int>
 
 
+#rem monkeydoc Convenience type alias for Stack\<Float\>.
+#end
 Alias FloatStack:Stack<Float>
 Alias FloatStack:Stack<Float>
 
 
+#rem monkeydoc Convenience type alias for Stack\<String\>.
+#end
 Alias StringStack:Stack<String>
 Alias StringStack:Stack<String>
 
 
-#rem monkeydoc The Stack class.
+#rem monkeydoc The Stack class provides suport for dynamic arrays.
+
+A stack is an 'array like' container that grows dynamically as necessary.
+
+It is very cheap to add values to the end of a stack, but insertion or removal of values requires higher indexed values to be 
+'shifted down'.
+
+Stacks implement the [[IContainer]] interface so can be used with [[Eachin]] loops.
+
+Note that you should NOT modify a stack while iterating through it with an eachin loop. Doing so while cause a 'concurrent stack
+modification' runtime error in debug mode. Please see [[IContainer]] for more information.
+
 #end
 #end
 Class Stack<T> Implements IContainer<T>
 Class Stack<T> Implements IContainer<T>
 
 

+ 34 - 1
modules/std/fiber/fiber.monkey2

@@ -20,28 +20,61 @@ Function GetCurrentFiber:Int()="bbFiber::GetCurrentFiber"
 
 
 Public
 Public
 
 
+#rem monkeydoc Fibers provides support for cooperative multitasking.
+
+A Fiber is a lightweight 'thread of execution' that can be used to achieve a form of cooperative multitasking.
+
+A fiber can be in one of 4 states:
+
+* Running. There is only ever one fiber in the running state at a time. This is the fiber returned by [[Current]].
+
+* Suspended. A fiber is in the suspended state if it has called [[Suspend]]. A suspended fiber can only be returned to the running state
+by some other fiber calling [[Resume]] on it.
+
+* Paused. A fiber is in the paused state after it has called [[Resume]] on another fiber and that fiber has resumed running. A paused
+fiber will continue running when the fiber it resumed calls [[Suspend]] or exits normally. A fiber is also paused after creating a new 
+fiber, ie: creating a new fiber also implicty resumes the new fiber.
+
+* Terminated. The fiber has either returned from it's entry function, or has been explicitly terminated via a call to [[Terminate]].
+
+#end
 Struct Fiber
 Struct Fiber
 
 
+	#rem monkeydoc Creates a new fiber.
+	
+	Creates a new fiber and starts it running.
+	
+	#end
 	Method New( entry:Void() )
 	Method New( entry:Void() )
 		_fiber=StartFiber( entry )
 		_fiber=StartFiber( entry )
 	End
 	End
-	
+
+	#rem monkeydoc Resumes a suspended fiber.
+	#end	
 	Method Resume()
 	Method Resume()
 		ResumeFiber( _fiber )
 		ResumeFiber( _fiber )
 	End
 	End
 	
 	
+	#rem monkeydoc Terminates a fiber.
+	#end
 	Method Terminate()
 	Method Terminate()
 		TerminateFiber( _fiber )
 		TerminateFiber( _fiber )
 	End
 	End
 	
 	
+	#rem monkeydoc Suspends the current fiber.
+	#end
 	Function Suspend()
 	Function Suspend()
 		SuspendCurrentFiber()
 		SuspendCurrentFiber()
 	End
 	End
 	
 	
+	#rem monkeydoc Gets the currently running fiber.
+	#end
 	Function Current:Fiber()
 	Function Current:Fiber()
 		Return New Fiber( GetCurrentFiber() )
 		Return New Fiber( GetCurrentFiber() )
 	End
 	End
 	
 	
+	#rem monkeydoc @hidden - not really needed?
+	#end
 	Function CreateSuspended:Fiber( entry:Void() )
 	Function CreateSuspended:Fiber( entry:Void() )
 		Return New Fiber( CreateFiber( entry ) )
 		Return New Fiber( CreateFiber( entry ) )
 	End
 	End

BIN
modules/std/fiber/future.monkey2


+ 38 - 6
modules/std/geom/affinemat3.monkey2

@@ -1,22 +1,37 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc Convenience type alias for AffineMat3\<Float\>
+#end
 Alias AffineMat3f:AffineMat3<Float>
 Alias AffineMat3f:AffineMat3<Float>
 
 
+#rem monkeydoc Affine 3x3 matrix class.
+
+An affine 3x3 matrix is a 3x3 matrix whose right hand column is always 0,0,1.
+
+Affine 3x3 matrices are often used for 2d transformations such as scaling, rotation and translation.
+
+#end
 Struct AffineMat3<T>
 Struct AffineMat3<T>
 
 
+	#rem monkeydoc The first row of the matrix.
+	#end
 	Field i:Vec2<T>
 	Field i:Vec2<T>
+	
+	#rem monkeydoc The second row of the matrix.
+	#end
 	Field j:Vec2<T>
 	Field j:Vec2<T>
-	Field t:Vec2<T>
 	
 	
+	#rem monkeydoc The third row of the matrix.
+	#end
+	Field t:Vec2<T>
+
+	#rem monkeydoc Creates a new matrix.
+	#end
 	Method New()
 	Method New()
 		i.x=1;j.y=1
 		i.x=1;j.y=1
 	End
 	End
 	
 	
-'	Method New( m:AffineMat3 )
-'		i=m.i;j=m.j;t=m.t
-'	End
-	
 	Method New( i:Vec2<T>,j:Vec2<T>,t:Vec2<T> )
 	Method New( i:Vec2<T>,j:Vec2<T>,t:Vec2<T> )
 		Self.i=i;Self.j=j;Self.t=t
 		Self.i=i;Self.j=j;Self.t=t
 	End
 	End
@@ -25,6 +40,8 @@ Struct AffineMat3<T>
 		Self.i.x=ix;Self.i.y=iy;Self.j.x=jx;Self.j.y=jy;Self.t.x=tx;Self.t.y=ty
 		Self.i.x=ix;Self.i.y=iy;Self.j.x=jx;Self.j.y=jy;Self.t.x=tx;Self.t.y=ty
 	End
 	End
 	
 	
+	#rem monkeydoc Returns the inverse of the matrix.
+	#end
 	Operator-:AffineMat3()
 	Operator-:AffineMat3()
 		Local idet:=1.0/(i.x*j.y-i.y*j.x)
 		Local idet:=1.0/(i.x*j.y-i.y*j.x)
 		Return New AffineMat3(
 		Return New AffineMat3(
@@ -33,10 +50,14 @@ Struct AffineMat3<T>
 			(j.x*t.y-j.y*t.x)*idet , (i.y*t.x-i.x*t.y)*idet )
 			(j.x*t.y-j.y*t.x)*idet , (i.y*t.x-i.x*t.y)*idet )
 	End
 	End
 	
 	
+	#rem monkeydoc Multiplies a vector by the matrix and returns the result.
+	#end
 	Operator*:Vec2<T>( v:Vec2<T> )
 	Operator*:Vec2<T>( v:Vec2<T> )
 		Return New Vec2<T>( i.x*v.x + j.x*v.y + t.x , i.y*v.x + j.y*v.y + t.y )
 		Return New Vec2<T>( i.x*v.x + j.x*v.y + t.x , i.y*v.x + j.y*v.y + t.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Multiplies the matrix by another matrix and returns the result.
+	#end
 	Operator*:AffineMat3( m:AffineMat3 )
 	Operator*:AffineMat3( m:AffineMat3 )
 		Return New AffineMat3(
 		Return New AffineMat3(
 			i.x*m.i.x + j.x*m.i.y       , i.y*m.i.x + j.y*m.i.y ,
 			i.x*m.i.x + j.x*m.i.y       , i.y*m.i.x + j.y*m.i.y ,
@@ -44,10 +65,14 @@ Struct AffineMat3<T>
 			i.x*m.t.x + j.x*m.t.y + t.x , i.y*m.t.x + j.y*m.t.y + t.y )
 			i.x*m.t.x + j.x*m.t.y + t.x , i.y*m.t.x + j.y*m.t.y + t.y )
 	End
 	End
 			
 			
+	#rem monkeydoc Multiplies a vector by the matrix and returns the result.
+	#end
 	Method Transform:Vec2<T>( x:T,y:T )
 	Method Transform:Vec2<T>( x:T,y:T )
 		Return New Vec2<T>( i.x*x + j.x*y + t.x , i.y*x + j.y*y + t.y )
 		Return New Vec2<T>( i.x*x + j.x*y + t.x , i.y*x + j.y*y + t.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Multiplies the matrix by another matrix and returns the result.
+	#end
 	Method Transform:AffineMat3( ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float )
 	Method Transform:AffineMat3( ix:Float,iy:Float,jx:Float,jy:Float,tx:Float,ty:Float )
 		Return New AffineMat3(
 		Return New AffineMat3(
 			i.x*ix + j.x*iy       , i.y*ix + j.y*iy ,
 			i.x*ix + j.x*iy       , i.y*ix + j.y*iy ,
@@ -55,6 +80,8 @@ Struct AffineMat3<T>
 			i.x*tx + j.x*ty + t.x , i.y*tx + j.y*ty + t.y )
 			i.x*tx + j.x*ty + t.x , i.y*tx + j.y*ty + t.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Applies a translation transformation to the matrix and returns the result.
+	#end
 	Method Translate:AffineMat3( v:Vec2<T> )
 	Method Translate:AffineMat3( v:Vec2<T> )
 		Return Transform( 1,0,0,1,v.x,v.y )
 		Return Transform( 1,0,0,1,v.x,v.y )
 	End
 	End
@@ -63,10 +90,14 @@ Struct AffineMat3<T>
 		Return Transform( 1,0,0,1,tx,ty )
 		Return Transform( 1,0,0,1,tx,ty )
 	End
 	End
 	
 	
+	#rem monkeydoc Applies a rotation transformation to the matrix and returns the result.
+	#end
 	Method Rotate:AffineMat3( rz:Double )
 	Method Rotate:AffineMat3( rz:Double )
 		Return Transform( Cos( rz ),-Sin( rz ),Sin( rz ),Cos( rz ),0,0 )
 		Return Transform( Cos( rz ),-Sin( rz ),Sin( rz ),Cos( rz ),0,0 )
 	End
 	End
 	
 	
+	#rem monkeydoc Applies a scale transformation to the matrix and returns the result.
+	#end
 	Method Scale:AffineMat3( v:Vec2<T> )
 	Method Scale:AffineMat3( v:Vec2<T> )
 		Return Transform( v.x,0,0,v.y,0,0 )
 		Return Transform( v.x,0,0,v.y,0,0 )
 	End
 	End
@@ -75,6 +106,8 @@ Struct AffineMat3<T>
 		Return Transform( sx,0,0,sy,0,0 )
 		Return Transform( sx,0,0,sy,0,0 )
 	End
 	End
 
 
+	#rem monkeydoc @hidden
+	#end
 	Function Ortho:AffineMat3( left:T,right:T,bottom:T,top:T )
 	Function Ortho:AffineMat3( left:T,right:T,bottom:T,top:T )
 
 
 		Local w:=right-left,h:=top-bottom
 		Local w:=right-left,h:=top-bottom
@@ -87,5 +120,4 @@ Struct AffineMat3<T>
 		Return r
 		Return r
 	End
 	End
 	
 	
-	
 End
 End

+ 10 - 0
modules/std/geom/axis.monkey2

@@ -1,6 +1,16 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc Axis enumeration.
+
+| Axis	| Description
+|:------|:-----------
+| `X`	| X axis
+| `Y`	| Y axis
+| `Z`	| Z axis
+| `W`	| W axis
+
+#end
 Enum Axis
 Enum Axis
 	X=0,Y=1,Z=2,W=3
 	X=0,Y=1,Z=2,W=3
 End
 End

+ 4 - 0
modules/std/geom/mat3.monkey2

@@ -1,8 +1,12 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc @hidden
+#end
 Alias Mat3f:Mat3<Float>
 Alias Mat3f:Mat3<Float>
 
 
+#rem monkeydoc @hidden
+#end
 Struct Mat3<T>
 Struct Mat3<T>
 
 
 	Field i:Vec3<T>
 	Field i:Vec3<T>

+ 4 - 0
modules/std/geom/mat4.monkey2

@@ -1,8 +1,12 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc @hidden
+#end
 Alias Mat4f:Mat4<Float>
 Alias Mat4f:Mat4<Float>
 
 
+#rem monkeydoc @hidden
+#end
 Struct Mat4<T>
 Struct Mat4<T>
 
 
 	Field i:Vec4<T>
 	Field i:Vec4<T>

+ 111 - 15
modules/std/geom/rect.monkey2

@@ -1,14 +1,29 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc Convenience type alias for Rect\<Int\>.
+#end
 Alias Recti:Rect<Int>
 Alias Recti:Rect<Int>
+
+#rem monkeydoc Convenience type alias for Rect\<Int\>.
+#end
 Alias Rectf:Rect<Float>
 Alias Rectf:Rect<Float>
 
 
+#rem monkeydoc The Rect class provides support for manipulating rectangular regions.
+
+#end
 Struct Rect<T>
 Struct Rect<T>
 
 
+	#rem monkeydoc Minimum rect coordinates.
+	#end
 	Field min:Vec2<T>
 	Field min:Vec2<T>
+	
+	#rem monkeydoc Maximum rect coordinates.
+	#end
 	Field max:Vec2<T>
 	Field max:Vec2<T>
 	
 	
+	#rem monkeydoic Creates a new Rect.
+	#end
 	Method New()
 	Method New()
 	End
 	End
 	
 	
@@ -32,76 +47,109 @@ Struct Rect<T>
 		Self.max=New Vec2<T>( x1,y1 )
 		Self.max=New Vec2<T>( x1,y1 )
 	End
 	End
 	
 	
+	#rem monkeydoc The minimum X coordinate.
+	#end
 	Property X:T()
 	Property X:T()
 		Return min.x
 		Return min.x
 	Setter( x:T )
 	Setter( x:T )
 		min.x=x
 		min.x=x
 	End
 	End
 	
 	
+	#rem monkeydoc The minimum Y coordinate.
+	#end
 	Property Y:T()
 	Property Y:T()
 		Return min.y
 		Return min.y
 	Setter( y:T )
 	Setter( y:T )
 		min.y=y
 		min.y=y
 	End
 	End
 	
 	
+	#rem monkeydoc The width of the rect.
+
+'	Writing to this property modifies the maximum Y coordinate only.
+	
+	#end
 	Property Width:T()
 	Property Width:T()
 		Return max.x-min.x
 		Return max.x-min.x
-	Setter( width:T )
-		max.x=min.x+width
+'	Setter( width:T )
+'		max.x=min.x+width
 	End
 	End
 	
 	
+	#rem monkeydoc The height of the rect.
+
+'	Writing to this property modifies the maximum Y coordinate only.
+	
+	#end
 	Property Height:T()
 	Property Height:T()
 		Return max.y-min.y
 		Return max.y-min.y
-	Setter( height:T )
-		max.y=min.y+height
+'	Setter( height:T )
+'		max.y=min.y+height
 	End
 	End
 	
 	
+	#rem monkeydoc The minimum X coordinate.
+	#end
 	Property Left:T()
 	Property Left:T()
 		Return min.x
 		Return min.x
 	Setter( left:T )
 	Setter( left:T )
 		min.x=left
 		min.x=left
 	End
 	End
 	
 	
+	#rem monkeydoc The minimum Y coordinate.
+	#end
 	Property Top:T()
 	Property Top:T()
 		Return min.y
 		Return min.y
 	Setter( top:T )
 	Setter( top:T )
 		min.y=top
 		min.y=top
 	End
 	End
 	
 	
+	#rem monkeydoc The maximum X coordinate.
+	#end
 	Property Right:T()
 	Property Right:T()
 		Return max.x
 		Return max.x
 	Setter( right:T )
 	Setter( right:T )
 		max.x=right
 		max.x=right
 	End
 	End
 	
 	
+	#rem monkeydoc The maximum X coordinate.
+	#end
 	Property Bottom:T()
 	Property Bottom:T()
 		Return max.y
 		Return max.y
 	Setter( bottom:T )
 	Setter( bottom:T )
 		max.y=bottom
 		max.y=bottom
 	End
 	End
 	
 	
+	#rem monkeydoc The top-left of the rect.
+	#end
 	Property Origin:Vec2<T>()
 	Property Origin:Vec2<T>()
 		Return min
 		Return min
 	Setter( origin:Vec2<T> )
 	Setter( origin:Vec2<T> )
 		min=origin
 		min=origin
 	End
 	End
 	
 	
+	#rem monkeydoc The width and height of the rect.
+	#end
 	Property Size:Vec2<T>()
 	Property Size:Vec2<T>()
 		Return max-min
 		Return max-min
 	Setter( size:Vec2<T> )
 	Setter( size:Vec2<T> )
 		max=min+size
 		max=min+size
 	End
 	End
-	
+
+	#rem monkeydoc The center of the rect.
+	#end	
 	Property Center:Vec2<T>()
 	Property Center:Vec2<T>()
 		Return (min+max)/2
 		Return (min+max)/2
+'	Setter( center:Vec2<T> )
 	End
 	End
 	
 	
+	#rem monkeydoc The top-left of the rect.
+	#end
 	Property TopLeft:Vec2<T>()
 	Property TopLeft:Vec2<T>()
 		Return min
 		Return min
 	Setter( v:Vec2<T> )
 	Setter( v:Vec2<T> )
 		min=v
 		min=v
 	End
 	End
 	
 	
+	#rem monkeydoc The top-right of the rect.
+	#end
 	Property TopRight:Vec2<T>()
 	Property TopRight:Vec2<T>()
 		Return New Vec2<T>( max.x,min.y )
 		Return New Vec2<T>( max.x,min.y )
 	Setter( v:Vec2<T> )
 	Setter( v:Vec2<T> )
@@ -109,12 +157,16 @@ Struct Rect<T>
 		min.y=v.y
 		min.y=v.y
 	End
 	End
 	
 	
+	#rem monkeydoc The bottom-right of the rect.
+	#end
 	Property BottomRight:Vec2<T>()
 	Property BottomRight:Vec2<T>()
 		Return max
 		Return max
 	Setter( v:Vec2<T> )
 	Setter( v:Vec2<T> )
 		max=v
 		max=v
 	End
 	End
 	
 	
+	#rem monkeydoc The bottom-left of the rect.
+	#end
 	Property BottomLeft:Vec2<T>()
 	Property BottomLeft:Vec2<T>()
 		Return New Vec2<T>( min.x,max.y )
 		Return New Vec2<T>( min.x,max.y )
 	Setter( v:Vec2<T> )
 	Setter( v:Vec2<T> )
@@ -122,64 +174,92 @@ Struct Rect<T>
 		max.y=v.y
 		max.y=v.y
 	End
 	End
 	
 	
+	#rem monkeydoc True if Right\<=Left or Bottom\<=Top.
+	#end
 	Property Empty:Bool()
 	Property Empty:Bool()
 		Return max.x<=min.x Or max.y<=min.y
 		Return max.x<=min.x Or max.y<=min.y
 	End
 	End
 
 
+	#rem monkeydoc Adds another rect to the rect and returns the result.
+	#end
 	Operator+:Rect( r:Rect )
 	Operator+:Rect( r:Rect )
 		Return New Rect( min+r.min,max+r.max )
 		Return New Rect( min+r.min,max+r.max )
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts another rect from the rect and returns the result.
+	#end
 	Operator-:Rect( r:Rect )
 	Operator-:Rect( r:Rect )
 		Return New Rect( min-r.min,max-r.max )
 		Return New Rect( min-r.min,max-r.max )
 	End
 	End
 	
 	
+	#rem monkeydoc Multiples the rect by a vector and returns the result.
+	#end
 	Operator*:Rect( v:Vec2<T> )
 	Operator*:Rect( v:Vec2<T> )
 		Return New Rect( min.x*v.x,min.y*v.y,max.x*v.x,max.y*v.y )
 		Return New Rect( min.x*v.x,min.y*v.y,max.x*v.x,max.y*v.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Divides the rect by a vector and returns the result.
+	#end
 	Operator/:Rect( v:Vec2<T> )
 	Operator/:Rect( v:Vec2<T> )
 		Return New Rect( min.x/v.x,min.y/v.y,max.x/v.x,max.y/v.y )
 		Return New Rect( min.x/v.x,min.y/v.y,max.x/v.x,max.y/v.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Adds a vector to the rect and returns the result.
+	#end
 	Operator+:Rect( v:Vec2<T> )
 	Operator+:Rect( v:Vec2<T> )
 		Return New Rect( min+v,max+v )
 		Return New Rect( min+v,max+v )
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts a vector from the rect and returns the result.
+	#end
 	Operator-:Rect( v:Vec2<T> )
 	Operator-:Rect( v:Vec2<T> )
 		Return New Rect( min-v,max-v )
 		Return New Rect( min-v,max-v )
 	End
 	End
 	
 	
+	#rem monkeydoc Adds another rect to the rect.
+	#end
 	Operator+=( r:Rect )
 	Operator+=( r:Rect )
 		min+=r.min
 		min+=r.min
 		max+=r.max
 		max+=r.max
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts another rect from the rect.
+	#end
 	Operator-=( r:Rect )
 	Operator-=( r:Rect )
 		min-=r.min
 		min-=r.min
 		max-=r.max
 		max-=r.max
 	End
 	End
 
 
+	#rem monkeydoc Multiples the rect by a vector.
+	#end
 	Operator*=( v:Vec2<T> )
 	Operator*=( v:Vec2<T> )
 		min*=v
 		min*=v
 		max*=v
 		max*=v
 	End
 	End
 	
 	
+	#rem monkeydoc Divides the rect by a vector.
+	#end
 	Operator/=( v:Vec2<T> )
 	Operator/=( v:Vec2<T> )
 		min/=v
 		min/=v
 		max/=v
 		max/=v
 	End
 	End
 	
 	
+	#rem monkeydoc Adds a vector to the rect.
+	#end
 	Operator+=( v:Vec2<T> )
 	Operator+=( v:Vec2<T> )
 		min+=v
 		min+=v
 		max+=v
 		max+=v
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts a vector from the rect.
+	#end
 	Operator-=( v:Vec2<T> )
 	Operator-=( v:Vec2<T> )
 		min-=v
 		min-=v
 		max-=v
 		max-=v
 	End
 	End
 	
 	
+	#rem monkeydoc Computes the intersection of the rect with another rect and returns the result.
+	#end
 	Operator&:Rect( r:Rect )
 	Operator&:Rect( r:Rect )
 		Local x0:=Max( min.x,r.min.x )
 		Local x0:=Max( min.x,r.min.x )
 		Local y0:=Max( min.y,r.min.y )
 		Local y0:=Max( min.y,r.min.y )
@@ -187,14 +267,9 @@ Struct Rect<T>
 		Local y1:=Min( max.y,r.max.y )
 		Local y1:=Min( max.y,r.max.y )
 		Return New Rect( x0,y0,x1,y1 )
 		Return New Rect( x0,y0,x1,y1 )
 	End
 	End
-	
-	Operator&=( r:Rect )
-		min.x=Max( min.x,r.min.x )
-		min.y=Max( min.y,r.min.y )
-		max.x=Min( max.x,r.max.x )
-		max.y=Min( max.y,r.max.y )
-	End
-	
+
+	#rem monkeydoc Computes the union of the rest with another rect and returns the result.
+	#end	
 	Operator|:Rect( r:Rect )
 	Operator|:Rect( r:Rect )
 		Local x0:=Min( min.x,r.min.x )
 		Local x0:=Min( min.x,r.min.x )
 		Local y0:=Min( min.y,r.min.y )
 		Local y0:=Min( min.y,r.min.y )
@@ -203,6 +278,17 @@ Struct Rect<T>
 		Return New Rect( x0,y0,x1,y1 )
 		Return New Rect( x0,y0,x1,y1 )
 	End
 	End
 	
 	
+	#rem monkeydoc Intersects the rect with another rect.
+	#end
+	Operator&=( r:Rect )
+		min.x=Max( min.x,r.min.x )
+		min.y=Max( min.y,r.min.y )
+		max.x=Min( max.x,r.max.x )
+		max.y=Min( max.y,r.max.y )
+	End
+	
+	#rem monkeydoc Unions the rect with another rect.
+	#end
 	Operator|=( r:Rect )
 	Operator|=( r:Rect )
 		min.x=Min( min.x,r.min.x )
 		min.x=Min( min.x,r.min.x )
 		min.y=Min( min.y,r.min.y )
 		min.y=Min( min.y,r.min.y )
@@ -210,12 +296,16 @@ Struct Rect<T>
 		max.y=Max( max.y,r.max.y )
 		max.y=Max( max.y,r.max.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Gets the rect centered within another rect.
+	#end 
 	Method Centered:Rect( r:Rect )
 	Method Centered:Rect( r:Rect )
 		Local x:=(r.Width-Width)/2+min.x
 		Local x:=(r.Width-Width)/2+min.x
 		Local y:=(r.Height-Height)/2+min.y
 		Local y:=(r.Height-Height)/2+min.y
 		Return New Rect( x,y,x+Width,y+Height )
 		Return New Rect( x,y,x+Width,y+Height )
 	End
 	End
 	
 	
+	#rem monkeydoc Checks if the rect contains a vector or another rect.
+	#end
 	Method Contains:Bool( v:Vec2<T> )
 	Method Contains:Bool( v:Vec2<T> )
 		Return v.x>=min.x And v.x<max.x And v.y>=min.y And v.y<max.y
 		Return v.x>=min.x And v.x<max.x And v.y>=min.y And v.y<max.y
 	End
 	End
@@ -224,20 +314,26 @@ Struct Rect<T>
 		Return min.x<=r.min.x And max.x>=r.max.x And min.y<=r.min.y And max.y>=r.max.y
 		Return min.x<=r.min.x And max.x>=r.max.x And min.y<=r.min.y And max.y>=r.max.y
 	End
 	End
 	
 	
+	#rem monkeydoc Checks if the rect intersects another rect.
+	#end
 	Method Intersects:Bool( r:Rect )
 	Method Intersects:Bool( r:Rect )
 		Return r.max.x>min.x And r.min.x<max.x And r.max.y>min.y And r.min.y<max.y
 		Return r.max.x>min.x And r.min.x<max.x And r.max.y>min.y And r.min.y<max.y
 	End
 	End
 	
 	
+	#rem monkeydoc Gets a string describing the rect.
+	#end
 	Method ToString:String()
 	Method ToString:String()
 		Return "Rect("+min.ToString()+","+max.ToString()+")"
 		Return "Rect("+min.ToString()+","+max.ToString()+")"
 	End
 	End
 	
 	
 End
 End
 
 
+#rem monkeydoc Transforms a Rect\<Int\> by an AffineMat3.
+#end
 Function TransformRecti<T>:Recti( rect:Recti,matrix:AffineMat3<T> )
 Function TransformRecti<T>:Recti( rect:Recti,matrix:AffineMat3<T> )
 	
 	
-	Local min:=matrix * New Vec2f( rect.min.x,rect.min.y )
-	Local max:=matrix * New Vec2f( rect.max.x,rect.max.y )
+	Local min:=matrix * New Vec2<T>( rect.min.x,rect.min.y )
+	Local max:=matrix * New Vec2<T>( rect.max.x,rect.max.y )
 		
 		
 	Return New Recti( Round( min.x ),Round( min.y ),Round( max.x ),Round( max.y ) )
 	Return New Recti( Round( min.x ),Round( min.y ),Round( max.x ),Round( max.y ) )
 End
 End

+ 58 - 2
modules/std/geom/vec2.monkey2

@@ -1,14 +1,28 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc Convenience type alias for Vec2\<Int\>.
+#end
 Alias Vec2i:Vec2<Int>
 Alias Vec2i:Vec2<Int>
+
+#rem monkeydoc Convenience type alias for Vec2\<Float\>.
+#end
 Alias Vec2f:Vec2<Float>
 Alias Vec2f:Vec2<Float>
 
 
+#rem monkeydoc The Vec2 type provides support for 2 component vectors.
+#end
 Struct Vec2<T>
 Struct Vec2<T>
 
 
+	#rem monkeydoc Vector x coordinate.
+	#end
 	Field x:T
 	Field x:T
+	
+	#rem monkeydoc Vector y coodinate.
+	#end
 	Field y:T
 	Field y:T
 	
 	
+	#rem monkeydoc Creates a new vector.
+	#end
 	Method New()
 	Method New()
 	End
 	End
 	
 	
@@ -21,72 +35,114 @@ Struct Vec2<T>
 		Self.y=y
 		Self.y=y
 	End
 	End
 	
 	
+	#rem monkeydoc The X coordinate of the vector.
+	#end
 	Property X:T()
 	Property X:T()
 		Return x
 		Return x
 	Setter( x:T )
 	Setter( x:T )
 		Self.x=x
 		Self.x=x
 	End
 	End
 	
 	
+	#rem monkeydoc The Y coordinate of the vector.
+	#end
 	Property Y:T()
 	Property Y:T()
 		Return y
 		Return y
 	Setter( y:T )
 	Setter( y:T )
 		Self.y=y
 		Self.y=y
 	End
 	End
 	
 	
+	#rem monkeydoc Negates the vector components and returns the result.
+	#end
 	Operator-:Vec2()
 	Operator-:Vec2()
 		Return New Vec2( -x,-y )
 		Return New Vec2( -x,-y )
 	End
 	End
 	
 	
+	#rem monkeydoc Multiplies the vector by another vector and returns the result.
+	#end
 	Operator*:Vec2( v:Vec2 )
 	Operator*:Vec2( v:Vec2 )
 		Return New Vec2( x*v.x,y*v.y )
 		Return New Vec2( x*v.x,y*v.y )
 	End
 	End
-	
+
+	#rem monkeydoc Divides the vector by another vector and returns the result.
+	#end	
 	Operator/:Vec2( v:Vec2 )
 	Operator/:Vec2( v:Vec2 )
 		Return New Vec2( x/v.x,y/v.y )
 		Return New Vec2( x/v.x,y/v.y )
 	End
 	End
-	
+
+	#rem monkeydoc Adds another vector to the vector and returns the result.
+	#end	
 	Operator+:Vec2( v:Vec2 )
 	Operator+:Vec2( v:Vec2 )
 		Return New Vec2( x+v.x,y+v.y )
 		Return New Vec2( x+v.x,y+v.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts another vector from the vector and returns the result.
+	#end
 	Operator-:Vec2( v:Vec2 )
 	Operator-:Vec2( v:Vec2 )
 		Return New Vec2( x-v.x,y-v.y )
 		Return New Vec2( x-v.x,y-v.y )
 	End
 	End
 	
 	
+	#rem monkeydoc Scales the vector by a value and returns the result.
+	#end
 	Operator*:Vec2( s:Double )
 	Operator*:Vec2( s:Double )
 		Return New Vec2( x*s,y*s )
 		Return New Vec2( x*s,y*s )
 	End
 	End
 	
 	
+	#rem monkeydoc Inverse scales the vector by a value and returns the result.
+	#end
 	Operator/:Vec2( s:Double )
 	Operator/:Vec2( s:Double )
 		Return New Vec2( x/s,y/s )
 		Return New Vec2( x/s,y/s )
 	End
 	End
 	
 	
+	#rem monkeydoc Adds a value to the vector components and returns the result.
+	#end
 	Operator+:Vec2( s:T )
 	Operator+:Vec2( s:T )
 		Return New Vec2( x+s,y+s )
 		Return New Vec2( x+s,y+s )
 	End
 	End
 	
 	
+	#rem monkeydoc Subtracts a value from the vector components and returns the result.
+	#end
 	Operator-:Vec2( s:T )
 	Operator-:Vec2( s:T )
 		Return New Vec2( x-s,y-s )
 		Return New Vec2( x-s,y-s )
 	End
 	End
 
 
+	#rem monkeydoc The length of the vector.
+	#end
 	Property Length:Double()
 	Property Length:Double()
 		Return Sqrt( x*x+y*y )
 		Return Sqrt( x*x+y*y )
 	End
 	End
 	
 	
+	#rem monkeydoc Computes the dot product of the vector with another vector.
+	#end
 	Method Dot:Double( v:Vec2 )
 	Method Dot:Double( v:Vec2 )
 		Return x*v.x+y*v.y
 		Return x*v.x+y*v.y
 	End
 	End
 	
 	
+	#rem monkeydoc Normalizes the vector and returns the result.
+	#end
 	Method Normalize:Vec2()
 	Method Normalize:Vec2()
 		Return Self/Length
 		Return Self/Length
 	End
 	End
 	
 	
+	#rem monkeydoc Blends the vector with another vector and returns the result.
+	#end
 	Method Blend:Vec2( v:Vec2,alpha:Double )
 	Method Blend:Vec2( v:Vec2,alpha:Double )
 		Return New Vec2( (v.x-x)*alpha+x,(v.y-y)*alpha+y )
 		Return New Vec2( (v.x-x)*alpha+x,(v.y-y)*alpha+y )
 	End
 	End
 	
 	
+	#rem monkeydoc Gets a string representation for the vector.
+	#end
 	Method ToString:String()
 	Method ToString:String()
 		Return "Vec2("+x+","+y+")"
 		Return "Vec2("+x+","+y+")"
 	End
 	End
 
 
 End
 End
+
+#rem monkeydoc Transforms a Vec2\<Int\> by an AffineMat3.
+#end
+Function TransformVec2i<T>:Vec2i( vec:Vec2i,matrix:AffineMat3<T> )
+	
+	Local tmp:=matrix * New Vec2<T>( rect.min.x,rect.min.y )
+	
+	Return New Vec2i( Round( tmp.x ),Round( tmp.y ) )
+End
+

+ 4 - 0
modules/std/geom/vec3.monkey2

@@ -1,8 +1,12 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc @hidden
+#end
 Alias Vec3f:Vec3<Float>
 Alias Vec3f:Vec3<Float>
 
 
+#rem monkeydoc @hidden
+#end
 Struct Vec3<T>
 Struct Vec3<T>
 
 
 	Field x:T
 	Field x:T

+ 4 - 0
modules/std/geom/vec4.monkey2

@@ -1,8 +1,12 @@
 
 
 Namespace std.geom
 Namespace std.geom
 
 
+#rem monkeydoc @hidden
+#end
 Alias Vec4f:Vec4<Float>
 Alias Vec4f:Vec4<Float>
 
 
+#rem monkeydoc @hidden
+#end
 Struct Vec4<T>
 Struct Vec4<T>
 
 
 	Field x:T
 	Field x:T

+ 92 - 3
modules/std/graphics/color.monkey2

@@ -1,26 +1,75 @@
 
 
 Namespace std.graphics
 Namespace std.graphics
 
 
+#rem monkeydoc The Color type provides support for manipulating red, green blue, alpha colors.
+#end
 Struct Color
 Struct Color
 	
 	
+	#rem monkeydoc Transparent black.
+	#end
 	Const None:=New Color( 0,0,0,0 )
 	Const None:=New Color( 0,0,0,0 )
+	
+	#rem monkeydoc Red.
+	#end
 	Const Red:=New Color( 1,0,0 )
 	Const Red:=New Color( 1,0,0 )
+	
+	#rem monkeydoc Green.
+	#end
 	Const Green:=New Color( 0,1,0 )
 	Const Green:=New Color( 0,1,0 )
+	
+	#rem monkeydoc Blue.
+	#end
 	Const Blue:=New Color( 0,0,1 )
 	Const Blue:=New Color( 0,0,1 )
+	
+	#rem monkeydoc Yellow.
+	#end
 	Const Yellow:=New Color( 1,1,0 )
 	Const Yellow:=New Color( 1,1,0 )
+	
+	#rem monkeydoc Magenta.
+	#end
 	Const Magenta:=New Color( 1,0,1 )
 	Const Magenta:=New Color( 1,0,1 )
+	
+	#rem monkeydoc Cyan.
+	#end
 	Const Cyan:=New Color( 0,1,1 )
 	Const Cyan:=New Color( 0,1,1 )
+
+	#rem monkeydoc Black.
+	#end
 	Const Black:=New Color( 0,0,0 )
 	Const Black:=New Color( 0,0,0 )
+
+	#rem monkeydoc White.
+	#end
 	Const White:=New Color( 1,1,1 )
 	Const White:=New Color( 1,1,1 )
+
+	#rem monkeydoc Grey.
+	#end
 	Const Grey:=New Color( .5,.5,.5 )
 	Const Grey:=New Color( .5,.5,.5 )
+
+	#rem monkeydoc Light Grey.
+	#end
 	Const LightGrey:=New Color( .75,.75,.75 )
 	Const LightGrey:=New Color( .75,.75,.75 )
+
+	#rem monkeydoc Dark Grey.
+	#end
 	Const DarkGrey:=New Color( .25,.25,.25 )
 	Const DarkGrey:=New Color( .25,.25,.25 )
 	
 	
+	#rem monkeydoc Red component of color.
+	#end
 	Field r:Float
 	Field r:Float
+
+	#rem monkeydoc Green component of color.
+	#end
 	Field g:Float
 	Field g:Float
+	#rem monkeydoc Blue component of color.
+	#end
 	Field b:Float
 	Field b:Float
+	
+	#rem monkeydoc Alpha component of color.
+	#end
 	Field a:Float
 	Field a:Float
 	
 	
+	#rem monkeydoc Creates a new color.
+	#end
 	Method New( a:Float=1 )
 	Method New( a:Float=1 )
 		Self.a=a
 		Self.a=a
 	End
 	End
@@ -39,55 +88,93 @@ Struct Color
 		Self.a=a
 		Self.a=a
 	End
 	End
 	
 	
+	#rem monkeydoc The Red color component.
+	#end
 	Property R:Float()
 	Property R:Float()
 		Return r
 		Return r
 	Setter( r:Float )
 	Setter( r:Float )
 		Self.r=r
 		Self.r=r
 	End
 	End
 	
 	
+	#rem monkeydoc The green color component.
+	#end
 	Property G:Float()
 	Property G:Float()
 		Return g
 		Return g
 	Setter( g:Float )
 	Setter( g:Float )
 		Self.g=g
 		Self.g=g
 	End
 	End
 	
 	
+	#rem monkeydoc The blue color component.
+	#end
 	Property B:Float()
 	Property B:Float()
 		Return b
 		Return b
 	Setter( b:Float )
 	Setter( b:Float )
 		Self.b=b
 		Self.b=b
 	End
 	End
 	
 	
+	#rem monkeydoc The alpha color component.
+	#end
 	Property A:Float()
 	Property A:Float()
 		Return a
 		Return a
 	Setter( a:Float )
 	Setter( a:Float )
 		Self.a=a
 		Self.a=a
 	End
 	End
 	
 	
+	#rem monkeydoc Multiplies the color by another color or value and returns the result.
+	#end
 	Operator*:Color( color:Color )
 	Operator*:Color( color:Color )
 		Return New Color( r*color.r,g*color.g,b*color.b,a*color.a )
 		Return New Color( r*color.r,g*color.g,b*color.b,a*color.a )
 	End
 	End
+
+	Operator*:Color( scale:Float )
+		Return New Color( r*scale,g*scale,b*scale,a*scale )
+	End
 	
 	
+	#rem monkeydoc Divides the color by another color or value and returns the result.
+	#end
 	Operator/:Color( color:Color )
 	Operator/:Color( color:Color )
 		Return New Color( r/color.r,g/color.g,b/color.b,a/color.a )
 		Return New Color( r/color.r,g/color.g,b/color.b,a/color.a )
 	End
 	End
-	
+
+	Operator/:Color( scale:Float )
+		Return New Color( r/scale,g/scale,b/scale,a/scale )
+	End
+
+	#rem monkeydoc Adds another color or value to the color and returns the result.
+	#end
 	Operator+:Color( color:Color )
 	Operator+:Color( color:Color )
 		Return New Color( r+color.r,g+color.g,b+color.b,a+color.a )
 		Return New Color( r+color.r,g+color.g,b+color.b,a+color.a )
 	End
 	End
 
 
+	Operator+:Color( offset:Float )
+		Return New Color( r+offset,g+offset,b+offset,a+offset )
+	End
+
+	#rem monkeydoc Subtracts another color or value from the color and returns the result.
+	#end
 	Operator-:Color( color:Color )
 	Operator-:Color( color:Color )
 		Return New Color( r-color.r,g-color.g,b-color.b,a-color.a )
 		Return New Color( r-color.r,g-color.g,b-color.b,a-color.a )
 	End
 	End
-	
+
+	Operator-:Color( offset:Float )
+		Return New Color( r-offset,g-offset,b-offset,a-offset )
+	End
+
+	#rem monkeydoc Blends the color with another color and returns the result.
+	#end	
 	Method Blend:Color( color:Color,delta:Float )
 	Method Blend:Color( color:Color,delta:Float )
 		Local idelta:=1-delta
 		Local idelta:=1-delta
 		Return New Color( r*idelta+color.r*delta,g*idelta+color.g*delta,b*idelta+color.b*delta,a*idelta+color.a*delta )
 		Return New Color( r*idelta+color.r*delta,g*idelta+color.g*delta,b*idelta+color.b*delta,a*idelta+color.a*delta )
 	End
 	End
-	
+
+	#rem monkeydoc Converts the color to 32 bit ARGB format.
+	#end	
 	Method ToARGB:UInt()
 	Method ToARGB:UInt()
 		Return UInt(a*255) Shl 24 | UInt(r*255) Shl 16 | UInt(g*255) Shl 8 | UInt(b*255)
 		Return UInt(a*255) Shl 24 | UInt(r*255) Shl 16 | UInt(g*255) Shl 8 | UInt(b*255)
 	End
 	End
 	
 	
+	#rem monkeydoc Creates a color from hue, saturation and value.
+	#end
 	Function FromHSV:Color( h:Float,s:Float,v:Float,a:Float=1 )
 	Function FromHSV:Color( h:Float,s:Float,v:Float,a:Float=1 )
 
 
 		h*=6
 		h*=6
@@ -112,6 +199,8 @@ Struct Color
 		Return New Color( r,g,b,a )
 		Return New Color( r,g,b,a )
 	End
 	End
 	
 	
+	#rem monkeydoc Creates a color from a 32 bit ARGB color.
+	#end
 	Function FromARGB:Color( argb:UInt )
 	Function FromARGB:Color( argb:UInt )
 		Local a:=(argb Shr 24 & $ff)/255.0
 		Local a:=(argb Shr 24 & $ff)/255.0
 		Local r:=(argb Shr 16 & $ff)/255.0
 		Local r:=(argb Shr 16 & $ff)/255.0

+ 3 - 3
modules/std/graphics/pixelformat.monkey2

@@ -1,7 +1,7 @@
 
 
 Namespace std.graphics
 Namespace std.graphics
 
 
-#rem monkeydoc PixelFormat enumeration.
+#rem monkeydoc Pixel formats supported by pixmaps.
 
 
 | PixelFormat	| Description
 | PixelFormat	| Description
 |:--------------|:-----------
 |:--------------|:-----------
@@ -19,6 +19,8 @@ Enum PixelFormat
 
 
 End
 End
 
 
+#rem monkeydoc Gets the number of bytes per pixel for a particular pixel format.
+#end
 Function PixelFormatDepth:Int( format:PixelFormat )
 Function PixelFormatDepth:Int( format:PixelFormat )
 
 
 	Select format
 	Select format
@@ -27,9 +29,7 @@ Function PixelFormatDepth:Int( format:PixelFormat )
 	Case PixelFormat.IA16 Return 2
 	Case PixelFormat.IA16 Return 2
 	Case PixelFormat.RGB24 Return 3
 	Case PixelFormat.RGB24 Return 3
 	Case PixelFormat.RGBA32 Return 4
 	Case PixelFormat.RGBA32 Return 4
-	Default Assert( False )
 	End
 	End
 	
 	
 	Return 0
 	Return 0
-	
 End
 End

+ 1 - 1
modules/std/graphics/pixmap.monkey2

@@ -1,7 +1,7 @@
 
 
 Namespace std.graphics
 Namespace std.graphics
 
 
-#rem monkeydoc Pixmap class.
+#rem monkeydoc Pixmaps allow you to store and manipulate rectangular blocks of pixel data.
 
 
 A pixmap contains a block of memory used to store a rectangular array of pixels.
 A pixmap contains a block of memory used to store a rectangular array of pixels.
 
 

+ 13 - 0
modules/std/misc/json.monkey2

@@ -1,4 +1,17 @@
 
 
+#rem monkeydoc
+
+JSON (JavaScript Object Notation) is a lightweight data-interchange format.
+
+\## Reading JSON data
+
+Use the [[JsonObject.Load]] function to load JSON data from a file, or [[JsonObject.Parse]] to parse JSON data from a string.
+
+\## Writing JSON data
+
+To save a JSON object, use the [[JsonObject.Save]] function.
+
+#end
 Namespace std.json
 Namespace std.json
 
 
 #rem monkeydoc JsonError class.
 #rem monkeydoc JsonError class.

+ 10 - 18
modules/std/misc/random.monkey2

@@ -45,35 +45,27 @@ Function RndULong:ULong()
 	Return s1+s0
 	Return s1+s0
 End
 End
 
 
-#rem monkeydoc Generates a random double value greater than or equal to 0 and less than 1.
+#rem monkeydoc Generates a random double value.
 
 
-@return A random double value in the range 0 (inclusive) to 1 (exclusive).
+When used with no parameters, returns a random double value in the range 0 (inclusive) to 1 (exclusive).
 
 
-#end
-Function Rnd:Double()
-	Return Double( RndULong() & ULong( $1fffffffffffff ) ) / Double( $20000000000000 )
-End
+When used with one parameter, returns a random double value in the range 0 (inclusive) to `max` (exclusive).
 
 
-#rem monkeydoc Generates a random double value greater than or equal to 0 and less than a given value.
+When used with two parameters, returns a random double value in the range `min` (inclusive) to `max` (exclusive).
 
 
-@param max Maximum value to return.
+@param min Minimum value to return.
 
 
-@return A random double value in the range 0 (inclusive) to `max` (exclusive).
+@param max Maximum value to return.
 
 
 #end
 #end
+Function Rnd:Double()
+	Return Double( RndULong() & ULong( $1fffffffffffff ) ) / Double( $20000000000000 )
+End
+
 Function Rnd:Double( max:Double )
 Function Rnd:Double( max:Double )
 	Return Rnd()*max
 	Return Rnd()*max
 End
 End
 
 
-#rem monkeydoc Generates a random double value within a given range.
-
-@param min Minimum value to return.
-
-@param max Maximum value to return.
-
-@return A random double value in the range `min` (inclusive) to `max` (exclusive).
-
-#end
 Function Rnd:Double( min:Double,max:Double )
 Function Rnd:Double( min:Double,max:Double )
 	Return Rnd(max-min)+min
 	Return Rnd(max-min)+min
 End
 End

+ 80 - 6
modules/std/misc/stringio.monkey2

@@ -48,12 +48,7 @@ Function SaveString:Bool( str:String,path:String )
 	Return ok
 	Return ok
 End
 End
 
 
-#rem monkeydoc Converts a ulong value to a hexadecimal string.
-
-@param value The value to convert.
-
-@return The hexadecimal representation of `value`.
-
+#rem monkeydoc @hidden Use ULongToString
 #end
 #end
 Function Hex:String( value:ULong )
 Function Hex:String( value:ULong )
 
 
@@ -68,3 +63,82 @@ Function Hex:String( value:ULong )
 	Return str ? str Else "0"
 	Return str ? str Else "0"
 End
 End
 
 
+#rem monkeydoc @hidden Use StringToULong
+#end
+Function FromHex:ULong( hex:String )
+
+	Local value:ULong
+	
+	For Local i:=0 Until hex.Length
+		Local ch:=hex[i]
+		If ch>=48 And ch<58
+			value=value Shl 4 | (ch-48)
+		Else If ch>=65 And ch<71
+			value=value Shl 4 | (ch-55)
+		Else If ch>=97 And ch<103
+			value=value Shl 4 | (ch-87)
+		Else
+			Exit
+		Endif
+	Next
+	
+	Return value
+
+End
+
+#rem monkeydoc Converts an unsigned long value to a string.
+
+@param value Value to convert.
+
+@param base Numeric base for conversion, eg: 2 for binary, 16 for hex etc.
+
+#end
+Function ULongToString:String( value:ULong,base:UInt )
+
+	Local str:=""
+	
+	While value
+		Local n:=value Mod base
+		If n<10 str=String.FromChar( n+48 )+str Else str=String.FromChar( n+55 )+str
+		value/=base
+	Wend
+	
+	Return str
+
+End
+
+#rem monkeydoc Converts a string to an unsigned long value.
+
+@param str String to convert.
+
+@param base Numeric base for conversion, eg: 2 for binary, 16 for hex etc.
+
+#end
+Function StringToULong:ULong( str:String,base:UInt )
+
+	Local value:ULong
+	
+	If base<=10
+	
+		For Local ch:=Eachin str
+			If ch>=48 And ch<48+base value=value*base+(ch-48) Else Exit
+		Next
+		
+		Return value
+	Endif
+
+	For Local ch:=Eachin str
+		
+		If ch>=48 And ch<58
+			value=value*base+(ch-48)
+		Else If ch>=65 And ch<65+(base-10)
+			value=value*base+(ch-55)
+		Else If ch>=97 And ch<07+(base-10)
+			value=value*base+(ch-87)
+		Else
+			Exit
+		Endif
+	Next
+	
+	Return value
+End