Reference Flag
Safety:
There are no safety concerns for this project.
Whenever we started creating the flags, at first it was very complex and confusing. But it got a lot easier when we learned to break the problems down into loops and functions. When making a flag, map out the order in which you create the colors. For example, if you want to make the Swedish flag first you should:
1. Make the blue background
2. Make the two crosses.
From this project, I gained the understanding of how to break down a large project into smaller parts to help complete it more efficiently.
This project is meant to show that Karel can create flags using the paint function but also that Karel can create and paint lots of designs depending on the programmers creativity. We hope that you can inspire yourself and create your own design or image using Karel. The positive impact of this project is that it shows that the paint command can be used for a wide variety of things like creating your own graphic designs in your place of work, or even just for person development in your home like pictures and what not. The entire point of this project was flags, but that doesn't mean the command can't be used for another function.
This project is useful because it demonstrates that Karel can do many things using the paint command. It also shows that the paint command can do a wide variety of things. We tried to show the flexibility of the command using our different colored examples, and we hope we did so.
You can do this project yourself by going to the CODEHS SANDBOX and selecting the "Create Program" option. After that, you can select a program type. Go to the Javascript column and then press the "UltraKarel" option. Once you load in to the program, it should have the commands "paint(Color.red),paint(Color.orange)" and other colors. Now find a reference or flag to recreate and begin painting.
This project benefited me a lot because I learned how to use Javascript for the first time. When I saw that Karel had an option to paint, I thought of creating flags and did it. It felt very intuitive when I was able to apply what I learned from CodeHS and eventually create something of my own.
This project could be very easy or hard depending on what flags you are doing. For example if you compare the United States flag to the Flag of France. France is a very simple 3 color flag but the United States has stripes and many stars making it much harder to create compared to France. But it also depends on the person coding. If your able to break the code into simple functions and map what you want to do, it makes the project a lot easier.
PROCEDURE
To create the flags code I had to focus on creating the all blue background first. I did this by creating a function called "paintRowBlue". This function would paint an entire street/avenue (depending on the direction of Karel) blue, which made it a lot easier to make the entire 10x10 background blue. which would go forward and paint the color blue. I repeated this until the entire background was blue. After creating the all blue background, I moved to avenue 5, street 10 and began to create a yellow line. I created a function called "paintRowYellow" which moves forward and paints the squares yellow until Karel hits a wall. This helped me easily paint the entire column and row yellow to create the yellow cross. At the end, I compiled all this code into one function "swedishFlag" which you can see is the only command in the start function. I added a showcase of Karel creating the flag and I scrolled through the code and showed all functions in the embed below. - Moses
The code can be found here:
https://pastebin.com/MAGDK0A3
Sweden is a Scandinavian country known for its rich history, picturesque landscapes, and vibrant culture. The blue color represents loyalty, truth, and justice, while the yellow color symbolizes generosity, harmony, and warmth. The Swedish flag holds deep significance for the nation and is proudly displayed during national celebrations and events. It is a symbol of unity and national pride, reflecting the values and traditions of the Swedish people.
ACTION VIDEO
I had to prioritize making the landscape completely red before I could write the code for the flag. I started by drawing a white line on Avenue 5, Street 20, after finishing the all-red background. I just used "while(frontIsClear())," which paints the tiles white and advances till Karel hits a wall if the front is clear. This made it much easier for me to paint a row and complete column white to make the white cross. Using the same technique—while(frontIsClear())—and white paint, I created another thick white surface that was four streets wide. Afterwards, I wanted to add blue lines to the white cross I had previously drawn. To do this, I started at the end of one of my white lines street 10, avenue 1, which was a cross, and I used the "while(frontIsClear())" command once more to paint the street blue. I then repeated the blue lines on the next street above it, and I brought Karl to street 20, avenue 7. The "norwayFlag" function, which you can see is the isolated command in the start function, is the result of my compilation of all this code. In the embed below, I included a presentation of Karel making the flag and I slid through the code to display every function. - Oluwaseyitan Emmanuel Adeniji
Norway's flag features a red field with a blue cross outlined in white, symbolizing its monarchy history and close ties to Scandinavia. Similar to other Nordic countries like Sweden, Denmark, Finland, and Iceland, the flag's design reflects historical and cultural ties among Scandinavian nations. The use of red and blue in the Norwegian flag is inspired by historical heraldry and traditional colors associated with the country, reflecting the country's historical and cultural ties.
Norway Flag Pastebin here:
https://pastebin.com/ZJYABUJj
Flag Creation starts at 0:51
ACTION VIDEO BELOW
The type of flag I decide to do was the Switzerland flag. One reason I chose this was not due to its simple colors but more because of the country I have always dreamt of traveling to Switzerland. So when I started to make to this flag, I thought of making the cross first but in the end, I decided to first fill in the background with red and then make then make the cross in the code I mostly used for loop code which looks like this.
for (var I = 0; I < count; I ++) {
}
I repeated the for-loop code and put it all into a function called "Switzerland".
So that is how I made the Switzerland flag using JavaScript.
ACTION VIDEO
I decided to do the flag of Guernsey. I decided to do this flag because I've never heard of this country. As I was making the flag of Guernsey, I realized that I would have to make 2 crosses of 2 different color while one was inside the other. The red cross on the Guernsey flag represents the islands constitutional relationship with the English Crown. The yellow cross represents The Duke of Normandy.
For the creation of this flag, I used CodeHs(UltraKarel) and lots of for(var i = 0; i < num; i++) loops and while(frontIsClear) loops so that I was able to get things done faster to complete the flag in time.
for ( var i = 0; i < count ; i ++){
}
and this code was the main reason I was able to complete the flag. I looped Karel going up and down which created the green part of the flag, and the white. The way I planned this flag was by first coloring one part green and then leaving the middle blank so on other side I was able to paint it green and this how I coded the flag of Nigeria.
-Omobolaji
Below is a video of Karel creating the flag.
We used HTML in CodeHS to create a website telling people about our project, and directing them to this site if they wish to learn more about our project.