Skip to content

Commit

Permalink
Fixed problems with examples
Browse files Browse the repository at this point in the history
Signed-off-by: Roopesh O R <[email protected]>
  • Loading branch information
Roopesh2 committed May 4, 2024
1 parent d55c242 commit ee30aa4
Show file tree
Hide file tree
Showing 127 changed files with 8,764 additions and 4,857 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'public'
path: "public"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/dist
**/docs
**/*.min.*
1 change: 1 addition & 0 deletions Extensions/Animations/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getBezierControlPoints } from "../../src/c.js";
import { loop, noLoop } from "../../src/settings.js";
import { animateFill } from "./constructs.js";
(function () {
Expand Down
1 change: 0 additions & 1 deletion TODOs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
## TOOD:

- restructure Extensionsm, add relevent stuffs in src

57 changes: 26 additions & 31 deletions dist/c.core.gcc.js

Large diffs are not rendered by default.

1,531 changes: 840 additions & 691 deletions dist/c.core.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/c.core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/c.core.min.js.map

Large diffs are not rendered by default.

234 changes: 118 additions & 116 deletions dist/c.gcc.js

Large diffs are not rendered by default.

1,538 changes: 845 additions & 693 deletions dist/c.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/c.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/c.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/WebGL.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/WebGL_m4.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/WebGL_settings.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/WebGL_webgl.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/color_color_converters.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/color_color_reader.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/color_gradients.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/color_interpolation.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/color_random.js.html

Large diffs are not rendered by default.

79 changes: 38 additions & 41 deletions docs/constants_color_palettes.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/constants_colors.js.html

Large diffs are not rendered by default.

3,479 changes: 3,189 additions & 290 deletions docs/global.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/image_image.js.html

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions docs/image_processing.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/m4_m4.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/main.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/math_aritmetics.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/math_points.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/math_random.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/misc_point_generator.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Arithmetic-Functions.html

Large diffs are not rendered by default.

66 changes: 34 additions & 32 deletions docs/module-Arrows.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Braces.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Color-Converters.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Color-Gradient.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Color-Lerp.html

Large diffs are not rendered by default.

77 changes: 1 addition & 76 deletions docs/module-Color-Palettes.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Color-Reader.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Colors.html

Large diffs are not rendered by default.

1,872 changes: 865 additions & 1,007 deletions docs/module-Coordinate-Systems.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Extra-Shapes.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Geometric-Shapes.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/module-Image-Processing.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Image.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/module-Plottter-Functions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Point-Utils.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Random-Colors.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-Random-Functions.html

Large diffs are not rendered by default.

38 changes: 14 additions & 24 deletions docs/module-Settings.html

Large diffs are not rendered by default.

110 changes: 107 additions & 3 deletions docs/module-Tex.html

Large diffs are not rendered by default.

663 changes: 660 additions & 3 deletions docs/module-Utils.html

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions docs/module-Vector.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/module-text.html

Large diffs are not rendered by default.

136 changes: 68 additions & 68 deletions docs/objects_arrows.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/objects_braces.js.html

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions docs/objects_coordinate_systems_axes.js.html

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions docs/objects_coordinate_systems_cartesian_plotters.js.html

Large diffs are not rendered by default.

329 changes: 329 additions & 0 deletions docs/objects_coordinate_systems_number_line.js.html

Large diffs are not rendered by default.

214 changes: 214 additions & 0 deletions docs/objects_coordinate_systems_number_plane.js.html

Large diffs are not rendered by default.

502 changes: 502 additions & 0 deletions docs/objects_coordinate_systems_polar_plane.js.html

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions docs/objects_coordinate_systems_vector.js.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/objects_functions.js.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/objects_geometry.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/objects_more_shapes.js.html

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions docs/objects_tex.js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/objects_text.js.html

Large diffs are not rendered by default.

13 changes: 1 addition & 12 deletions docs/settings.js.html

Large diffs are not rendered by default.

104 changes: 81 additions & 23 deletions docs/utils.js.html

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions gruntfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ module.exports = function (grunt) {
src: "src/core.js",
dest: "dist/c.core.js",
},
custom: {
src: "examples/cutting/index.js",
dest: "examples/cutting/bundle.js",
},
},
uglify: {
options: {
Expand All @@ -43,10 +39,6 @@ module.exports = function (grunt) {
src: "dist/c.core.js",
dest: "dist/c.core.min.js",
},
custom: {
src: "examples/cutting/bundle.js",
dest: "examples/cutting/bundle.min.js",
},
},
jsdoc: {
dist: {
Expand All @@ -69,5 +61,4 @@ module.exports = function (grunt) {
]);
grunt.registerTask("docs", ["jsdoc"]);
grunt.registerTask("core", ["browserify:core", "uglify:core"]);
grunt.registerTask("custom", ["browserify:custom", "uglify:custom"]);
};
1 change: 0 additions & 1 deletion public/examples/Clollatz Conjecture/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shapes</title>
<script defer src="../../src/app.js" type="module"></script>
<script defer src="./index.js" type="module"></script>
<style>
body,
Expand Down
182 changes: 92 additions & 90 deletions public/examples/Clollatz Conjecture/index.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,104 @@
import { ColorPalettes } from "../../src/constants/color_palettes.js";
import { pixel } from "../../src/image/image.js";
import { C } from "../../src/main.js";
import { numberPlane } from "../../src/objects/coordinate_systems.js";
import { background, translate } from "../../src/settings.js";
import {
ColorPalettes,
background,
numberPlane,
pixel,
translate,
} from "../../../src/c.js";

// complex operators
/**
* multiplies two complex numbers
* @param {number[]} a first complex number
* @param {number[]} b second complex number
* @returns {number[]}
*/
const cmul = (a, b) => {
return [a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]];
};
{
/**
* multiplies two complex numbers
* @param {number[]} a first complex number
* @param {number[]} b second complex number
* @returns {number[]}
*/
const cmul = (a, b) => {
return [a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0]];
};

