Skip to content

Commit

Permalink
add more info on docs and update example
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Sep 2, 2024
1 parent 0750c68 commit 6238517
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
2 changes: 2 additions & 0 deletions docs/docs/features/sixel-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Sixel, short for "six pixels", is a bitmap graphics format supported by terminal

Sixel was first introduced as a way of sending bitmap graphics to DEC dot matrix printers like the LA50. After being put into "sixel mode" the following data was interpreted to directly control six of the pins in the nine-pin print head. A string of sixel characters encodes a single 6-pixel high row of the image.

![Demo sixel with timg](/assets/features/demo-sixel-2.png)

The system was later re-used as a way to send bitmap data to the VT200 series and VT320 terminals when defining custom character sets. A series of sixels are used to transfer the bitmap for each character. This feature is known as soft character sets or dynamically redefinable character sets (DRCS). With the VT240, VT241, VT330, and VT340, the terminals could decode a complete sixel image to the screen, like those previously sent to printers.

![Demo sixel](/assets/features/demo-sixel.png)
Expand Down
Binary file added docs/static/assets/features/demo-sixel-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions sugarloaf/examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn main() {

sugarloaf.set_background_image(&sugarloaf::ImageProperties {
path: String::from("resources/rio-colors.png"),
width: 400.,
height: 400.,
width: Some(400.),
height: Some(400.),
x: 0.,
y: 0.,
});
Expand Down
35 changes: 17 additions & 18 deletions sugarloaf/src/components/rich_text/image_cache/atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,24 +277,23 @@ impl AtlasAllocator {
None
}

#[allow(unused)]
pub fn dump_lines(&self) {
for (i, line) in self.lines.iter().enumerate() {
print!("[{}]", i);
let low_bits = line.state & LOW_BITS;
if line.state & FRAGMENTED_BIT == 0 {
println!(" offset {}", low_bits);
} else {
let mut itr = low_bits;
while itr != !0 {
let slot = self.slots[itr as usize];
print!(" ({}..={})", slot.x, slot.x + slot.width);
itr = slot.next;
}
println!("");
}
}
}
// pub fn dump_lines(&self) {
// for (i, line) in self.lines.iter().enumerate() {
// print!("[{}]", i);
// let low_bits = line.state & LOW_BITS;
// if line.state & FRAGMENTED_BIT == 0 {
// println!(" offset {}", low_bits);
// } else {
// let mut itr = low_bits;
// while itr != !0 {
// let slot = self.slots[itr as usize];
// print!(" ({}..={})", slot.x, slot.x + slot.width);
// itr = slot.next;
// }
// println!("");
// }
// }
// }
}

const FRAGMENTED_BIT: u32 = 0x80000000;
Expand Down
43 changes: 21 additions & 22 deletions sugarloaf/src/components/rich_text/image_cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,34 @@ impl ImageCache {
let height = request.height;

// Check buffer size
if buffer_size(width as u32, height as u32).is_none() {
return None;
}
buffer_size(width as u32, height as u32)?;

// Too big to allocate
if !(width <= self.max_texture_size && height <= (self.max_texture_size / 4)) {
return None;
}

let atlas_data = self.atlas.alloc.allocate(width, height);
if atlas_data.is_none() {
return None;
// Grow atlas to fit
// self.max_texture_size += SIZE;
// self.atlas.fresh = true;
// self.atlas.dirty = true;
// self.entries.clear();
// println!("{:?}", self.max_texture_size);
// self.atlas.alloc = AtlasAllocator::new(self.max_texture_size, self.max_texture_size);
// self.atlas.buffer = vec![
// 0u8;
// self.max_texture_size as usize * self.max_texture_size as usize * 4
// ];
// atlas_data = self.atlas.alloc.allocate(width, height);
// println!("{:?}", atlas_data);
// if atlas_data.is_none() {
// return None;
// Grow atlas to fit
// self.max_texture_size += SIZE;
// self.atlas.fresh = true;
// self.atlas.dirty = true;
// self.entries.clear();
// println!("{:?}", self.max_texture_size);
// self.atlas.alloc = AtlasAllocator::new(self.max_texture_size, self.max_texture_size);
// self.atlas.buffer = vec![
// 0u8;
// self.max_texture_size as usize * self.max_texture_size as usize * 4
// ];
// atlas_data = self.atlas.alloc.allocate(width, height);
// println!("{:?}", atlas_data);

// if self.max_texture_size > MAX_SIZE {
// println!("should try to grow or reset atlas");
// }
}
// if self.max_texture_size > MAX_SIZE {
// println!("should try to grow or reset atlas");
// }
// }
let (x, y) = atlas_data?;
let entry_index = self.entries.len();
self.entries.push(Entry {
Expand Down

0 comments on commit 6238517

Please sign in to comment.