Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
falcucci committed Sep 21, 2024
2 parents 335a952 + 44b8d49 commit c856e63
Show file tree
Hide file tree
Showing 25 changed files with 620 additions and 548 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,42 @@ effort:
4. Where possible, features of the renderer should be
regression tested to ensure that changes do not change
the quality of the rendering unless explicitly intended.

## Dependencies

The tests require the nerd fonts to be installed. Run the
following:

### Windows
```powershell
scoop bucket add extras
scoop bucket add nerd-fonts
scoop install Monaspace-NF FiraCode-NF ProFont-NF CascadiaCode-NF Noto-NF
```

### Mac
```bash
brew install font-monaspace font-fira-code-nerd-font font-profont-nerd-font font-caskaydia-cove-nerd-font font-monaspace-nerd-font font-noto-nerd-font
```
### Linux
```bash
FONT_DIR="${HOME}/.local/share/fonts"
mkdir -p "$FONT_DIR"

for font in ${{ env.FONTS }}; do
ZIP_FILE="${font}${EXTENSION}"
if [[ "$font" == "Monaspace" ]]; then
DOWNLOAD_URL="https://github.com/githubnext/monaspace/releases/download/v1.101/monaspace-v1.101.zip"
else
DOWNLOAD_URL="https://github.com/ryanoasis/nerd-fonts/releases/download/${VERSION}/${ZIP_FILE}"
fi
echo "Downloading and installing '$font'..."
wget --quiet "$DOWNLOAD_URL" -O "$ZIP_FILE"
unzip -oq "$ZIP_FILE" -d "$FONT_DIR"
rm "$ZIP_FILE"
echo "'$font' installed successfully."
done

# Refresh font cache
fc-cache -fv
```
8 changes: 5 additions & 3 deletions crates/scene_viewer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{fs::File, io::Read, path::Path, sync::Arc};

use futures::executor::block_on;