/**
* multiplies a real number and a complex number
*/
const rmul = (a, b) => {
return [a * b[0], a * b[1]];
};
/**
* multiplies a real number and a complex number
*/
const rmul = (a, b) => {
return [a * b[0], a * b[1]];
};

/**
* adds two complex numbers
*/
const cadd = (a, b) => {
return [a[0] + b[0], a[1] + b[1]];
};
/**
* adds two complex numbers
*/
const cadd = (a, b) => {
return [a[0] + b[0], a[1] + b[1]];
};

/**
* divides two complex numbers
*/
const cdiv = (a, b) => {
const d = b[0] * b[0] + b[1] * b[1];
return [(a[0] * b[0] + a[1] * b[1]) / d, (a[1] * b[0] - a[0] * b[1]) / d];
};
/**
* divides two complex numbers
*/
const cdiv = (a, b) => {
const d = b[0] * b[0] + b[1] * b[1];
return [(a[0] * b[0] + a[1] * b[1]) / d, (a[1] * b[0] - a[0] * b[1]) / d];
};

/**
* divides a complex number by a real number
*/
const cdivr = (a, b) => {
return [a[0] / b, a[1] / b];
};
/**
* divides a complex number by a real number
*/
const cdivr = (a, b) => {
return [a[0] / b, a[1] / b];
};

/**
* returns the sin of a complex number
*/
const csin = (a) => {
return [Math.sin(a[0]) * Math.cosh(a[1]), Math.cos(a[0]) * Math.sinh(a[1])];
};
/**
* returns the cos of a complex number
*/
const ccos = (a) => {
return [Math.cos(a[0]) * Math.cosh(a[1]), -Math.sin(a[0]) * Math.sinh(a[1])];
};
/**
* returns the sin of a complex number
*/
const csin = (a) => {
return [Math.sin(a[0]) * Math.cosh(a[1]), Math.cos(a[0]) * Math.sinh(a[1])];
};
/**
* returns the cos of a complex number
*/
const ccos = (a) => {
return [Math.cos(a[0]) * Math.cosh(a[1]), -Math.sin(a[0]) * Math.sinh(a[1])];
};

/**
* returns the square of a complex number
*/
const csqr = (a) => {
return [a[0] * a[0] - a[1] * a[1], 2 * a[0] * a[1]];
};
/**
* returns the square of a complex number
*/
const csqr = (a) => {
return [a[0] * a[0] - a[1] * a[1], 2 * a[0] * a[1]];
};

/**
* returns the square of cos of a complex number
*/
const ccos2 = (a) => {
let cr = Math.cos(a[0]) * Math.cosh(a[1]),
ci = -Math.sin(a[0]) * Math.sinh(a[1]);
return [cr * cr - ci * ci, 2 * cr * ci];
};
/**
* returns the square of cos of a complex number
*/
const ccos2 = (a) => {
let cr = Math.cos(a[0]) * Math.cosh(a[1]),
ci = -Math.sin(a[0]) * Math.sinh(a[1]);
return [cr * cr - ci * ci, 2 * cr * ci];
};

/**
* returns the square of sin of a complex number
*/
const csin2 = (a) => {
let cr = Math.sin(a[0]) * Math.cosh(a[1]),
ci = Math.cos(a[0]) * Math.sinh(a[1]);
return [cr * cr - ci * ci, 2 * cr * ci];
};
/**
* returns the square of sin of a complex number
*/
const csin2 = (a) => {
let cr = Math.sin(a[0]) * Math.cosh(a[1]),
ci = Math.cos(a[0]) * Math.sinh(a[1]);
return [cr * cr - ci * ci, 2 * cr * ci];
};

