You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: processingjs-gwt/src/main/java/com/github/timeu/gwtlibs/processingjsgwt/client/ProcessingInstance.java
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,71 @@
3
3
importcom.google.gwt.core.client.js.JsType;
4
4
5
5
6
+
/**
7
+
* ProcessingInstance is the base class that is used to interface with the ProcessingJS sketch.
8
+
* Every ProcessingJS sketch has some default methods (draw, setup, etc)
9
+
* Users should create their own custom interface extending ProcessingInstance and define the API methods
10
+
* similar to draw and size. The custom interface must be annotated with {@link @JsType}
11
+
*/
6
12
@JsType
7
13
publicinterfaceProcessingInstance {
8
14
15
+
/**
16
+
* Called once when the program is started. Used to define initial enviroment properties such as screen size, background color, loading images, etc. before the draw() begins executing.
17
+
* Variables declared within setup() are not accessible within other functions, includingdraw().
18
+
* There can only be one setup() function for each program and it should not be called again after it's initial execution.
19
+
*/
20
+
voidsetup();
21
+
22
+
/**
23
+
* Defines the dimension of the display window in units of pixels. The size() function must be the first line in setup().
24
+
* If size() is not called, the default size of the window is 100x100 pixels.
25
+
* The system variables width and height are set by the parameters passed to the size() function.
26
+
*
27
+
* @param width width of the sketch
28
+
* @param height height of the sketch
29
+
*/
9
30
voidsize(intwidth,intheight);
31
+
32
+
/**
33
+
* Called directly after setup() and continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called.
34
+
* The draw() function is called automatically and should never be called explicitly.
35
+
* It should always be controlled with noLoop(), redraw() and loop().
36
+
* After noLoop() stops the code in draw() from executing, redraw() causes the code inside draw() to execute once and loop() will causes the code inside draw() to execute continuously again.
37
+
* The number of times draw() executes in each second may be controlled with the delay() and frameRate() functions.
38
+
* There can only be one draw() function for each sketch and draw() must exist if you want the code to run continuously or to process events such as mousePressed().
39
+
* Sometimes, you might have an empty call to draw() in your program as shown in the above example.
40
+
*/
10
41
voiddraw();
42
+
43
+
/**
44
+
* Executes the code within draw() one time.
45
+
* This functions allows the program to update the display window only when necessary, for example when an event registered by mousePressed() or keyPressed() occurs.
46
+
*
47
+
* In structuring a program, it only makes sense to call redraw() within events such as mousePressed().
48
+
* This is because redraw() does not run draw() immediately (it only sets a flag that indicates an update is needed).
49
+
*
50
+
* Calling redraw() within draw() has no effect because draw() is continuously called anyway.
51
+
*/
52
+
voidredraw();
53
+
54
+
/**
55
+
* Stops Processing from continuously executing the code within draw().
56
+
* If loop() is called, the code in draw() begin to run continuously again.
57
+
* If using noLoop() in setup(), it should be the last line inside the block.
58
+
*
59
+
* When noLoop() is used, it's not possible to manipulate or access the screen inside event handling functions such as mousePressed() or keyPressed().
60
+
* Instead, use those functions to call redraw() or loop(), which will run draw(), which can update the screen properly.
61
+
* This means that when noLoop() has been called, no drawing can happen, and functions like saveFrame() or loadPixels() may not be used.
62
+
*
63
+
* Note that if the sketch is resized, redraw() will be called to update the sketch, even after noLoop() has been specified.
64
+
* Otherwise, the sketch would enter an odd state until loop() was called.
65
+
*/
66
+
voidnoLoop();
67
+
68
+
/**
69
+
* Causes Processing to continuously execute the code within draw().
70
+
* If noLoop() is called, the code in draw() stops executing.
0 commit comments