-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
real generation working with oneping
- Loading branch information
Showing
38 changed files
with
1,047 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// array example | ||
let emoji = zip(range(1, 6), ['🗻', '🚀', '🐋', '🍉', '🍩']); | ||
let scatter = Scatter(emoji.map(([i, e]) => [Text(e), [i, i]]), {size: 0.4}); | ||
let plot = Plot(scatter, {xlim: [0, 6], ylim: [0, 6]}); | ||
let frame = Frame(plot, {margin: 0.15}); | ||
return frame; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// fancy plot | ||
let xlim = [0, 2*pi], ylim = [-1, 1]; | ||
let func = x => -sin(x); | ||
let pal = x => interpolateHex(blue, red, x); | ||
let xticks = linspace(0, 2, 6).slice(1).map(x => [x*pi, `${rounder(x, 1)} π`]); | ||
let line = SymPath({fy: func, xlim}); | ||
let points = SymPoints({ | ||
fy: func, xlim, N: 21, size: 0.04, | ||
fs: (x, y) => Circle({fill: pal((1+y)/2), rad: (1+abs(y))/2}) | ||
}); | ||
let plot = Plot([line, points], { | ||
xlim, ylim, xanchor: 0, aspect: 1.5, xaxis_tick_pos: 'both', | ||
xticks, yticks: 5, xgrid: true, ygrid: true, xlabel_offset: 0.1, | ||
xlabel: 'phase', ylabel: 'amplitude', title: 'Inverted Sine Wave', | ||
xgrid_stroke_dasharray: 3, ygrid_stroke_dasharray: 3 | ||
}); | ||
return Frame(plot, {margin: 0.25}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// example of using math in a plot | ||
func = x => exp(sin(x)); | ||
path = SymPath({fy: func, xlim: [0, 2*pi]}); | ||
plot = Plot(path, {aspect: phi, ylim: [0, 3]}); | ||
return Frame(plot, {margin: 0.15}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// plop down a rectangle | ||
let rect = Rect(); | ||
let place = Place(rect, { | ||
pos: [0.6, 0.4], rad: [0.2, 0.1], rotate: 20, invar: true | ||
pos: [0.6, 0.4], rad: [0.2, 0.1], rotate: 20 | ||
}); | ||
return place; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// text greeting | ||
return Text('Hello World!', {font_weight: 'bold'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,14 @@ | |
"Note" | ||
], | ||
"networks": [ | ||
"Text", | ||
"Node", | ||
"Edge", | ||
"Network" | ||
], | ||
"functions": [ | ||
"Math", | ||
"Arrays", | ||
"Colors" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Arrays | ||
|
||
There are a number of functions designed to make working with arrays easier. They largely mimic similar functions found in core Python or the `numpy` library. | ||
|
||
## Functions | ||
|
||
- `zip(...arrs)` — combine arrays `arrs` element-wise | ||
- `reshape(arr, shape)` — reshape array `arr` to given dimensions `shape` | ||
- `split(arr, len)` — split array `arr` into subarrays of length `len` | ||
- `sum(arr)` — sum the elements of array `arr` | ||
- `all(arr)` — check if all elements of array `arr` are true | ||
- `any(arr)` — check if any element of array `arr` is true | ||
- `add(arr1, arr2)` — add arrays `arr1` and `arr2` element-wise | ||
- `mul(arr1, arr2)` — multiply arrays `arr1` and `arr2` element-wise | ||
- `cumsum(arr, first=true)` — compute the cumulative sum of array `arr` with the option to start at zero | ||
- `norm(arr, degree=1)` — compute the `degree`-norm of array `arr` | ||
- `normalize(arr, degree=1)` — normalize array `arr` to have `degree`-norm one | ||
- `range(i0, i1, step=1)` — generate an array of evenly spaced values from `i0` to `i1` with spacing `step` | ||
- `linspace(x0, x1, n=50)` — generate an array of `n` evenly spaced values between `x0` and `x1` | ||
- `enumerate(arr)` — pair each element of array `arr` with its index | ||
- `repeat(x, n)` — repeat array `x` a total of `n` times | ||
- `meshgrid(x, y)` — create a mesh grid from arrays `x` and `y` | ||
- `lingrid(xlim, ylim, N)` — create a 2D grid of `N = [Nx, Ny]` points over the ranges `xlim` and `ylim` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Colors | ||
|
||
There are a few functions designed to manipulate colors in HEX, RGB, and HSL formats. | ||
|
||
## Constants | ||
|
||
- `blue`= `'#1e88e5'` — a neon blue color | ||
- `red`= `'#ff0d57'` — a neon red color | ||
- `green`= `'#4caf50'` — a neon green color | ||
|
||
## Functions | ||
|
||
- `hex2rgb(hex)` — convert a HEX color string to an RGB array | ||
- `rgb2hex(rgb)` — convert an RGB array to a HEX color string | ||
- `rgb2hsl(rgb)` — convert an RGB array to an HSL array | ||
- `interpolateHex(hex1, hex2, alpha)` — interpolate between two HEX colors with weight `alpha` and return the result in RGB format. This is useful for creating continuous color palettes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Math | ||
|
||
Here we collect a variety of global mathematical functions and constants. You can still use the core JavaScript `Math` library as well. | ||
|
||
## Constants | ||
|
||
- `e` — the base of the natural logarithm (e) | ||
- `pi` — the geometric constant (π) | ||
- `phi` — the golden ratio (φ) | ||
- `r2d` — the conversion factor between radians and degrees (180/π) | ||
- `d2r` — the conversion factor between degrees and radians (π/180) | ||
|
||
## Functions | ||
|
||
- `exp(x)` — the exponential function | ||
- `log(x)` — the natural logarithm | ||
- `sin(x)` — the sine function | ||
- `cos(x)` — the cosine function | ||
- `tan(x)` — the tangent function | ||
- `abs(x)` — the absolute value | ||
- `pow(x, y)` — the power function | ||
- `sqrt(x)` — the square root function | ||
- `sign(x)` — the sign function | ||
- `floor(x)` — the floor function | ||
- `ceil(x)` — the ceiling function | ||
- `round(x)` — the rounding function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Text | ||
|
||
<span class="inherit">[Element](#Element)</span> | ||
|
||
Creates a new `Text` element. Uses built-in browser facilities when available to calculate font size and aspect ratio. | ||
|
||
Positional arguments: | ||
|
||
- `text`: a string to be used as the content | ||
|
||
Keyword arguments: | ||
|
||
- `size` = `12`: the font size (preferred over direct `font_size` property) | ||
- `actual` = `false`: whether to use actual size calculations | ||
- `hshift` = `0.0`: horizontal shift of the text | ||
- `vshift` = `-0.13`: vertical shift of the text | ||
- `calc_family`: the font family to use for size calculations | ||
- `calc_weight`: the font weight to use for size calculations | ||
- `calc_size`: the font size to use for size calculations |
Oops, something went wrong.