/**
* adds a real number and a complex number
*/
const radd = (a, b) => {
return [a + b[0], b[1]];
};

/**
* substract two complex numbers
*/
const csub = (a, b) => {
return [a[0] - b[0], a[1] - b[1]];
};
/**
* adds a real number and a complex number
*/
const radd = (a, b) => {
return [a + b[0], b[1]];
};

/**
* substract two complex numbers
*/
const csub = (a, b) => {
return [a[0] - b[0], a[1] - b[1]];
};
}
C(
() => {
background(0);
Expand All @@ -106,10 +109,9 @@ C(
},
yAxis: {
range: [-2, 2],
textDirection: [-0.6, -1],
excludeOriginTick: false,
labelDirection: [0, -2],
},
center: [-2, 0],
originPosition: [-2, 0],
});

let h_W = 400 / 2;
Expand All @@ -136,7 +138,7 @@ C(
b = b - (c1 * ssnh + (b / 2) * ccsh);
}
ColorPalettes;
pixel(x, y, `hsl(${(1 - i / iters) * 360}, 50%, 50%, 50%)`, 0.5);
pixel(x, y, `hsla(${(1 - i / iters) * 360}, 50%, 50%, 80%)`, 0.5);
}
}
console.timeEnd("cl");
Expand Down
3 changes: 1 addition & 2 deletions public/examples/Colors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Colors</title>
<script defer src="../../src/app.js" type="module"></script>
<script defer src="../../Extensions/Colors/index.js"></script>
<script defer src="../../../Extensions/Colors/index.js"></script>
<script defer src="./index.js" type="module"></script>
<style>
body,
Expand Down
22 changes: 10 additions & 12 deletions public/examples/Colors/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { linearGradient } from "../../src/color/gradients.js";
import { Colors } from "../../src/constants/colors.js";
import { C } from "../../src/main.js";
import { rect } from "../../src/objects/geometry.js";
import { text } from "../../src/objects/text.js";
import { linearGradient } from "../../../src/color/gradients.js";
import { Colors } from "../../../src/constants/colors.js";
import { C } from "../../../src/main.js";
import { rect } from "../../../src/objects/geometry.js";
import { text } from "../../../src/objects/text.js";
import {
background,
fill,
fontFamily,
fontSize,
measureText,
noFill,
stroke,
translate,
} from "../../src/settings.js";
} from "../../../src/settings.js";
const W = 780;

C(
function () {
background(0);
let w = 120;
let w = 130;
const h = 50;
let paddingX = 10;
const paddingY = 30;
let boxW = w * 6 + paddingX * 2;
let boxH = h * 8 + paddingY * 2;

fontSize("19px");
// fontFamily("CMU Serif")
fontSize(19);
fontFamily("CMU Serif");
translate((W - boxW) / 2, 20);
// debugger;
function box(name, k) {
// background
if (name === "BLACK") stroke("white");
Expand Down Expand Up @@ -66,7 +66,6 @@ C(
noFill();
stroke(Manim.BLUE);
rect(0, 0, boxW, boxH);
stroke("black");
translate(paddingX, paddingY);
fill(Manim.BLUE_A);
for (let i = 0; i < colors.length; i++) {
Expand Down Expand Up @@ -127,7 +126,6 @@ C(
col[k] = Manim[col[k]];
}
translate(0, h);

// name of set
fill(linearGradient([0, 0], [measureText(name).width, 0], col));
if (k > 4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shapes</title>
<script defer src="../../dist/c.core.js"></script>
<title>Complex polynomials</title>

<script defer src="./index.js" type="module"></script>
<style>
body,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { C } from "../../src/main.js";
import { numberPlane } from "../../src/objects/coordinate_systems.js";
import { background, translate } from "../../src/settings.js";
import { pixel } from "../../../src/c.js";
import { C } from "../../../src/main.js";
import { numberPlane } from "../../../src/objects/coordinate_systems/number_plane.js";
import { background, translate } from "../../../src/settings.js";

C(
() => {
Expand All @@ -17,12 +18,6 @@ C(
range: [-2, 2],
},
});
// let GL = createWebGL();
// GL.background(0);
// let minx = -2;
// let maxx = 2;
// let miny = -2;
// let maxy = 2;
for (let x = -h_W; x <= h_W; x += 1) {
for (let y = -h_H; y <= h_H; y += 1) {
let a = x / 50,
Expand Down Expand Up @@ -50,7 +45,6 @@ C(
);

function cmul(p, x, y) {
//prettier-ignore
let k = p[0] * x - p[1] * y;
p[1] = p[0] * p[1] + x * p[1];
p[0] = k;
Expand Down
2 changes: 1 addition & 1 deletion public/examples/Dijkstra/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="../../src/app.js" type="module"></script>

<script defer src="./index.js" type="module"></script>
</head>
<body>
Expand Down
Loading

0 comments on commit ee30aa4

Please sign in to comment.