-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.ts
More file actions
82 lines (64 loc) · 2.06 KB
/
common.ts
File metadata and controls
82 lines (64 loc) · 2.06 KB
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
import type {Dot} from "./models.ts";
import {createContext} from "react";
export const degtorad = Math.PI / 180;
export const outerDiameter = 900;
export const radius = outerDiameter / 2 - 5;
export const center = radius;
export const inRadius = radius - 160;
export const signElements = ["earth", "air", "water", "fire"] as const;
import confColors from "./shared/config.json";
//
// export const colors = {
// "earth": "rgb(240,167,67)",
// "fire":"rgb(231,50,36)",
// "water":"rgb(122,201,60)",
// "air": "rgb(155,155,248)",
// } as { [key in typeof signElements[number]]: string };
// export const colors = {
// "earth": "rgb(221,161,81)",
// "fire":"rgb(151,131,86)",
// "water":"rgb(136,104,49)",
// "air": "rgb(231,198,145)",
// } as { [key in typeof signElements[number]]: string };
export const colors = confColors.colors as { [key in typeof signElements[number]]: string };
export const styles = {
backgroundColor: confColors.colors.background,
foreColor: confColors.colors.foreground,
}
export const MainContext = createContext({} as NatContext);
export interface NatContext {
rotate: number;
lineAngleX: (angle: number, rad: number) => number;
lineAngelY: (angle: number, rad: number) => number;
createDot: (angle: number, rad: number) => Dot;
}
export function context({ascendant}: { ascendant: number }) : NatContext {
// export const rotate = base.ascendant;
const rotate = 180-ascendant;
function lineAngleX(angle: number, rad: number) {
return Math.cos(degtorad * angle) * rad + center;
}
function lineAngelY(angle: number, rad: number) {
return -Math.sin(degtorad * angle) * rad + center;
}
function createDot(angle: number, rad: number): Dot {
angle = rotate + angle;
return {x: lineAngleX(angle, rad), y: lineAngelY(angle, rad)};
}
return {rotate, lineAngleX, lineAngelY, createDot};
}
//
// export const signes = [
// "aries",
// "taurus",
// "gemini",
// "cancer",
// "leo",
// "virgo",
// "libra",
// "scorpio",
// "sagittarius",
// "capricorn",
// "aquarius",
// "pisces",
// ];