use glamour::{Point2, Size2};
use glamour::{Point2, Rect, Size2};
use notify::{recommended_watcher, RecursiveMode, Watcher};
use palette::Srgba;
use parking_lot::RwLock;
Expand Down Expand Up @@ -57,8 +57,10 @@ impl ApplicationHandler for App {
scene.add_layer(Default::default());
scene.add_quad(
Quad::new(
Point2::new(self.mouse_pos.x as f32, self.mouse_pos.y as f32),
Size2::new(100., 100.),
Rect::new(
Point2::new(self.mouse_pos.x as f32, self.mouse_pos.y as f32),
Size2::new(100., 100.),
),
Srgba::new(0.5, 0.5, 1., 0.5),
)
.with_edge_blur(5.0),
Expand Down
98 changes: 55 additions & 43 deletions scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -5589,13 +5589,15 @@
{
"Quads": [
{
"top_left": {
"x": 150.0,
"y": 100.0
},
"size": {
"width": 100.0,
"height": 100.0
"region": {
"origin": {
"x": 150.0,
"y": 100.0
},
"size": {
"width": 100.0,
"height": 100.0
}
},
"color": {
"red": 1.0,
Expand Down Expand Up @@ -10563,13 +10565,15 @@
{
"Quads": [
{
"top_left": {
"x": 500.0,
"y": 10.0
},
"size": {
"width": 50.0,
"height": 50.0
"region": {
"origin": {
"x": 500.0,
"y": 10.0
},
"size": {
"width": 50.0,
"height": 50.0
}
},
"color": {
"red": 1.0,
Expand All @@ -10581,13 +10585,15 @@
"edge_blur": 0.0
},
{
"top_left": {
"x": 510.0,
"y": 20.0
},
"size": {
"width": 50.0,
"height": 50.0
"region": {
"origin": {
"x": 510.0,
"y": 20.0
},
"size": {
"width": 50.0,
"height": 50.0
}
},
"color": {
"red": 1.0,
Expand All @@ -10599,13 +10605,15 @@
"edge_blur": 0.0
},
{
"top_left": {
"x": 520.0,
"y": 30.0
},
"size": {
"width": 50.0,
"height": 50.0
"region": {
"origin": {
"x": 520.0,
"y": 30.0
},
"size": {
"width": 50.0,
"height": 50.0
}
},
"color": {
"red": 0.0,
Expand All @@ -10617,13 +10625,15 @@
"edge_blur": 0.0
},
{
"top_left": {
"x": 530.0,
"y": 40.0
},
"size": {
"width": 50.0,
"height": 50.0
"region": {
"origin": {
"x": 530.0,
"y": 40.0
},
"size": {
"width": 50.0,
"height": 50.0
}
},
"color": {
"red": 0.0,
Expand All @@ -10635,13 +10645,15 @@
"edge_blur": 0.0
},
{
"top_left": {
"x": 540.0,
"y": 50.0
},
"size": {
"width": 50.0,
"height": 50.0
"region": {
"origin": {
"x": 540.0,
"y": 50.0
},
"size": {
"width": 50.0,
"height": 50.0
}
},
"color": {
"red": 0.0,
Expand All @@ -10663,4 +10675,4 @@
},
"textures": {}
}
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod drawable;
mod drawable_pipeline;
mod drawable_reference;
mod offscreen_renderer;
pub mod prelude;
mod renderer;
mod scene;
mod shader;
Expand All @@ -15,6 +16,7 @@ mod test;
pub use glamour;
pub use palette;
pub use parley;
pub use winit;

pub use offscreen_renderer::OffscreenRenderer;
pub use renderer::Renderer;
Expand Down
6 changes: 6 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub use crate::offscreen_renderer::OffscreenRenderer;
pub use crate::renderer::Renderer;
pub use crate::scene::*;
pub use crate::shader::*;
pub use crate::shaper::Shaper;
pub use crate::winit_renderer::WinitRenderer;
4 changes: 2 additions & 2 deletions src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ impl Scene {
self
}

pub fn add_text_layout(&mut self, layout: Layout<Srgba>, top_left: Point2) {
pub fn add_text_layout(&mut self, layout: &Layout<Srgba>, top_left: Point2) {
self.update_layer(|resources, layer| {
layer.add_text_layout(resources, layout, top_left);
});
}

pub fn with_text_layout(mut self, layout: Layout<Srgba>, top_left: Point2) -> Self {
pub fn with_text_layout(mut self, layout: &Layout<Srgba>, top_left: Point2) -> Self {
self.add_text_layout(layout, top_left);
self
}
Expand Down
7 changes: 3 additions & 4 deletions src/scene/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ impl Layer {

pub fn add_clear(&mut self, color: Srgba) {
self.add_quad(Quad::new(
point2!(0.0, 0.0),
size2!(f32::MAX / 2., f32::MAX / 2.),
Rect::new(point2!(0.0, 0.0), size2!(f32::MAX / 2., f32::MAX / 2.)),
color,
));
}
Expand Down Expand Up @@ -163,7 +162,7 @@ impl Layer {
pub fn add_text_layout(
&mut self,
resources: &mut Resources,
layout: Layout<Srgba>,
layout: &Layout<Srgba>,
position: Point2,
) {
for line in layout.lines() {
Expand Down Expand Up @@ -208,7 +207,7 @@ impl Layer {
pub fn with_text_layout(
mut self,
resources: &mut Resources,
layout: Layout<Srgba>,
layout: &Layout<Srgba>,
position: Point2,
) -> Self {
self.add_text_layout(resources, layout, position);
Expand Down
5 changes: 5 additions & 0 deletions src/scene/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ impl Path {
}
}

#[deprecated(note = "Use new_line_instead")]
pub fn new_open_stroke(width: f32, color: Srgba, start: Point2) -> Self {
Self::new_line(width, color, start)
}

pub fn new_line(width: f32, color: Srgba, start: Point2) -> Self {
Self {
fill: None,
stroke: Some((width, color)),
Expand Down
Loading

0 comments on commit c856e63

Please sign in to comment.