Code Monkey home page Code Monkey logo

Comments (2)

kojix2 avatar kojix2 commented on June 10, 2024

I don't know why, but it seems to work if I call UI.draw_path_new_figure first, as in page7a.c.

require 'libui'

UI = LibUI

UI.init

handler = UI::FFI::AreaHandler.malloc
handler.to_ptr.free = Fiddle::RUBY_FREE
area    = UI.new_area(handler)
brush   = UI::FFI::DrawBrush.malloc
brush.to_ptr.free = Fiddle::RUBY_FREE

handler_draw_event = Fiddle::Closure::BlockCaller.new(0, [1, 1, 1]) do |_, _, area_draw_params|
  area_draw_params = UI::FFI::AreaDrawParams.new(area_draw_params)
  100.times do |i|
    path = UI.draw_new_path(0)
    UI.draw_path_new_figure(path, 200, 200 - i) # Here
    UI.draw_path_arc_to(path, 200, 200 - i, 100 - i, Math::PI / 6, Math::PI / 4, 1)
    UI.draw_path_end(path)
    brush.Type = 0
    brush.R = rand(10) / 10.0
    brush.G = rand(10) / 10.0
    brush.B = rand(10) / 10.0
    brush.A = rand(10) / 10.0
    UI.draw_fill(area_draw_params.Context, path, brush.to_ptr)
    UI.draw_free_path(path)
  end
end

handler.Draw         = handler_draw_event
# 
do_nothing           = Fiddle::Closure::BlockCaller.new(0, [0]) {}
handler.MouseEvent   = do_nothing
handler.MouseCrossed = do_nothing
handler.DragBroken   = do_nothing
handler.KeyEvent     = do_nothing

box = UI.new_vertical_box
UI.box_set_padded(box, 1)
UI.box_append(box, area, 1)

main_window = UI.new_window('Basic Area', 400, 400, 1)
UI.window_set_margined(main_window, 1)
UI.window_set_child(main_window, box)

UI.window_on_closing(main_window) do
  UI.control_destroy(main_window)
  UI.quit
  0
end
UI.control_show(main_window)

UI.main
UI.quit

image

from libui.

AndyObtiva avatar AndyObtiva commented on June 10, 2024

Thanks for the help in noting that. My example (not a well written one, so I just updated it) does run on the Mac (and I bet it runs on Linux too). I think starting a figure is a Windows-only requirement (but it makes sense). I will keep that in mind in Glimmer DSL for LibUI.

from libui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.