Created
September 26, 2023 18:05
-
-
Save manthanabc/ae930def2da19ae0f9187658aa93e957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
NATO (North Atlantic Treaty Organization)'s Logo using turtle | |
author: Manthan Patil, 26, september 2023 | |
*/ | |
#include "simplecpp" | |
#include <math.h> | |
void backward(int n) { | |
left(180); | |
forward(n); | |
left(180); | |
} | |
void fbpool(int n) { | |
forward(n); backward(n); | |
} | |
void draw_circle(int r) { | |
penDown(); | |
int step = 10; | |
int d = 0; | |
int f = 3; | |
for(int i=0; i<r; i++) { | |
if (i +d < f) penUp(); | |
else if(abs(i -r +d) < f) penUp(); | |
else if(abs(i - r/4 +d) < f) penUp(); | |
else if(abs(i - (r/2) +d) < f) penUp(); | |
else if(abs(i - (r/2) - (r/4) +d) < f) penUp(); | |
else penDown(); | |
backward(step); left(360/r); | |
} | |
left(step-10); | |
backward(step/4 + 1); | |
right(180); | |
penDown(); | |
} | |
int main(void){ | |
turtleSim(); | |
left(90); | |
// forward 120 | |
penUp(); | |
forward(80); | |
right(90); | |
draw_circle(60); | |
left(180+90); | |
forward(40); | |
right(165); | |
penDown(); | |
for(int i =0 ; i< 7; i++) { | |
forward(110); | |
right(60); | |
fbpool(35); | |
left(60); | |
left(60); | |
forward(110); | |
right(75); | |
right(90); | |
fbpool(135); | |
left(90); | |
right(75); | |
} | |
wait(100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment