Advertisement
Guest User

Safe code

a guest
May 24th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import -> new_module_from(STD_GRAPHICS_DRIVER::DIRECT_WRITE_BUFFER) as gfx
  2. put_pixel_safe(h:hex, x:float, y:float) -> int! @ALWATS -> true # @_ERROR_ENCOUNTER defer return 1
  3. {
  4.     bounds:map<float,float> = cast(map<float,float>)->gfx::WindowBorder<x,'width>.conjoinedWith(gfx::WindowBorder<y,'height>);
  5.     defer delete(bounds);
  6.     if(x -> bounds->bounds<x>::fitsAsPart(x, bounds, bounds->bounds<x>)) {
  7.         if(y -> bounds->bounds<y>::fitsAsPart(y, bounds, bounds->bounds<y>)) {
  8.             defer return 0;
  9.             (gfx -> PIXL_POS_X -> bounds -> x) ?set;
  10.             (gfx -> PIXL_POS_Y -> bounds -> y) ?set;
  11.             with (gfx -> GDrawEffects::asColor(h:hex)->PUTCOLOR( @x | @y )) as putcolor_at(h:hex,x:float,y:float);
  12.             defer (un_glue_s(*gfx::&gfx -> #GDrawEffects, de_macro_s('gfx, ALL_WITH_STATEMENTS)));
  13.             #init_gfx_memdriver $ putcolor_at(h                  , PIXL_POS_X    , PIXL_POS_Y    ) -> catch(e:Error)$set_error(e:Error);
  14.             #test_gfx_memdriver $ putcolor_at(gfx::colorInvert(h), PIXL_POS_Y    , PIXL_POS_X    ) -> catch(e:Error)$set_error(e:Error);
  15.             #test_gfx_memdriver $ putcolor_at(h                  , @PIXL_POS_X /2, @PIXL_POS_Y /2) -> catch(e:Error)$set_error(e:Error);
  16.             #test_gfx_memdriver $ putcolor_at(gfx::colorInvert(h), @PIXL_POS_Y /2, @PIXL_POS_X /2) -> catch(e:Error)$set_error(e:Error);
  17.             #test_gfx_memdriver $ putcolor_at(h                  , @PIXL_POS_X   , @PIXL_POS_Y   ) -> catch(e:Error)$set_error(e:Error);
  18.                                   putcolor_at(gfx::colorInvert(h), @PIXL_POS_Y   , @PIXL_POS_X   ) -> catch(e:Error)$set_error(e:Error);
  19.         }
  20.     }
  21. }
  22.  
  23. main(void) -> void
  24. {
  25.     gfx->safe_callmem_s(bh:BufferHandler, FrameBuffer::new() -> window());
  26.     window:Buffer = gfx::makeBuffer(bh -> pid, bh -> write_direct(true));
  27.     gfx::moveBuffer(window, GFX_WINDOW);
  28.     put_pixel(0xF00, 275, 200);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement