Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions public/externalLibs/graphics/CURVES_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ and of the point returned by the Curve as the position
of your pen on a 2-dimensional plane at the time indicated by the
argument. We represent the *type* of such Curve functions like this:

Curve: Number → Point
Curve := Number → Point

where Point is a pair of Numbers. If `C` is a Curve, then the starting
point of the curve is always `C(0)`, and the ending point is always
Expand Down Expand Up @@ -53,12 +53,19 @@ function unit_circle(t) {
draw_connected_full_view(100)(unit_circle);
```
</a>
Here, `draw_connected_full_view` is applied to 100, which means that 100+1 points
are being sampled. The function returns a Curve drawer: A function that turns
a Curve into a Drawing. When a program evaluates to a Drawing, the Source system
Here, `draw_connected_full_view` is applied to 100, which means that 100+1 numbers
between 0 and 1 are being sampled:
0, 0.01, 0.02, ..., 0.99, 1.
The function `draw_connected_full_view` is a Curve drawer:
A function that takes a number and returns a function that turns
a Curve into a Drawing.

Drawer := Number → (Curve → Drawing)

When a program evaluates to a Drawing, the Source system
displays it graphically, in a window, instead of textually.

The functions returned by `draw_connected_full_view` stretches or shrinks
The functions returned by `draw_connected_full_view` stretch or shrink
the given Curve to show the full curve and maximize its width and height,
with some padding.

Expand Down
32 changes: 16 additions & 16 deletions public/externalLibs/graphics/webGLcurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function generateCurve(scaleMode, drawMode, numPoints, func, isFullView) {
* displays it graphically, in a window, instead of textually.
* The parts between (0,0) and (1,1) of the resulting Drawing
* are shown in the window.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_connected(num) {
return function(func) {
Expand All @@ -98,10 +98,10 @@ function draw_connected(num) {
* displays it graphically, in a window, instead of textually.
* The parts between (0,0) and (1,1) of the resulting Drawing
* are shown in the window.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_points_on(num) {
return curve =>
Expand All @@ -116,10 +116,10 @@ function draw_points_on(num) {
* displays it graphically, in a window, instead of textually.
* The Drawing is squeezed such that all its parts are shown in the
* window.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_points_squeezed_to_window(num) {
return function(func) {
Expand All @@ -136,10 +136,10 @@ function draw_points_squeezed_to_window(num) {
* The Drawing is resized proportionally such that it
* is shown as big as possible, and still fits entirely
* inside the window.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_connected_squeezed_to_window(num) {
return function(func) {
Expand All @@ -156,10 +156,10 @@ function draw_connected_squeezed_to_window(num) {
* The Drawing is stretched or shrunk
* to show the full curve
* and maximize its width and height, with some padding.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_connected_full_view(num) {
return function(func) {
Expand All @@ -175,10 +175,10 @@ function draw_connected_full_view(num) {
* displays it graphically, in a window, instead of textually.
* The Drawing is scaled proportionally to show the full curve
* and maximize its size, with some padding.
* @param {number} num - determines the number of points to be
* @param {Number} num - determines the number of points to be
* sampled. Including 0 and 1,
* there are <CODE>num + 1</CODE> evenly spaced sample points.
* @return {function} function from Curves to Drawings.
* @return {function} function of type Curve → Drawing
*/
function draw_connected_full_view_proportional(num) {
return function(func) {
Expand All @@ -188,8 +188,8 @@ function draw_connected_full_view_proportional(num) {

/**
* makes a Point with given x and y coordinates
* @param {number} x - x-coordinate of new point
* @param {number} y - y-coordinate of new point
* @param {Number} x - x-coordinate of new point
* @param {Number} y - y-coordinate of new point
* @returns {Point} with x and y as coordinates
*/
function make_point(x, y) {
Expand All @@ -199,7 +199,7 @@ function make_point(x, y) {
/**
* retrieves the x-coordinate a given Point
* @param {Point} p - given point
* @returns {number} x-coordinate of the Point
* @returns {Number} x-coordinate of the Point
*/
function x_of(pt) {
return pt[0]
Expand All @@ -208,7 +208,7 @@ function x_of(pt) {
/**
* retrieves the y-coordinate a given Point
* @param {Point} p - given point
* @returns {number} y-coordinate of the Point
* @returns {Number} y-coordinate of the Point
*/
function y_of(pt) {
return pt[1]
Expand Down
19 changes: 8 additions & 11 deletions public/externalLibs/graphics/webGLhi_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function unit_line(t) {
* only points with the given y-coordinate.
*
* @param {number} t - fraction between 0 and 1
* @returns {curve} horizontal Curve
* @returns {Curve} horizontal Curve
*/
function unit_line_at(y) {
return function(t) {
Expand Down Expand Up @@ -188,15 +188,14 @@ function deriv_t(n) {
}

/**
* this function returns a unary Curve operator:
* It takes scaling factors <CODE>a</CODE> and <CODE>b</CODE> as arguments
* this function takes scaling factors <CODE>a</CODE> and <CODE>b</CODE> as arguments
* and returns a unary Curve operator that
* scales a given Curve by <CODE>a</CODE> in x-direction and by <CODE>b</CODE>
* in y-direction.
*
* @param {number} a - scaling factor in x-direction
* @param {number} b - scaling factor in y-direction
* @returns {function} unary Curve operator
* @returns {unary_Curve_operator} function that takes a Curve and returns a Curve
*/
function scale_x_y(a, b) {
return curve =>
Expand All @@ -207,13 +206,12 @@ function scale_x_y(a, b) {
}

/**
* this function returns a unary Curve operator:
* It takes a scaling factor s argument and returns a
* this function takes a scaling factor s argument and returns a
* unary Curve operator that
* scales a given Curve by s in x and y direction.
*
* @param {number} s - scaling factor
* @returns {function} unary Curve operator
* @returns {unary_Curve_operator} function that takes a Curve and returns a Curve
*/
function scale(s) {
return scale_x_y(s, s)
Expand Down Expand Up @@ -422,7 +420,7 @@ function show_connected_gosper(level) {
* applying an angle given by the given angle-producing function
* @param {number} level - number of repeated applications of gosperize to the curve
* @param {function} angle_at - function that determines the angle at each level
* @returns {curve}
* @returns {Curve}
*/
function param_gosper(level, angle_at) {
if (level === 0) {
Expand All @@ -433,11 +431,10 @@ function param_gosper(level, angle_at) {
}

/**
* this function returns a unary Curve operator:
* It takes an angle theta and returns a Curve operator:
* this function takes an angle theta and returns a unary Curve operator:
* A function that takes a Curve as argument and returns
* a new Curve, according to the Gosper operation, modified
* with the given angle
* with the given angle theta
*
* @param {Curve} curve - given Curve
* @returns {Curve} result Curve
Expand Down
28 changes: 14 additions & 14 deletions public/externalLibs/video/video_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,10 @@ VD.handleUpdateDimensions = function(w, h) {

// upside-down

const WIDTH = get_video_width();
const HEIGHT = get_video_height();

function upside_down(src, dest) {
const WIDTH = get_video_width();
const HEIGHT = get_video_height();
for (let x=0; x<WIDTH; x = x + 1) {
for (let y=0; y<HEIGHT; y = y + 1) {
copy_pixel(
Expand All @@ -390,17 +391,16 @@ function upside_down(src, dest) {
apply_filter(upside_down);

// sine distortion

const wave_length = 5 * (2 * math_PI);
const distortion = 10;

const WIDTH = get_video_width();
const HEIGHT = get_video_height();

const mid_x = WIDTH/2;
const mid_y = HEIGHT/2;

function sine_distortion(src, dest) {
const wave_length = 5 * (2 * math_PI);
const distortion = 10;

const WIDTH = get_video_width();
const HEIGHT = get_video_height();

const mid_x = WIDTH/2;
const mid_y = HEIGHT/2;
for (let x=0; x<WIDTH; x = x + 1){
for (let y=0; y<HEIGHT; y = y + 1){
const d_x = math_abs(mid_x - x);
Expand All @@ -421,10 +421,10 @@ apply_filter(sine_distortion);

// inversion filter

const WIDTH = get_video_width();
const HEIGHT = get_video_height();

function invert(src, dest) {
const WIDTH = get_video_width();
const HEIGHT = get_video_height();

for (let x=0; x<WIDTH; x = x + 1){
for (let y=0; y<HEIGHT; y = y + 1){
dest[x][y] = [255 - red_of(src[x][y]),
Expand Down