pub struct Generator { /* private fields */ }
Expand description
A generator to perform zalgo operations.
This is a structure that contains an internal rand::ThreadRng
instance.
Implementations§
Source§impl Generator
impl Generator
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new generator with a new ThreadRng instance.
Examples found in repository?
6fn main() {
7 let mut generator = Generator::new();
8
9 // Create Zalgo text with Zalgo `char`s in all positions, with a maximum
10 // amount of Zalgo:
11 generator.gen("test", &mut String::new(), &GeneratorArgs::new(true, true, true, ZalgoSize::Maxi));
12
13 // Create Zalgo text with Zalgo `char`s in only the middle and lower
14 // positions, with a minimum amount of Zalgo:
15 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, true, true, ZalgoSize::Mini));
16
17 // Create Zalgo text with Zalgo `char`s in only the lower position, with a
18 // random amount of Zalgo (can be a low amount or high amount):
19 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, false, true, ZalgoSize::None));
20
21 // Consequentially, you can also not modify your given text with any Zalgo:
22 // Technically the `ZalgoSize` value given does not matter here.
23 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, false, false, ZalgoSize::None));
24}
Sourcepub fn gen<T: AsRef<str>>(
&mut self,
text: T,
buf: &mut String,
args: &GeneratorArgs,
)
pub fn gen<T: AsRef<str>>( &mut self, text: T, buf: &mut String, args: &GeneratorArgs, )
Generates a String containing Zalgo text. This is customizable via defining whether to include Zalgo text above the given string, in the middle of it, and below it.
The amount of Zalgo text can be (more or less) defined by the value of
the size
given. Read on the ZalgoSize
for more information.
§Examples
Create Zalgo text with Zalgo char
s in all positions, with a maximum
amount of Zalgo:
use zalgo::{Generator, GeneratorArgs, ZalgoSize};
let mut generator = Generator::new();
let args = GeneratorArgs::new(true, true, true, ZalgoSize::Maxi);
let mut out = String::new();
generator.gen("test", &mut out, &args);
Create Zalgo text with Zalgo char
s in only the middle and lower
positions, with a minimum amount of Zalgo:
use zalgo::{Generator, GeneratorArgs, ZalgoSize};
let mut generator = Generator::new();
let args = GeneratorArgs::new(false, true, true, ZalgoSize::Mini);
let mut out = String::new();
generator.gen("test", &mut out, &args);
Create Zalgo text with Zalgo char
s in only the lower position, with a
random amount of Zalgo (can be a low amount or high amount):
use zalgo::{Generator, GeneratorArgs, ZalgoSize};
let mut generator = Generator::new();
let args = GeneratorArgs::new(false, false, true, ZalgoSize::None);
let mut out = String::new();
generator.gen("test", &mut out, &args);
Consequentially, you can also not modify your given text with any Zalgo:
use zalgo::{Generator, GeneratorArgs, ZalgoSize};
let mut generator = Generator::new();
let args = GeneratorArgs::new(false, false, false, ZalgoSize::None);
let mut out = String::new();
generator.gen("test", &mut out, &args);
// Technically the `ZalgoSize` value given does not matter here.
Examples found in repository?
6fn main() {
7 let mut generator = Generator::new();
8
9 // Create Zalgo text with Zalgo `char`s in all positions, with a maximum
10 // amount of Zalgo:
11 generator.gen("test", &mut String::new(), &GeneratorArgs::new(true, true, true, ZalgoSize::Maxi));
12
13 // Create Zalgo text with Zalgo `char`s in only the middle and lower
14 // positions, with a minimum amount of Zalgo:
15 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, true, true, ZalgoSize::Mini));
16
17 // Create Zalgo text with Zalgo `char`s in only the lower position, with a
18 // random amount of Zalgo (can be a low amount or high amount):
19 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, false, true, ZalgoSize::None));
20
21 // Consequentially, you can also not modify your given text with any Zalgo:
22 // Technically the `ZalgoSize` value given does not matter here.
23 generator.gen("test", &mut String::new(), &GeneratorArgs::new(false, false, false, ZalgoSize::None));
24}
Sourcepub fn gen_simple<T: AsRef<str>>(&mut self, text: T, buf: &mut String)
pub fn gen_simple<T: AsRef<str>>(&mut self, text: T, buf: &mut String)
A simple function to generate a String containing Zalgo text.
Unlike gen
, this is not customizable. This produces zalgo above, in
the middle, and below the string.
§Examples
Create Zalgo text:
use zalgo::Generator;
let mut out = String::new();
let mut generator = Generator::new();
generator.gen_simple("test", &mut out);