tutorials:a-beginners-tutorial
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:a-beginners-tutorial [2024/12/19 11:39] – Tim | tutorials:a-beginners-tutorial [2024/12/19 13:34] (current) – barley1965 | ||
---|---|---|---|
Line 8: | Line 8: | ||
Installing the platform GroIMP on your computer is actually quite straightforward if you carefully follow the instructions below. GroIMP runs on Java, so first of all, make sure you have a recent version of Java installed. To check if you have Java installed on your machine you open the command prompt window (type cmd in the search window), then type “java -version”, | Installing the platform GroIMP on your computer is actually quite straightforward if you carefully follow the instructions below. GroIMP runs on Java, so first of all, make sure you have a recent version of Java installed. To check if you have Java installed on your machine you open the command prompt window (type cmd in the search window), then type “java -version”, | ||
- | {{: | + | {{: |
I have version 22 on my computer, which is one of the latest versions. If you don’t see this message or you know you don’t have Java, make sure to install Java version 22 before proceeding to the next step (you can find it here: https:// | I have version 22 on my computer, which is one of the latest versions. If you don’t see this message or you know you don’t have Java, make sure to install Java version 22 before proceeding to the next step (you can find it here: https:// | ||
Line 28: | Line 28: | ||
After this you click on ‘Install’ and wait for the installation to finish (this can take more than ten minutes). | After this you click on ‘Install’ and wait for the installation to finish (this can take more than ten minutes). | ||
- | After the installation, | + | After the installation, |
GroIMP will now be available either on your desktop or in the list of programmes: | GroIMP will now be available either on your desktop or in the list of programmes: | ||
Line 47: | Line 47: | ||
{{: | {{: | ||
- | Note that on your machine, the naming of the menu items might vary, due to the language settings of your Java version (I have a French Java installation, so some of the menu items will appear | + | Note that on your machine, the naming of the menu items might vary, due to the language settings of your Java version (in this tutorial, the menu items will appear in English).\\ |
GroIMP is a multi-windows platform, i.e. it consists in fact of a (large) number of windows, which can be piled upon each other (like the sheets in an Excel file), “glued” side by side, or be viewed separately (this is handy if your computer is connected to more than one computer screen). To change the size of an integrated window you can simply click and drag on one of the grey hatched lines separating two windows. To change the position of a window you can click on the tab, hold and drag the whole window to its new position. You will see on your left a window called “View”, which contains the visual output of a model (currently a blue cylinder on its side, with a label “A” below it) and on your right a window called “jEdit – Alga.rgg”, | GroIMP is a multi-windows platform, i.e. it consists in fact of a (large) number of windows, which can be piled upon each other (like the sheets in an Excel file), “glued” side by side, or be viewed separately (this is handy if your computer is connected to more than one computer screen). To change the size of an integrated window you can simply click and drag on one of the grey hatched lines separating two windows. To change the position of a window you can click on the tab, hold and drag the whole window to its new position. You will see on your left a window called “View”, which contains the visual output of a model (currently a blue cylinder on its side, with a label “A” below it) and on your right a window called “jEdit – Alga.rgg”, | ||
Line 61: | Line 61: | ||
{{: | {{: | ||
- | From the lecture, you will already know that the text in line 24 is a rule, with a left-hand-side and a right-hand-side. The keyword ‘Axiom’ refers to the start word of the L-system, and ‘==> | + | The text in line 24 is a rule, with a left-hand-side and a right-hand-side. The keyword ‘Axiom’ refers to the start word of the L-system, and ‘%%==>%%’ is an operator that essentially means “// |
{{: | {{: | ||
Line 72: | Line 72: | ||
Let’s have a closer look at the code surrounding the Axiom rule: | Let’s have a closer look at the code surrounding the Axiom rule: | ||
- | protected void init () | + | '' |
init () is what is called a method in the Java language. Whenever you see a name followed by a pair of simple brackets, (), you can be almost certain that you are dealing with a method. A method is a little //programme within the programme//, | init () is what is called a method in the Java language. Whenever you see a name followed by a pair of simple brackets, (), you can be almost certain that you are dealing with a method. A method is a little //programme within the programme//, | ||
Line 168: | Line 168: | ||
Open Ex08.gsz ([[# | Open Ex08.gsz ([[# | ||
+ | <code java> | ||
F(x/3) RU(-60) F(x/3) RU(120) F(x/3) RU(-60) F(x/3) | F(x/3) RU(-60) F(x/3) RU(120) F(x/3) RU(-60) F(x/3) | ||
+ | </ | ||
Suppose we want to change the angle of the RU rotation, from 60 and -60 to 55 and -55. We could do this manually by changing all the arguments one by one (note that we replaced 120 by 2*55=110): | Suppose we want to change the angle of the RU rotation, from 60 and -60 to 55 and -55. We could do this manually by changing all the arguments one by one (note that we replaced 120 by 2*55=110): | ||
F(x/3) RU(-55) F(x/3) RU(110) F(x/3) RU(-55) F(x/3) | F(x/3) RU(-55) F(x/3) RU(110) F(x/3) RU(-55) F(x/3) | ||
Line 187: | Line 188: | ||
Open Ex09.gsz ([[# | Open Ex09.gsz ([[# | ||
+ | <code java> | ||
module Leaf(float len, float width) extends Parallelogram(len, | module Leaf(float len, float width) extends Parallelogram(len, | ||
{{setShader(GREEN); | {{setShader(GREEN); | ||
+ | </ | ||
The leaf is defined as an extension of a Parallelogram object. You can have a look at how such an object looks like, by inserting it into the scene. For this, use the menu item “Objects” 🡪 “Primitives” 🡪 “Parallelogram”: | The leaf is defined as an extension of a Parallelogram object. You can have a look at how such an object looks like, by inserting it into the scene. For this, use the menu item “Objects” 🡪 “Primitives” 🡪 “Parallelogram”: | ||
{{: | {{: | ||
- | The Leaf module is defined with two parameters, len and width, both of type float (floating point number), which will be used to draw a parallelogram of length len and width width. Finally, the definition invokes the method setShader of Parallelogram to paint the leaves green. Note that for this you need to write {{ in the beginning, and }} at the end. | + | The Leaf module is defined with two parameters, len and width, both of type float (floating point number), which will be used to draw a parallelogram of length len and width width. Finally, the definition invokes the method setShader of Parallelogram to paint the leaves green. Note that for this you need to write '' |
The leaf petiole is defined as an extension of F: | The leaf petiole is defined as an extension of F: | ||
Line 271: | Line 273: | ||
STRENGTH_LIMIT is a constant parameter that we are going to use to define a certain lower limit of the strength variable of Bud. Have a look at the new condition in the production rule of the method grow: | STRENGTH_LIMIT is a constant parameter that we are going to use to define a certain lower limit of the strength variable of Bud. Have a look at the new condition in the production rule of the method grow: | ||
+ | <code java> | ||
(b[order] <= MAX_ORDER_ALLOWED && b[strength] > STRENGTH_LIMIT) | (b[order] <= MAX_ORDER_ALLOWED && b[strength] > STRENGTH_LIMIT) | ||
+ | </ | ||
We see a new condition, b[strength] > STRENGTH_LIMIT, | We see a new condition, b[strength] > STRENGTH_LIMIT, | ||
Line 362: | Line 364: | ||
//Write the following two rules in the editor window below the comment (“%%// | //Write the following two rules in the editor window below the comment (“%%// | ||
- | **Axiom ==> Bud** | + | **Axiom |
- | **Bud ==> Internode Node Bud** | + | **Bud %%==>%% Internode Node Bud** |
In order for this to work as a program, we have to write a bit more (by “wrapping” the rules with some method code): | In order for this to work as a program, we have to write a bit more (by “wrapping” the rules with some method code): | ||
Line 585: | Line 587: | ||
] | ] | ||
- | public void executer | + | public void run () |
[ | [ | ||
A ==> A B; | A ==> A B; |
tutorials/a-beginners-tutorial.1734604777.txt.gz · Last modified: 2024/12/19 11:39 by Tim