-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCS1101S Q1.js
97 lines (80 loc) · 2.6 KB
/
CS1101S Q1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import {from_url, stack_frac, stack, beside_frac, heart, beside, quarter_turn_right,quarter_turn_left, make_cross, rcross, stackn, show} from "rune";
const paw = from_url("https://i.imgur.com/GJg95B8.png");
const x = 5;
/*
function start(rune,n)
{
return beside_frac(1 - 1/n, make_cross(rune),stackn(n-2,rune));
}
function qtr_turn_add(rune,n)
{
return beside_frac(1-1/n, quarter_turn_right(rune), stackn(n-1,paw));
}
*/
function besiden1(n,rune)
{
return quarter_turn_right(stackn(n,quarter_turn_left(rune)));
}
function besiden(n, rune) {
return n === 1
? rune
: beside_frac(1/n,rune,
besiden(n-1,rune));
}
function turn_upside_down(rune)
{
return quarter_turn_right(quarter_turn_right(rune));
}
function persian(rune,x)
{
return beside_frac(1-1/x, quarter_turn_right(
beside_frac(1-1/x, quarter_turn_right(
beside_frac(1-1/(x-1), quarter_turn_right(
beside_frac(1-1/(x-1), quarter_turn_right(
make_cross(rune))
,stackn(x-2,quarter_turn_right(rune))))
,stackn(x-1,turn_upside_down(rune))))
,stackn(x-1,quarter_turn_left(rune))))
,stackn(x,rune));
}
show(persian(paw,5));
function addleftright(center,pattern,x)
{
return beside_frac(1/(x),stackn(x-2,pattern),beside_frac(1- 1/(x-1), center,stackn(x-2,pattern)));
}
function addtopdown(center,pattern,x)
{
return stack_frac(1/(x),besiden(x-2,pattern),stack_frac(1- 1/(x-1), center,besiden(x-2,pattern)));
}
show(addleftright(addtopdown(make_cross(paw),paw,5),paw,5));
function addlrwtd(center,pattern,x)
{
return beside_frac(1/(x),stackn(x,pattern),beside_frac(1- 1/(x-1), center,stackn(x,pattern)));
}
function both(center, pattern, x)
{
return addlrwtd(addtopdown(center,pattern,x),pattern,x);
}
function refinedpersian(rune,x)
{
return both(make_cross(rune),rune,x);
}
show(refinedpersian(paw,5));
/*
function add4side(center,pattern,x)
{
return addleftright(quarter_turn_right(addleftright(quarter_turn_right(center),pattern,x)),quarter_turn_right(pattern),x+2);
}
function addtopdown1(center,pattern,x)
{
return quarter_turn_right(beside_frac(1/(x),stackn(x-2,quarter_turn_left(pattern)),beside_frac(1- 1/(x-1), center,stackn(x-2,quarter_turn_left(pattern)))));
}
function add4side1(center,pattern,x,counter)
{
return counter===1
? addleftright(center,quarter_turn_right(pattern),x)
: addleftright(quarter_turn_left(add4side1(center,quarter_turn_right(pattern),x,counter-1)),quarter_turn_right(pattern),x+2);
}
*/
//show(beside_frac(1 - 1/n, make_cross(paw),stackn(n-2,paw)));
//show(qtr_turn_add(start(paw,5),5));