notesy::math
Trigonometry, rounding and the like: for drawing an icon's rays or a
chart's arcs (notesy::icons), and for numbers that come whole or
not (a forecast's 21 and 21.4). Every function takes either, so a
script needn't mind which a number is. Angles are in radians. Needs
nothing.
rustuse notesy::{canvas, icons, math};
pub fn ready() {
// A sun: a ring, and eight rays.
let shapes = [canvas::circle([8.0, 8.0], 3.0)];
for i in 0..8 {
let a = math::pi() * math::float(i) / 4.0;
let x = math::cos(a);
let y = math::sin(a);
shapes.push(canvas::line([8.0 + x * 4.6, 8.0 + y * 4.6], [8.0 + x * 6.4, 8.0 + y * 6.4]));
}
icons::draw("sun", shapes);
let highs = [21, 23.6, 19.2];
let top = math::max(math::max(highs[0], highs[1]), highs[2]);
let label = `${math::round(top)}°`; // "24°"
}
| Function | What it gives |
|---|---|
math::pi() |
π |
math::sin(a), math::cos(a), math::tan(a) |
the sine, cosine and tangent of angle a |
math::asin(x), math::acos(x), math::atan(x) |
the angle with that sine, cosine or tangent |
math::atan2(y, x) |
the angle of the point x, y, seen from 0, 0 |
math::hypot(x, y) |
how far the point x, y is from 0, 0 |
math::radians(degrees), math::degrees(radians) |
an angle, the other way |
math::exp(x), math::ln(x), math::log10(x) |
e to the x, and logarithms |
math::round(x), math::floor(x), math::ceil(x) |
the nearest whole number, the one below, the one above: whole numbers |
math::float(x) |
x as a number with a fraction, whole or not |
math::abs(x), math::min(a, b), math::max(a, b), math::clamp(x, low, high) |
x without its sign, the smaller and the larger, x kept from low to high |
Every page
- Overview
- plugin.toml: Every field of plugin.toml
- Permissions: What a plugin can ask for, when notesy asks, and what changes it
- Scripts: How a script runs: its lifecycle, events, limits and errors
- Packing and installing: Making, checking, signing, packing and installing
- notesy::log: Lines for its log on the Plugins page
- notesy::events: Hearing what happens, and every event
- notesy::commands: Adding commands, and running notesy's
- notesy::store: Keeping its own data
- notesy::settings: Reading its settings
- notesy::secrets: Keys and tokens, in the system keychain
- notesy::notes: Reading and changing the vault's notes
- notesy::editor: The note in front
- notesy::files: A folder of its own
- notesy::links: Opening pages in the browser
- notesy::clipboard: Copying and pasting
- notesy::view: What panels, tabs and sections show
- notesy::panels and notesy::views: Adding side panels and tabs
- notesy::sections: Sidebar sections
- notesy::menus: Items in notesy's right-click menus
- notesy::status: Status bar items
- notesy::notices: Notices
- notesy::dialogs: Asking in a dialog, notesy's kinds or its own
- notesy::cards: Its part of the tree's hover cards
- notesy::boards: Boards' cards and arrows, and kinds of card of its own
- notesy::blocks: Drawing its fenced blocks
- notesy::icons: Drawing its own icons
- notesy::net: Requests to the sites it names
- notesy::accounts: Signing in to a service
- notesy::json: Reading and writing JSON
- notesy::toml: Reading and writing TOML
- notesy::yaml: Reading and writing YAML, and a note's front matter
- notesy::time: Now, written in the user's time zone, dates read, how long ago
- notesy::math: Trigonometry and the like, for drawing
- Names: Icon, Color, Tone, Side, Method, Command, Menu, Sidebar, Event: Notesy's names as enums
- notesy::preview: Its own screens for notesy preview
- notesy::perf: Timing its own work
- notesy::tex: Math macros for every note's formulas