Improve various code and docs spelling/grammar

This commit is contained in:
Keavon Chambers 2021-07-23 17:25:05 -07:00
parent 5e8ace928c
commit f00601e5a7
7 changed files with 42 additions and 34 deletions

View file

@ -44,7 +44,7 @@ Development is broken into monthly sprints culminating in a presentation at the
[Rust](https://www.rust-lang.org/) is the language of choice for many compelling reasons. It is low-level and highly efficient which is important because the nondestructive, resolution-agnostic editing approach will already be challenging to render fast enough for interactive, real-time editing. Furthermore, Rust makes multithreading easy to implement and its safety guarantees will eliminate the inclusion of many bugs and crashes in the software. It is also simple to compile Rust code natively to Windows, macOS, Linux, and web browsers via WebAssembly, with the possibility of deploying Graphite to mobile devices down the road as well.
[Vue.js](https://vuejs.org/) is the web frontend framework initally used for building Graphite's user interface. This means, for the moment, Graphite will only run in a browser using Rust code compiled to [WebAssembly](https://webassembly.org/) (via [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)). This web-based GUI is intended to be rewritten in a native Rust GUI framework once that ecosystem matures or the project has engineering resources to write a tailor-made GUI framework for Graphite's needs. The project initially started writing a custom GUI system throughout 2020, but slow progress led to the decision of shelving it in lieu of a temporary web-based GUI.
[Vue.js](https://vuejs.org/) is the web frontend framework initially used for building Graphite's user interface. This means, for the moment, Graphite will only run in a browser using Rust code compiled to [WebAssembly](https://webassembly.org/) (via [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)). This web-based GUI is intended to be rewritten in a native Rust GUI framework once that ecosystem matures or the project has engineering resources to write a tailor-made GUI framework for Graphite's needs. The project initially started writing a custom GUI system throughout 2020, but slow progress led to the decision of shelving it in lieu of a temporary web-based GUI.
[WebGPU](https://gpuweb.github.io/gpuweb) (via the [WGPU Rust library](https://wgpu.rs)) will be used as the graphics API because it is modern, portable, and safe. It makes deployment on the web and native platforms easy while ensuring consistent cross-platform behavior. Shaders will be written in [Rust GPU](https://github.com/EmbarkStudios/rust-gpu) to keep the codebase in a consistent language. Graphite 0.1 and 0.2 will rely on the browser's built-in vector rendering capabilities for SVG editing before diving into building Graphite's complex render engine.

View file

@ -1,4 +1,5 @@
//! **Rust WebAssembly wrapper**: `/client/web/wasm/`
//! **Rust WebAssembly wrapper**: `/client/web/wasm/`
//!
//! Wraps the Editor Core Library and provides an API for the web app to use unburdened by Rust's complex data types that are not supported by WASM
pub mod document;

View file

@ -1,9 +1,9 @@
use serde::{Deserialize, Serialize};
/// Structure that represent a color.
/// Internally alpha is stored as `f32` that range from `0.0` (transparent) to 1.0 (opaque).
/// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque).
/// The other components (RGB) are stored as `f32` that range from `0.0` up to `f32::MAX`,
/// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and 0.0 (black) to 1.0 (white) in SDR color.
/// the values encode the brightness of each channel proportional to the light intensity in cd/m² (nits) in HDR, and `0.0` (black) to `1.0` (white) in SDR color.
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
pub struct Color {
@ -20,8 +20,9 @@ impl Color {
pub const GREEN: Color = Color::from_unsafe(0., 1., 0.);
pub const BLUE: Color = Color::from_unsafe(0., 0., 1.);
/// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negatives numbers (including `-0.0`), NaN and infinity are not valid values and return `None`.
/// Values greater than `1.0` for alpha are not valid.
/// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negative numbers (including `-0.0`), NaN, and infinity are not valid values and return `None`.
/// Alpha values greater than `1.0` are not valid.
///
/// # Examples
/// ```
/// use graphite_document_core::color::Color;
@ -38,12 +39,13 @@ impl Color {
Some(Color { red, green, blue, alpha })
}
// Return Color without checking `red` `green` `blue` and without transparency (alpha = 1.0)
/// Return an opaque `Color` from given `f32` RGB channels.
const fn from_unsafe(red: f32, green: f32, blue: f32) -> Color {
Color { red, green, blue, alpha: 1. }
}
/// Return a Color without transparency (alpha = 0xFF).
/// Return an opaque SDR `Color` given RGB channels from `0` to `255`.
///
/// # Examples
/// ```
/// use graphite_document_core::color::Color;
@ -55,7 +57,7 @@ impl Color {
Color::from_rgba8(red, green, blue, 255)
}
/// Return a color initialized by it's 8bit component.
/// Return an SDR `Color` given RGBA channels from `0` to `255`.
///
/// # Examples
/// ```
@ -64,16 +66,16 @@ impl Color {
/// assert!("72676261" == color.rgba_hex())
/// ```
pub fn from_rgba8(red: u8, green: u8, blue: u8, alpha: u8) -> Color {
let map = |int_color| int_color as f32 / 255.0;
let map_range = |int_color| int_color as f32 / 255.0;
Color {
red: map(red),
green: map(green),
blue: map(blue),
alpha: map(alpha),
red: map_range(red),
green: map_range(green),
blue: map_range(blue),
alpha: map_range(alpha),
}
}
/// Return the red component.
/// Return the `red` component.
///
/// # Examples
/// ```
@ -85,7 +87,7 @@ impl Color {
self.red
}
/// Return the green component.
/// Return the `green` component.
///
/// # Examples
/// ```
@ -97,7 +99,7 @@ impl Color {
self.green
}
/// Return the blue component.
/// Return the `blue` component.
///
/// # Examples
/// ```
@ -109,7 +111,7 @@ impl Color {
self.blue
}
/// Return the alpha component.
/// Return the `alpha` component without checking its expected `0.0` to `1.0` range.
///
/// # Examples
/// ```
@ -133,11 +135,13 @@ impl Color {
(self.red, self.green, self.blue, self.alpha)
}
/// Return a String of hexadecimal value with two digit per components ("RRGGBBAA").
/// Return an 8-character RGBA hex string (without a # prefix).
///
/// # Examples
/// ```
/// use graphite_document_core::color::Color;
/// let color = Color::from_rgba8(0x72, 0x67, 0x62, 0x61);
/// assert!("72676261" == color.rgba_hex())
/// let color = Color::from_rgba8(0x7C, 0x67, 0xFA, 0x61);
/// assert!("7C67FA61" == color.rgba_hex())
/// ```
pub fn rgba_hex(&self) -> String {
format!(
@ -149,11 +153,11 @@ impl Color {
)
}
/// Return a String of hexadecimal value with two digit per components ("RRGGBB").
/// Return a 6-character RGB hex string (without a # prefix).
/// ```
/// use graphite_document_core::color::Color;
/// let color = Color::from_rgba8(0x72, 0x67, 0x62, 0x61);
/// assert!("726762" == color.rgb_hex())
/// let color = Color::from_rgba8(0x7C, 0x67, 0xFA, 0x61);
/// assert!("7C67FA" == color.rgb_hex())
/// ```
pub fn rgb_hex(&self) -> String {
format!("{:02X?}{:02X?}{:02X?}", (self.r() * 255.) as u8, (self.g() * 255.) as u8, (self.b() * 255.) as u8,)

View file

@ -1,7 +1,8 @@
//! Graphite Document Core Library: `/core/document/`
//! Graphite Document Core Library: `/core/document/`
//!
//! A stateless library for updating Graphite design document (GDD) files.
//! The official Graphite CLI and Editor Core Library are the primary users,
//! but this library is intended to be useful to any application that wants to link the library for the purpose of updating GDD files by sending edit operations.
//! The official Graphite CLI and Editor Core Library are the primary users, but this library is intended to be useful
//! to any application that wants to link the library for the purpose of updating GDD files by sending edit operations.
//! Optionally depends on the Renderer Core Library if rendering is required.
pub mod color;

View file

@ -58,7 +58,7 @@ pub enum DocumentMessage {
NudgeSelectedLayers(f64, f64),
FlipLayer(Vec<LayerId>, bool, bool),
MoveSelectedLayersTo { path: Vec<LayerId>, insert_index: isize },
ReorderSelectedLayers(i32), // relatve_positon,
ReorderSelectedLayers(i32), // relatve_position,
}
impl From<DocumentOperation> for DocumentMessage {
@ -605,17 +605,17 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
responses.push_back(DocumentMessage::DeleteSelectedLayers.into());
responses.push_back(DocumentMessage::PasteLayers { path, insert_index }.into());
}
ReorderSelectedLayers(relative_positon) => {
ReorderSelectedLayers(relative_position) => {
let all_layer_paths = self.all_layers_sorted();
let selected_layers = self.selected_layers_sorted();
if let Some(pivot) = match relative_positon.signum() {
if let Some(pivot) = match relative_position.signum() {
-1 => selected_layers.first(),
1 => selected_layers.last(),
_ => unreachable!(),
} {
if let Some(pos) = all_layer_paths.iter().position(|path| path == pivot) {
let max = all_layer_paths.len() as i64 - 1;
let insert_pos = (pos as i64 + relative_positon as i64).clamp(0, max) as usize;
let insert_pos = (pos as i64 + relative_position as i64).clamp(0, max) as usize;
let insert = all_layer_paths.get(insert_pos);
if let Some(insert_path) = insert {
let (id, path) = insert_path.split_last().expect("Can't move the root folder");
@ -626,7 +626,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessor> for DocumentMessageHand
.map(|x| x.last().unwrap())
.collect();
let non_selected: Vec<_> = folder.layer_ids.iter().filter(|id| selected.iter().all(|x| x != id)).collect();
let offset = if relative_positon < 0 || non_selected.is_empty() { 0 } else { 1 };
let offset = if relative_position < 0 || non_selected.is_empty() { 0 } else { 1 };
let fallback = offset * (non_selected.len());
let insert_index = non_selected.iter().position(|x| *x == id).map(|x| x + offset).unwrap_or(fallback) as isize;
responses.push_back(DocumentMessage::MoveSelectedLayersTo { path: path.to_vec(), insert_index }.into())

View file

@ -1,4 +1,5 @@
//! **Graphite Editor Core Library**: `/core/editor/`
//! **Graphite Editor Core Library**: `/core/editor/`
//!
//! Used by a frontend editor client to maintain GUI state and dispatch user events.
//! The official Graphite editor is the primary user,
//! but others software like game engines could embed their own customized editor implementations.

View file

@ -1,4 +1,5 @@
//! Graphite Renderer Core Library: `/core/renderer/`
//! Graphite Renderer Core Library: `/core/renderer/`
//!
//! A stateless library (with the help of in-memory and/or on-disk caches for performance) for rendering Graphite's render graph (GRD) files.
//! The official Graphite CLI and Document Core Library are the primary users,
//! but this library is intended to be useful to any application that wants to link the library for the purpose of rendering Graphite's render graphs.