Last active
July 20, 2017 18:52
-
-
Save HopperMCS/9d05c5d3792c4acf3ae711ecd44a5386 to your computer and use it in GitHub Desktop.
#WetA$$Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate cairo; | |
| use std::error::Error; | |
| use std::fs::File; | |
| use std::io::prelude::*; | |
| use std::path::Path; | |
| use cairo::{Context, ImageSurface, Format}; | |
| use std::fs; | |
| fn main() { | |
| fn mkdir() -> std::io::Result<()> { | |
| fs::create_dir("images")?; | |
| Ok(()) | |
| } | |
| fn all_triangles() { | |
| let surface = ImageSurface::create(Format::ARgb32, 421, 410); | |
| let one = Context::new(&surface); | |
| one.scale(1.0, 1.0); | |
| one.set_source_rgba(0.0, 0.79, 0.83, 0.8); | |
| one.line_to (143.0, 30.0); | |
| one.line_to (198.0, 176.0); | |
| one.line_to (23.0, 281.0); | |
| one.close_path(); | |
| one.fill_preserve (); | |
| one.set_source_rgba (0.0, 0.79, 0.83, 0.8); | |
| one.stroke (); | |
| let two = Context::new(&surface); | |
| two.scale(1.0, 1.0); | |
| two.set_source_rgba(0.60, 0.85, 0.91, 0.8); | |
| two.line_to (275.0, 44.0); | |
| two.line_to (377.0, 102.0); | |
| two.line_to (100.0, 118.0); | |
| two.close_path(); | |
| two.fill_preserve (); | |
| two.set_source_rgba (0.60, 0.85, 0.91, 0.8); | |
| two.stroke (); | |
| let three = Context::new(&surface); | |
| three.scale(1.0, 1.0); | |
| three.set_source_rgba(0.28, 0.42, 0.61, 0.8); | |
| three.line_to (363.0, 190.0); | |
| three.line_to (250.0, 126.0); | |
| three.line_to (305.0, 26.0); | |
| three.close_path(); | |
| three.fill_preserve (); | |
| three.set_source_rgba (0.28, 0.42, 0.61, 0.8); | |
| three.stroke (); | |
| let four = Context::new(&surface); | |
| four.scale(1.0, 1.0); | |
| four.set_source_rgba(0.0, 0.63, 0.90, 0.8); | |
| four.line_to (376.0, 130.0); | |
| four.line_to (304.0, 222.0); | |
| four.line_to (290.0, 147.0); | |
| four.close_path(); | |
| four.fill_preserve (); | |
| four.set_source_rgba (0.0, 0.63, 0.90, 0.8); | |
| four.stroke (); | |
| let five = Context::new(&surface); | |
| five.scale(1.0, 1.0); | |
| five.set_source_rgba(0.60, 0.85, 0.91, 0.8); | |
| five.line_to (244.0, 314.0); | |
| five.line_to (148.0, 375.0); | |
| five.line_to (70.0, 184.0); | |
| five.close_path(); | |
| five.fill_preserve (); | |
| five.set_source_rgba (0.60, 0.85, 0.91, 0.8); | |
| five.stroke (); | |
| let six = Context::new(&surface); | |
| six.scale(1.0, 1.0); | |
| six.set_source_rgba(0.28, 0.42, 0.61, 0.8); | |
| six.line_to (195.0, 260.0); | |
| six.line_to (333.0, 356.0); | |
| six.line_to (128.0, 330.0); | |
| six.close_path(); | |
| six.fill_preserve (); | |
| six.set_source_rgba (0.28, 0.42, 0.61, 0.8); | |
| six.stroke (); | |
| let seven = Context::new(&surface); | |
| seven.scale(1.0, 1.0); | |
| seven.set_source_rgba(0.0, 0.63, 0.90, 0.8); | |
| seven.line_to (304.0, 270.0); | |
| seven.line_to (311.0, 380.0); | |
| seven.line_to (252.0, 326.0); | |
| seven.close_path(); | |
| seven.fill_preserve (); | |
| seven.set_source_rgba (0.0, 0.63, 0.90, 0.8); | |
| seven.stroke (); | |
| let mut file = File::create("images/crstfn-color.png").unwrap(); | |
| surface.write_to_png(&mut file); | |
| } | |
| mkdir(); | |
| all_triangles(); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment