Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. module Vectorize
  2. class Surface
  3. extend FFI::Library
  4. # TODO: How to make this portable?
  5. ffi_lib "/usr/X11/lib/libcairo.dylib"
  6.  
  7. attach_function :cairo_create, [:pointer], :pointer
  8.  
  9. CAIRO_FORMAT_INVALID = -1
  10. CAIRO_FORMAT_ARGB32 = 0
  11. CAIRO_FORMAT_RGB24 = 1
  12. CAIRO_FORMAT_A8 = 2
  13. CAIRO_FORMAT_A1 = 3
  14. CAIRO_FORMAT_RGB16_565 = 4
  15.  
  16. attr_reader :surface_pointer
  17. attr_reader :context_pointer
  18.  
  19. def context
  20. @context_pointer ||= self.class.cairo_create(surface_pointer)
  21. end
  22. end
  23. end
Add Comment
Please, Sign In to add comment