Created
December 6, 2020 11:07
-
-
Save arnabanimesh/77d4c63ea710d2a72b26ea57ae922eda to your computer and use it in GitHub Desktop.
Example cairo project
This file contains 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
[package] | |
name = "draw" | |
version = "0.1.0" | |
authors = ["author <author@email.com>"] | |
edition = "2018" | |
[dependencies] | |
cairo-rs = { version = "0.9.1", features = ["png"] } | |
png = "0.16.7" |
This file contains 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
Running `rustc --crate-name draw --edition=2018 src\main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=e6c1a2ca672e2bff --out-dir C:\Users\arnab\Documents\Github\rust\draw\target\debug\deps -C incremental=C:\Users\arnab\Documents\Github\rust\draw\target\debug\incremental -L dependency=C:\Users\arnab\Documents\Github\rust\draw\target\debug\deps --extern cairo=C:\Users\arnab\Documents\Github\rust\draw\target\debug\deps\libcairo-cc0c7941f7328314.rlib --extern png=C:\Users\arnab\Documents\Github\rust\draw\target\debug\deps\libpng-9535b98ef77e7a92.rlib -L native=C:/gtk-build/gtk/x64/release/lib -L native=C:/gtk-build/gtk/x64/release/lib -L native=C:/gtk-build/gtk/x64/release/lib -L native=C:/gtk-build/gtk/x64/release/lib` | |
Finished dev [unoptimized + debuginfo] target(s) in 0.90s | |
Running `target\debug\draw.exe` | |
error: process didn't exit successfully: `target\debug\draw.exe` (exit code: 0xc0000135, STATUS_DLL_NOT_FOUND) |
This file contains 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
use cairo::{Context, Format, ImageSurface}; | |
use std::fs::File; | |
fn main() { | |
let surface = ImageSurface::create(Format::ARgb32, 600, 600).expect("Couldn’t create surface"); | |
let context = Context::new(&surface); | |
context.set_source_rgb(1.0, 0.0, 0.0); | |
context.paint(); | |
let mut file = File::create("output.png").expect("Couldn’t create file"); | |
surface | |
.write_to_png(&mut file) | |
.expect("Couldn’t write to png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment