Cleaned up file structure. Completed tutorial 1.5.
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*/venv/
|
||||||
|
*/.idea/
|
||||||
|
*/__pycache__/
|
||||||
@@ -1,22 +1,28 @@
|
|||||||
import turtle
|
import turtle
|
||||||
import random
|
import random
|
||||||
|
|
||||||
def first(steps):
|
def moves():
|
||||||
window = turtle.Screen()
|
while x<steps:
|
||||||
|
direc = random.randrange(5)
|
||||||
|
r = getRandom(x, direc)
|
||||||
|
if direc == 0:
|
||||||
|
asdf.forward(r)
|
||||||
|
elif direc == 1:
|
||||||
|
asdf.backward(r)
|
||||||
|
elif direc == 2:
|
||||||
|
asdf.left(r)
|
||||||
|
elif direc == 3:
|
||||||
|
asdf.right(r)
|
||||||
|
history.append([direc,r])
|
||||||
|
x=x+1
|
||||||
|
return history
|
||||||
|
|
||||||
win_height = window.window_height()
|
def first(steps, asdf):
|
||||||
win_width = window.window_width()
|
|
||||||
|
|
||||||
asdf = turtle.Turtle()
|
|
||||||
window.tracer(delay=None)
|
|
||||||
asdf.hideturtle()
|
|
||||||
y=0
|
y=0
|
||||||
x = 1
|
x = 1
|
||||||
|
|
||||||
history = []
|
history = []
|
||||||
|
|
||||||
print(win_width)
|
|
||||||
print(win_width)
|
|
||||||
def getRandom(x, direc):
|
def getRandom(x, direc):
|
||||||
|
|
||||||
r = random.randrange(x)
|
r = random.randrange(x)
|
||||||
@@ -47,18 +53,5 @@ def first(steps):
|
|||||||
# x = 0
|
# x = 0
|
||||||
# y=y+1
|
# y=y+1
|
||||||
|
|
||||||
while x<steps:
|
|
||||||
direc = random.randrange(5)
|
|
||||||
r = getRandom(x, direc)
|
|
||||||
if direc == 0:
|
|
||||||
asdf.forward(r)
|
|
||||||
elif direc == 1:
|
|
||||||
asdf.backward(r)
|
|
||||||
elif direc == 2:
|
|
||||||
asdf.left(r)
|
|
||||||
elif direc == 3:
|
|
||||||
asdf.right(r)
|
|
||||||
history.append([direc,r])
|
|
||||||
x=x+1
|
|
||||||
return history
|
|
||||||
|
|
||||||
18
Python/main.py
Normal file
18
Python/main.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import gen
|
||||||
|
import turtle
|
||||||
|
|
||||||
|
window = turtle.Screen()
|
||||||
|
|
||||||
|
win_height = window.window_height()
|
||||||
|
win_width = window.window_width()
|
||||||
|
|
||||||
|
asdf = turtle.Turtle()
|
||||||
|
window.tracer(delay=None)
|
||||||
|
asdf.hideturtle()
|
||||||
|
|
||||||
|
steps = 215
|
||||||
|
history = []
|
||||||
|
|
||||||
|
history = gen.first(steps, asdf)
|
||||||
|
|
||||||
|
print(history)
|
||||||
14
Tutorials/Code Art/1/index.html
Normal file
14
Tutorials/Code Art/1/index.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Document</title>
|
||||||
|
<link rel="stylesheet" href="style.css"
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas id="my-canvas"></canvas>
|
||||||
|
<script src="index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
23
Tutorials/Code Art/1/index.js
Normal file
23
Tutorials/Code Art/1/index.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const canvas = document.getElementById('my-canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
canvas.width = window.innerWidth;
|
||||||
|
canvas.height = window.innerHeight;
|
||||||
|
// console.log(ctx);
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
|
||||||
|
|
||||||
|
// canvas.addEventListener('mousemove', function (e){
|
||||||
|
// console.log(e.x, e.y);
|
||||||
|
// ctx.rect(e.x,e.y,10,10);
|
||||||
|
// ctx.fill( );
|
||||||
|
// // ctx.stroke();
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
const degreeToRad = (deg) =>{
|
||||||
|
return deg / 180 * Math.PI;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.arc(100, 100, 50, 0, degreeToRad(360));
|
||||||
|
ctx.stroke();
|
||||||
8
Tutorials/Code Art/1/style.css
Normal file
8
Tutorials/Code Art/1/style.css
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#my-canvas{
|
||||||
|
/* background-color: blue; */
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
BIN
Tutorials/Code Art/AllResources.zip
Normal file
BIN
Tutorials/Code Art/AllResources.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user