mirror of
https://github.com/bvanroll/ascii_generator.git
synced 2025-08-28 11:32:38 +00:00
char index no overflow, but needs to be higher
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
12
.idea/ascii_generator.iml
generated
Normal file
12
.idea/ascii_generator.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ascii_generator.iml" filepath="$PROJECT_DIR$/.idea/ascii_generator.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
17
src/main.rs
17
src/main.rs
@@ -4,30 +4,29 @@ use std::io;
|
||||
use fontdue;
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Add;
|
||||
use std::fs::File;
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
//let path = &args[1];
|
||||
//let path2 = &String::from("/Users/beppe/Git/asciiGenerator/fonts/Lucida Console.ttf");
|
||||
let data = include_bytes!("/Users/beppe/Git/asciiGenerator/fonts/Lucida Console.ttf") as &[u8];
|
||||
//let mut currentPath = env::current_dir().expect("what").as_path();
|
||||
let data = fs::read("./font/Lucida Console.ttf").expect("it didnt work");
|
||||
let font = fontdue::Font::from_bytes(data, fontdue::FontSettings::default()).expect("yessir");
|
||||
let mut output: HashMap<char, [[u8]]> = HashMap::new(); //todo Second value should be bitmap type???
|
||||
let mut output: HashMap<char, Vec<Vec<u8>>> = HashMap::new(); //todo Second value should be bitmap type???
|
||||
let mut char_index:u32 = 0;
|
||||
//NOTE this starts at 0
|
||||
const RASTER_FACTOR: f32 = 15.0;
|
||||
while char_index < 1000000 {
|
||||
let char = std::char::from_u32(char_index).expect("yessiiiiiir");
|
||||
while char_index < 10000 {
|
||||
let char = std::char::from_u32(char_index).expect("error converting u32 to char");
|
||||
char_index += 1;
|
||||
let (metrics, mut unsorted_raster) = font.rasterize(char, RASTER_FACTOR);
|
||||
if (unsorted_raster.len() > 0) {
|
||||
|
||||
|
||||
(chunks, remainder) = unsorted_raster.as_chunks(RASTER_FACTOR as usize);
|
||||
output.insert(char, chunks.clone());
|
||||
//(chunks, remainder) = unsorted_raster.as_chunks(RASTER_FACTOR as usize);
|
||||
//output.insert(char, chunks.clone());
|
||||
}
|
||||
}
|
||||
//println!("{}", convertData(data));
|
||||
}
|
||||
|
||||
//returns remainder, chunk
|
||||
|
Reference in New Issue
Block a user