This commit is contained in:
DavidOnTop 2024-12-05 13:19:06 +01:00
parent 1f10c7a15f
commit dbc82afb0e
No known key found for this signature in database
GPG key ID: 5D05538A45D5149F
4 changed files with 182 additions and 1 deletions

65
src/u2.py Normal file
View file

@ -0,0 +1,65 @@
import turtle
radius = 100
t = turtle.Turtle()
t.speed(100)
t.penup()
def a():
t.setheading(180)
t.forward(radius*3)
circle2(False)
t.setheading(0)
t.penup()
t.forward(radius*2)
circle2(True)
t.setheading(0)
t.penup()
t.forward(radius*2)
circle2(False)
t.setheading(0)
t.penup()
t.forward(radius*2)
circle2(True)
def b():
circle2(False)
t.setheading(90)
t.forward(radius*2)
circle2(True)
t.setheading(180)
t.forward(radius*2)
circle2(False)
t.setheading(270)
t.forward(radius*2)
circle2(True)
def c():
circle2(False)
t.setheading(90)
t.forward(radius*2)
circle2(False)
t.setheading(180)
t.forward(radius*2)
circle2(True)
t.setheading(270)
t.forward(radius*2)
circle2(True)
def circle2(reverse):
if reverse:
t.dot(radius*2, "black")
t.dot(radius, "gray")
else:
t.dot(radius*2, "gray")
t.dot(radius, "black")
def main():
func = input("a b abo c\n")
globals().get(func)()
input()
if __name__ == "__main__":
main()

View file

@ -1 +1,13 @@
pub fn main() {}
use std::ffi::{CStr, CString};
use pyo3::ffi::c_str;
use pyo3::prelude::*;
static code: &'static str = include_str!("u2.py");
pub fn main() {
Python::with_gil(|py| {
let c = CString::new(code.as_bytes()).unwrap();
let activator = PyModule::from_code(py, c.as_c_str(), c_str!("main.py"), c_str!("main")).unwrap();
activator.call_method("main", (), None).unwrap();
})
}