canvas.CopyPixmap(New Recti(0, 0, canvas.Viewport.Width, canvas.Viewport.Height))
?
example: (press F10 to save capture to your desktop)
 
 
		
		
			
			
			
			
				
					
				
					1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
				 
						[ crayon - 5cba8d804d251044408059   inline = "true"   ] 
Namespace   myapp 
 
# Import   "<std>" 
# Import   "<mojo>" 
 
Using  std . . 
Using  mojo . . 
 
Class   MyWindow  Extends   Window 
 
	 Field   _capture : Pixmap 
	 Field   _takeSnapShot : Bool   
 
	 Method  New (   title : String = "Simple mojo app" , width : Int = 640 , height : Int = 480 , flags : WindowFlags = Null   ) 
 
		 Super . New (   title , width , height , flags   ) 
		 
		 _takeSnapShot   =   False 
	 End 
 
	 Method  OnRender (   canvas : Canvas   )   Override 
	 
		 App . RequestRender ( ) 
	 
		 canvas . DrawText (   "Hello World!" , Width / 2 , Height / 2 , . 5 , . 5   ) 
	 
		 canvas . Flush ( ) 
		 
		 If   _takeSnapShot 
			 _capture   =   canvas . CopyPixmap ( New   Recti ( 0 ,   0 ,   canvas . Viewport . Width ,   canvas . Viewport . Height ) ) 
			 Local   url : String   =   DesktopDir ( )   +   "cap.png" 
			 _capture . Save ( url ) 
			 Print   "Capture saved: "   +   url 
			 _takeSnapShot   =   False 
		 Endif 
		 
	 
	 End 
	 
	 Method  OnKeyEvent ( event : KeyEvent )   Override 
		 If   event . Type   =   EventType . KeyDown 
			 If   event . Key   =   Key . F10 
				 _takeSnapShot   =   True 
			 Endif 
		 Endif 
	 End 
	 
	 
End 
 
Function   Main ( ) 
	 New   AppInstance 
	 New   MyWindow 
	 App . Run ( ) 
End 
  
 
					 
				
			 
		 
[/crayon]