diff --git a/public/externalLibs/graphics/CURVES_README.md b/public/externalLibs/graphics/CURVES_README.md deleted file mode 100644 index 0b89085457..0000000000 --- a/public/externalLibs/graphics/CURVES_README.md +++ /dev/null @@ -1,114 +0,0 @@ -The CURVES library includes functions for drawing "curves", i.e. two-dimensional -lines, on a computer. Below are some useful definitions and examples to -work with CURVES. - -## Curves - -A Curve is a unary function which takes a Number argument within the -unit interval `[0,1]` and returns a point (a pair of Numbers). -You can think of the Number argument as time, -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 - -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 -`C(1)`. - -## Points - -To work with Points, we need a *constructor*, `make_point`, which -constructs Points from their x and y coordinates, and _selectors_, -`x_of` and `y_of`, for retrieving the x and y coordinates of a -Point. We require only that the constructors and selectors obey the -rules - -We can represent the *types* of these functions as follows: - -`make_point` : (Number, Number) → Point - -`x_of`, `y_of` : Point → Number - -## Examples - -A very simple curve is one that always returns the same point: - -``` -function point_curve(t) { - return make_point(0.5, 0.5); -} -``` - - -We define the Curve `unit_circle` and draw it as follows: - - -``` -function unit_circle(t) { - return make_point(math_sin(2 * math_PI * t), - math_cos(2 * math_PI * t)); -} -draw_connected_full_view(100)(unit_circle); -``` - -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` stretch or shrink -the given Curve to show the full curve and maximize its width and height, -with some padding. - - -``` -function unit_line_at(y) { - return t => make_point(t, y); -} -``` - -This function takes a number as argument, the y position, and -returns a Curve that is a horizontal line at the level given by y. - -The Curve `haf_way_line` - - -``` -const half_way_line = unit_line_at(0.5); -``` - - -is a horizontal line starting at `(0,0.5)` and ending at `(1,0.5)`. - -The type of `unit_line_at` is - -Number → Curve - -which is the same as: - -Number → (Number → Point) - -## Unary Curve Operators - -A unary Curve operator is a function that takes a curve as argument and returns -a Curve. The following function `up_a_bit` is a unary Curve operator that moves -a given curve up by 0.3. - - -``` -function up_a_bit(curve) { - return t => make_point(x_of(curve(t)), - y_of(curve(t)) + 0.3); -} -``` - - diff --git a/src/commons/application/types/ExternalTypes.ts b/src/commons/application/types/ExternalTypes.ts index 81adab3dab..ed91d5c464 100644 --- a/src/commons/application/types/ExternalTypes.ts +++ b/src/commons/application/types/ExternalTypes.ts @@ -11,7 +11,6 @@ export type External = { export enum ExternalLibraryName { NONE = 'NONE', RUNES = 'RUNES', - CURVES = 'CURVES', SOUNDS = 'SOUNDS', BINARYTREES = 'BINARYTREES', PIXNFLIX = 'PIXNFLIX', @@ -149,7 +148,6 @@ const machineLearningLibrary = [ const libEntries: Array<[ExternalLibraryName, string[]]> = [ [ExternalLibraryName.NONE, []], [ExternalLibraryName.RUNES, runesLibrary], - [ExternalLibraryName.CURVES, []], [ExternalLibraryName.SOUNDS, soundsLibrary], [ExternalLibraryName.BINARYTREES, binaryTreesLibrary], [ExternalLibraryName.PIXNFLIX, videoLibrary], diff --git a/src/commons/mocks/AssessmentMocks.ts b/src/commons/mocks/AssessmentMocks.ts index 52fc1f8956..19b8ebe563 100644 --- a/src/commons/mocks/AssessmentMocks.ts +++ b/src/commons/mocks/AssessmentMocks.ts @@ -290,11 +290,11 @@ export const mockRuneLibrary: Library = { globals: mockGlobals }; -const mockCurveLibrary: Library = { +const mockBinaryTreeLibrary: Library = { chapter: 4, external: { - name: ExternalLibraryName.CURVES, - symbols: externalLibraries.get(ExternalLibraryName.CURVES)! + name: ExternalLibraryName.BINARYTREES, + symbols: externalLibraries.get(ExternalLibraryName.BINARYTREES)! }, globals: mockGlobals }; @@ -399,7 +399,7 @@ export const mockAssessmentQuestions: Array { answer: 3, content: - 'This is the 3rd question. Oddly enough, it is an ungraded MCQ question that uses the curves library! Option C has a null hint!', + 'This is the 3rd question. Oddly enough, it is an ungraded MCQ question that uses the binary tree library! Option C has a null hint!', choices: [ { content: '**Option** `A`', @@ -419,7 +419,7 @@ export const mockAssessmentQuestions: Array } ], id: 2, - library: mockCurveLibrary, + library: mockBinaryTreeLibrary, type: 'mcq', solution: 0, xp: 0, @@ -429,7 +429,7 @@ export const mockAssessmentQuestions: Array { answer: 3, content: - 'This is the 4rth question. Oddly enough, it is a graded MCQ question that uses the curves library!', + 'This is the 4th question. Oddly enough, it is a graded MCQ question that uses the binary tree library!', choices: [ { content: 'A', @@ -449,7 +449,7 @@ export const mockAssessmentQuestions: Array } ], id: 3, - library: mockCurveLibrary, + library: mockBinaryTreeLibrary, type: 'mcq', solution: null, xp: 0, @@ -484,7 +484,7 @@ export const mockClosedAssessmentQuestions: Array { }); }); }); - - test('loads CURVES library correctly', () => { - const newExternalLibraryName = ExternalLibraryName.CURVES; - - const symbols = externalLibraries.get(newExternalLibraryName)!; - const library: Library = { - chapter, - external: { - name: newExternalLibraryName, - symbols - }, - globals - }; - - return expectSaga(workspaceSaga) - .put.like({ action: endClearContext(library, workspaceLocation) }) - .dispatch({ - type: BEGIN_CLEAR_CONTEXT, - payload: { library, workspaceLocation, shouldInitLibrary: true } - }) - .silentRun() - .then(() => { - expect(loadLib).toHaveBeenCalledWith('CURVES'); - expect(getReadyWebGLForCanvas).toHaveBeenCalledWith('curve'); - globals.forEach(item => { - expect(window[item[0]]).toEqual(item[1]); - }); - }); - }); }); describe('evalCode', () => {