Skip to content

Shared Surface functionality #20

Description

@mikowitz

For non-NI functions, there is cairo::Surface which is a shared impl for the surface types.

use cairo::{Format, ImageSurface, PdfSurface};

pub fn test() {
    let surface = ImageSurface::create(Format::ARgb32, 100, 100).expect("ok");

    let pdf = PdfSurface::new(100., 100., "test.pdf").expect("ok");

    foo(&surface);
    foo(&pdf);
}

fn foo(surface: &cairo::Surface) {
    println!("{:#?}", surface);
    println!("  {:#?}", surface.type_());
}

Perhaps a surface wrapper enum, like

enum Surface {
  Image(cairo::ImageSurface)
  Pdf(cairo::PdfSurface)
  ...
}

that can be passed as a reference up to Elixir, then passed back, matched on, and the surface passed directly to the helper functions.

  • create_similar
  • create_for_rectangle
  • mime_data
  • device
  • set_(device_offset)
  • set_(device_scale)
  • set_(fallback_resolution)
  • status
  • flush
  • finish
  • type_

Device

implement this as a struct, I think?

Enums

  • Content
  • SurfaceType

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions