Skip to content

Commit

Permalink
Document Angled gradient direction
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Jun 29, 2024
1 parent 0e1771d commit 12f9507
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cursive-core/src/style/gradient/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ impl Interpolator for Radial {
pub struct Angled {
/// Angle of the gradient in radians.
///
/// 0 = vertical.
/// * 0 = vertical from top to bottom.
/// * Pi/2 = horizontal from left to right.
/// * Pi = vertical from bottom to top.
/// * 3.Pi/2 = vertical from bottom to top.
pub angle_rad: f32,

/// The gradient to apply following the gradient angle.
Expand Down
11 changes: 9 additions & 2 deletions cursive/examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cursive::style::{
};
use cursive::traits::*;
use cursive::utils::markup::gradient;
use cursive::views::{Dialog, GradientView, OnEventView, TextView};
use cursive::views::{Dialog, GradientView, OnEventView, PaddedView, TextView};
use cursive::XY;

fn main() {
Expand Down Expand Up @@ -41,11 +41,18 @@ fn show_more(c: &mut cursive::Cursive) {

fn show_more_2(c: &mut cursive::Cursive) {
let dialog = Dialog::new()
.content(PaddedView::lrtb(
0,
0,
8,
0,
TextView::new("Press Q or E to rotate the gradient"),
))
.button("Moar", show_more_3)
.fixed_size((40, 20));

let interpolator = Angled {
angle_rad: 4f32,
angle_rad: 0f32,
gradient: Linear::new(Rgb::from(0xFFFFFF), Rgb::from(0x000000)),
};
c.pop_layer();
Expand Down

0 comments on commit 12f9507

Please sign in to comment.