text:
# Julia wrapper for header: /home/oleksandr/ath/julia/_cimgui.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

const cimgui = "..\\cimgui\\Debug\\imgui_sw.dll"

function igTest(test1::Cint,test2::Cint)
    ccall((:igTest,cimgui),Cint,(Cint,Cint),test1,test2)
end

function igGetIO()
    ccall((:igGetIO,cimgui),Ptr{ImGuiIO},())
end

function igGetStyle()
    ccall((:igGetStyle,cimgui),Ptr{ImGuiStyle},())
end

function igGetDrawData()
    ccall((:igGetDrawData,cimgui),Ptr{ImDrawData},())
end

function igNewFrame()
    ccall((:igNewFrame,cimgui),Void,())
end

function igRender()
    ccall((:igRender,cimgui),Void,())
end

function igShutdown()
    ccall((:igShutdown,cimgui),Void,())
end

function igShowUserGuide()
    ccall((:igShowUserGuide,cimgui),Void,())
end

function igShowStyleEditor(ref::Ptr{ImGuiStyle})
    ccall((:igShowStyleEditor,cimgui),Void,(Ptr{ImGuiStyle},),ref)
end

function igShowTestWindow(opened::Ptr{bool})
    ccall((:igShowTestWindow,cimgui),Void,(Ptr{bool},),opened)
end

function igShowMetricsWindow(opened::Ptr{bool})
    ccall((:igShowMetricsWindow,cimgui),Void,(Ptr{bool},),opened)
end

function igBegin(name::ASCIIString,p_opened::Ptr{bool},flags::ImGuiWindowFlags)
    ccall((:igBegin,cimgui),bool,(Cstring,Ptr{bool},ImGuiWindowFlags),name,p_opened,flags)
end

function igBegin2(name::Ptr{UInt8},p_opened::Ptr{bool},size_on_first_use::ImVec2,bg_alpha::Cfloat,flags::ImGuiWindowFlags)
    ccall((:igBegin2,cimgui),bool,(Ptr{UInt8},Ptr{bool},ImVec2,Cfloat,ImGuiWindowFlags),name,p_opened,size_on_first_use,bg_alpha,flags)
end

function igEnd()
    ccall((:igEnd,cimgui),Void,())
end

function igBeginChild(str_id::Ptr{UInt8},size::ImVec2,border::bool,extra_flags::ImGuiWindowFlags)
    ccall((:igBeginChild,cimgui),bool,(Ptr{UInt8},ImVec2,bool,ImGuiWindowFlags),str_id,size,border,extra_flags)
end

function igBeginChildEx(id::ImGuiID,size::ImVec2,border::bool,extra_flags::ImGuiWindowFlags)
    ccall((:igBeginChildEx,cimgui),bool,(ImGuiID,ImVec2,bool,ImGuiWindowFlags),id,size,border,extra_flags)
end

function igEndChild()
    ccall((:igEndChild,cimgui),Void,())
end

function igGetContentRegionMax(out::Ptr{ImVec2})
    ccall((:igGetContentRegionMax,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetContentRegionAvail(out::Ptr{ImVec2})
    ccall((:igGetContentRegionAvail,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetContentRegionAvailWidth()
    ccall((:igGetContentRegionAvailWidth,cimgui),Cfloat,())
end

function igGetWindowContentRegionMin(out::Ptr{ImVec2})
    ccall((:igGetWindowContentRegionMin,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetWindowContentRegionMax(out::Ptr{ImVec2})
    ccall((:igGetWindowContentRegionMax,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetWindowContentRegionWidth()
    ccall((:igGetWindowContentRegionWidth,cimgui),Cfloat,())
end

function igGetWindowDrawList()
    ccall((:igGetWindowDrawList,cimgui),Ptr{ImDrawList},())
end

function igGetWindowFont()
    ccall((:igGetWindowFont,cimgui),Ptr{ImFont},())
end

function igGetWindowFontSize()
    ccall((:igGetWindowFontSize,cimgui),Cfloat,())
end

function igSetWindowFontScale(scale::Cfloat)
    ccall((:igSetWindowFontScale,cimgui),Void,(Cfloat,),scale)
end

function igGetWindowPos(out::Ptr{ImVec2})
    ccall((:igGetWindowPos,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetWindowSize(out::Ptr{ImVec2})
    ccall((:igGetWindowSize,cimgui),Void,(Ptr{ImVec2},),out)
end

function igGetWindowWidth()
    ccall((:igGetWindowWidth,cimgui),Cfloat,())
end

function igGetWindowHeight()
    ccall((:igGetWindowHeight,cimgui),Cfloat,())
end

function igIsWindowCollapsed()
    ccall((:igIsWindowCollapsed,cimgui),bool,())
end

function igSetNextWindowPos(pos::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetNextWindowPos,cimgui),Void,(ImVec2,ImGuiSetCond),pos,cond)
end

function igSetNextWindowPosCenter(cond::ImGuiSetCond)
    ccall((:igSetNextWindowPosCenter,cimgui),Void,(ImGuiSetCond,),cond)
end

function igSetNextWindowSize(size::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetNextWindowSize,cimgui),Void,(ImVec2,ImGuiSetCond),size,cond)
end

function igSetNextWindowContentSize(size::ImVec2)
    ccall((:igSetNextWindowContentSize,cimgui),Void,(ImVec2,),size)
end

function igSetNextWindowContentWidth(width::Cfloat)
    ccall((:igSetNextWindowContentWidth,cimgui),Void,(Cfloat,),width)
end

function igSetNextWindowCollapsed(collapsed::bool,cond::ImGuiSetCond)
    ccall((:igSetNextWindowCollapsed,cimgui),Void,(bool,ImGuiSetCond),collapsed,cond)
end

function igSetNextWindowFocus()
    ccall((:igSetNextWindowFocus,cimgui),Void,())
end

function igSetWindowPos(pos::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetWindowPos,cimgui),Void,(ImVec2,ImGuiSetCond),pos,cond)
end

function igSetWindowSize(size::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetWindowSize,cimgui),Void,(ImVec2,ImGuiSetCond),size,cond)
end

function igSetWindowCollapsed(collapsed::bool,cond::ImGuiSetCond)
    ccall((:igSetWindowCollapsed,cimgui),Void,(bool,ImGuiSetCond),collapsed,cond)
end

function igSetWindowFocus()
    ccall((:igSetWindowFocus,cimgui),Void,())
end

function igSetWindowPosByName(name::Ptr{UInt8},pos::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetWindowPosByName,cimgui),Void,(Ptr{UInt8},ImVec2,ImGuiSetCond),name,pos,cond)
end

function igSetWindowSize2(name::Ptr{UInt8},size::ImVec2,cond::ImGuiSetCond)
    ccall((:igSetWindowSize2,cimgui),Void,(Ptr{UInt8},ImVec2,ImGuiSetCond),name,size,cond)
end

function igSetWindowCollapsed2(name::Ptr{UInt8},collapsed::bool,cond::ImGuiSetCond)
    ccall((:igSetWindowCollapsed2,cimgui),Void,(Ptr{UInt8},bool,ImGuiSetCond),name,collapsed,cond)
end

function igSetWindowFocus2(name::Ptr{UInt8})
    ccall((:igSetWindowFocus2,cimgui),Void,(Ptr{UInt8},),name)
end

function igGetScrollX()
    ccall((:igGetScrollX,cimgui),Cfloat,())
end

function igGetScrollY()
    ccall((:igGetScrollY,cimgui),Cfloat,())
end

function igGetScrollMaxX()
    ccall((:igGetScrollMaxX,cimgui),Cfloat,())
end

function igGetScrollMaxY()
    ccall((:igGetScrollMaxY,cimgui),Cfloat,())
end

function igSetScrollX(scroll_x::Cfloat)
    ccall((:igSetScrollX,cimgui),Void,(Cfloat,),scroll_x)
end

function igSetScrollY(scroll_y::Cfloat)
    ccall((:igSetScrollY,cimgui),Void,(Cfloat,),scroll_y)
end

function igSetScrollHere(center_y_ratio::Cfloat)
    ccall((:igSetScrollHere,cimgui),Void,(Cfloat,),center_y_ratio)
end

function igSetScrollFromPosY(pos_y::Cfloat,center_y_ratio::Cfloat)
    ccall((:igSetScrollFromPosY,cimgui),Void,(Cfloat,Cfloat),pos_y,center_y_ratio)
end

function igSetKeyboardFocusHere(offset::Cint)
    ccall((:igSetKeyboardFocusHere,cimgui),Void,(Cint,),offset)
end

function igSetStateStorage(tree::Ptr{ImGuiStorage})
    ccall((:igSetStateStorage,cimgui),Void,(Ptr{ImGuiStorage},),tree)
end

function igGetStateStorage()
    ccall((:igGetStateStorage,cimgui),Ptr{ImGuiStorage},())
end

function igPushFont(font::Ptr{ImFont})
    ccall((:igPushFont,cimgui),Void,(Ptr{ImFont},),font)
end

function igPopFont()
    ccall((:igPopFont,cimgui),Void,())
end

function igPushStyleColor(idx::ImGuiCol,col::ImVec4)
    ccall((:igPushStyleColor,cimgui),Void,(ImGuiCol,ImVec4),idx,col)
end

function igPopStyleColor(count::Cint)
    ccall((:igPopStyleColor,cimgui),Void,(Cint,),count)
end

function igPushStyleVar(idx::ImGuiStyleVar,val::Cfloat)
    ccall((:igPushStyleVar,cimgui),Void,(ImGuiStyleVar,Cfloat),idx,val)
end

function igPushStyleVarVec(idx::ImGuiStyleVar,val::ImVec2)
    ccall((:igPushStyleVarVec,cimgui),Void,(ImGuiStyleVar,ImVec2),idx,val)
end

function igPopStyleVar(count::Cint)
    ccall((:igPopStyleVar,cimgui),Void,(Cint,),count)
end

function igGetColorU32(idx::ImGuiCol,alpha_mul::Cfloat)
    ccall((:igGetColorU32,cimgui),ImU32,(ImGuiCol,Cfloat),idx,alpha_mul)
end

function igGetColorU32Vec(col::Ptr{ImVec4})
    ccall((:igGetColorU32Vec,cimgui),ImU32,(Ptr{ImVec4},),col)
end

function igPushItemWidth(item_width::Cfloat)
    ccall((:igPushItemWidth,cimgui),Void,(Cfloat,),item_width)
end

function igPopItemWidth()
    ccall((:igPopItemWidth,cimgui),Void,())
end

function igCalcItemWidth()
    ccall((:igCalcItemWidth,cimgui),Cfloat,())
end

function igPushTextWrapPos(wrap_pos_x::Cfloat)
    ccall((:igPushTextWrapPos,cimgui),Void,(Cfloat,),wrap_pos_x)
end

function igPopTextWrapPos()
    ccall((:igPopTextWrapPos,cimgui),Void,())
end

function igPushAllowKeyboardFocus(v::bool)
    ccall((:igPushAllowKeyboardFocus,cimgui),Void,(bool,),v)
end

function igPopAllowKeyboardFocus()
    ccall((:igPopAllowKeyboardFocus,cimgui),Void,())
end

function igPushButtonRepeat(repeat::bool)
    ccall((:igPushButtonRepeat,cimgui),Void,(bool,),repeat)
end

function igPopButtonRepeat()
    ccall((:igPopButtonRepeat,cimgui),Void,())
end

function igBeginGroup()
    ccall((:igBeginGroup,cimgui),Void,())
end

function igEndGroup()
    ccall((:igEndGroup,cimgui),Void,())
end

function igSeparator()
    ccall((:igSeparator,cimgui),Void,())
end

function igSameLine(local_pos_x::Cfloat,spacing_w::Cfloat)
    ccall((:igSameLine,cimgui),Void,(Cfloat,Cfloat),local_pos_x,spacing_w)
end

function igSpacing()
    ccall((:igSpacing,cimgui),Void,())
end

function igDummy(size::Ptr{ImVec2})
    ccall((:igDummy,cimgui),Void,(Ptr{ImVec2},),size)
end

function igIndent()
    ccall((:igIndent,cimgui),Void,())
end

function igUnindent()
    ccall((:igUnindent,cimgui),Void,())
end

function igColumns(count::Cint,id::Ptr{UInt8},border::bool)
    ccall((:igColumns,cimgui),Void,(Cint,Ptr{UInt8},bool),count,id,border)
end

function igNextColumn()
    ccall((:igNextColumn,cimgui),Void,())
end

function igGetColumnIndex()
    ccall((:igGetColumnIndex,cimgui),Cint,())
end

function igGetColumnOffset(column_index::Cint)
    ccall((:igGetColumnOffset,cimgui),Cfloat,(Cint,),column_index)
end

function igSetColumnOffset(column_index::Cint,offset_x::Cfloat)
    ccall((:igSetColumnOffset,cimgui),Void,(Cint,Cfloat),column_index,offset_x)
end

function igGetColumnWidth(column_index::Cint)
    ccall((:igGetColumnWidth,cimgui),Cfloat,(Cint,),column_index)
end

function igGetColumnsCount()
    ccall((:igGetColumnsCount,cimgui),Cint,())
end

function igGetCursorPos(pOut::Ptr{ImVec2})
    ccall((:igGetCursorPos,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetCursorPosX()
    ccall((:igGetCursorPosX,cimgui),Cfloat,())
end

function igGetCursorPosY()
    ccall((:igGetCursorPosY,cimgui),Cfloat,())
end

function igSetCursorPos(local_pos::ImVec2)
    ccall((:igSetCursorPos,cimgui),Void,(ImVec2,),local_pos)
end

function igSetCursorPosX(x::Cfloat)
    ccall((:igSetCursorPosX,cimgui),Void,(Cfloat,),x)
end

function igSetCursorPosY(y::Cfloat)
    ccall((:igSetCursorPosY,cimgui),Void,(Cfloat,),y)
end

function igGetCursorStartPos(pOut::Ptr{ImVec2})
    ccall((:igGetCursorStartPos,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetCursorScreenPos(pOut::Ptr{ImVec2})
    ccall((:igGetCursorScreenPos,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igSetCursorScreenPos(pos::ImVec2)
    ccall((:igSetCursorScreenPos,cimgui),Void,(ImVec2,),pos)
end

function igAlignFirstTextHeightToWidgets()
    ccall((:igAlignFirstTextHeightToWidgets,cimgui),Void,())
end

function igGetTextLineHeight()
    ccall((:igGetTextLineHeight,cimgui),Cfloat,())
end

function igGetTextLineHeightWithSpacing()
    ccall((:igGetTextLineHeightWithSpacing,cimgui),Cfloat,())
end

function igGetItemsLineHeightWithSpacing()
    ccall((:igGetItemsLineHeightWithSpacing,cimgui),Cfloat,())
end

function igPushIdStr(str_id::Ptr{UInt8})
    ccall((:igPushIdStr,cimgui),Void,(Ptr{UInt8},),str_id)
end

function igPushIdStrRange(str_begin::Ptr{UInt8},str_end::Ptr{UInt8})
    ccall((:igPushIdStrRange,cimgui),Void,(Ptr{UInt8},Ptr{UInt8}),str_begin,str_end)
end

function igPushIdPtr(ptr_id::Ptr{Void})
    ccall((:igPushIdPtr,cimgui),Void,(Ptr{Void},),ptr_id)
end

function igPushIdInt(int_id::Cint)
    ccall((:igPushIdInt,cimgui),Void,(Cint,),int_id)
end

function igPopId()
    ccall((:igPopId,cimgui),Void,())
end

function igGetIdStr(str_id::Ptr{UInt8})
    ccall((:igGetIdStr,cimgui),ImGuiID,(Ptr{UInt8},),str_id)
end

function igGetIdStrRange(str_begin::Ptr{UInt8},str_end::Ptr{UInt8})
    ccall((:igGetIdStrRange,cimgui),ImGuiID,(Ptr{UInt8},Ptr{UInt8}),str_begin,str_end)
end

function igGetIdPtr(ptr_id::Ptr{Void})
    ccall((:igGetIdPtr,cimgui),ImGuiID,(Ptr{Void},),ptr_id)
end

function igTextV(fmt::Ptr{UInt8},args::va_list)
    ccall((:igTextV,cimgui),Void,(Ptr{UInt8},va_list),fmt,args)
end

function igTextColoredV(col::ImVec4,fmt::Ptr{UInt8},args::va_list)
    ccall((:igTextColoredV,cimgui),Void,(ImVec4,Ptr{UInt8},va_list),col,fmt,args)
end

function igTextDisabledV(fmt::Ptr{UInt8},args::va_list)
    ccall((:igTextDisabledV,cimgui),Void,(Ptr{UInt8},va_list),fmt,args)
end

function igTextWrappedV(fmt::Ptr{UInt8},args::va_list)
    ccall((:igTextWrappedV,cimgui),Void,(Ptr{UInt8},va_list),fmt,args)
end

function igTextUnformatted(text::Ptr{UInt8},text_end::Ptr{UInt8})
    ccall((:igTextUnformatted,cimgui),Void,(Ptr{UInt8},Ptr{UInt8}),text,text_end)
end

function igLabelTextV(label::Ptr{UInt8},fmt::Ptr{UInt8},args::va_list)
    ccall((:igLabelTextV,cimgui),Void,(Ptr{UInt8},Ptr{UInt8},va_list),label,fmt,args)
end

function igBullet()
    ccall((:igBullet,cimgui),Void,())
end

function igBulletTextV(fmt::Ptr{UInt8},args::va_list)
    ccall((:igBulletTextV,cimgui),Void,(Ptr{UInt8},va_list),fmt,args)
end

function igButton(label::ASCIIString,size::ImVec2)
    ccall((:igButton,cimgui),bool,(Cstring,ImVec2),label,size)
end

function igSmallButton(label::Ptr{UInt8})
    ccall((:igSmallButton,cimgui),bool,(Ptr{UInt8},),label)
end

function igInvisibleButton(str_id::Ptr{UInt8},size::ImVec2)
    ccall((:igInvisibleButton,cimgui),bool,(Ptr{UInt8},ImVec2),str_id,size)
end

function igImage(user_texture_id::ImTextureID,size::ImVec2,uv0::ImVec2,uv1::ImVec2,tint_col::ImVec4,border_col::ImVec4)
    ccall((:igImage,cimgui),Void,(ImTextureID,ImVec2,ImVec2,ImVec2,ImVec4,ImVec4),user_texture_id,size,uv0,uv1,tint_col,border_col)
end

function igImageButton(user_texture_id::ImTextureID,size::ImVec2,uv0::ImVec2,uv1::ImVec2,frame_padding::Cint,bg_col::ImVec4,tint_col::ImVec4)
    ccall((:igImageButton,cimgui),bool,(ImTextureID,ImVec2,ImVec2,ImVec2,Cint,ImVec4,ImVec4),user_texture_id,size,uv0,uv1,frame_padding,bg_col,tint_col)
end

function igCollapsingHeader(label::Ptr{UInt8},str_id::Ptr{UInt8},display_frame::bool,default_open::bool)
    ccall((:igCollapsingHeader,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},bool,bool),label,str_id,display_frame,default_open)
end

function igCheckbox(label::Ptr{UInt8},v::Ptr{bool})
    ccall((:igCheckbox,cimgui),bool,(Ptr{UInt8},Ptr{bool}),label,v)
end

function igCheckboxFlags(label::Ptr{UInt8},flags::Ptr{UInt32},flags_value::UInt32)
    ccall((:igCheckboxFlags,cimgui),bool,(Ptr{UInt8},Ptr{UInt32},UInt32),label,flags,flags_value)
end

function igRadioButtonBool(label::Ptr{UInt8},active::bool)
    ccall((:igRadioButtonBool,cimgui),bool,(Ptr{UInt8},bool),label,active)
end

function igRadioButton(label::Ptr{UInt8},v::Ptr{Cint},v_button::Cint)
    ccall((:igRadioButton,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint),label,v,v_button)
end

function igCombo(label::Ptr{UInt8},current_item::Ptr{Cint},items::Ptr{Ptr{UInt8}},items_count::Cint,height_in_items::Cint)
    ccall((:igCombo,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{Ptr{UInt8}},Cint,Cint),label,current_item,items,items_count,height_in_items)
end

function igCombo2(label::Ptr{UInt8},current_item::Ptr{Cint},items_separated_by_zeros::Ptr{UInt8},height_in_items::Cint)
    ccall((:igCombo2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{UInt8},Cint),label,current_item,items_separated_by_zeros,height_in_items)
end

function igCombo3(label::Ptr{UInt8},current_item::Ptr{Cint},items_getter::Ptr{Void},data::Ptr{Void},items_count::Cint,height_in_items::Cint)
    ccall((:igCombo3,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{Void},Ptr{Void},Cint,Cint),label,current_item,items_getter,data,items_count,height_in_items)
end

function igColorButton(col::ImVec4,small_height::bool,outline_border::bool)
    ccall((:igColorButton,cimgui),bool,(ImVec4,bool,bool),col,small_height,outline_border)
end

function igColorEdit3(label::Ptr{UInt8},col::Ptr{Cfloat})
    ccall((:igColorEdit3,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat}),label,col)
end

function igColorEdit4(label::Ptr{UInt8},col::Ptr{Cfloat},show_alpha::bool)
    ccall((:igColorEdit4,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},bool),label,col,show_alpha)
end

function igColorEditMode(mode::ImGuiColorEditMode)
    ccall((:igColorEditMode,cimgui),Void,(ImGuiColorEditMode,),mode)
end

function igPlotLines(label::Ptr{UInt8},values::Ptr{Cfloat},values_count::Cint,values_offset::Cint,overlay_text::Ptr{UInt8},scale_min::Cfloat,scale_max::Cfloat,graph_size::ImVec2,stride::Cint)
    ccall((:igPlotLines,cimgui),Void,(Ptr{UInt8},Ptr{Cfloat},Cint,Cint,Ptr{UInt8},Cfloat,Cfloat,ImVec2,Cint),label,values,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size,stride)
end

function igPlotLines2(label::Ptr{UInt8},values_getter::Ptr{Void},data::Ptr{Void},values_count::Cint,values_offset::Cint,overlay_text::Ptr{UInt8},scale_min::Cfloat,scale_max::Cfloat,graph_size::ImVec2)
    ccall((:igPlotLines2,cimgui),Void,(Ptr{UInt8},Ptr{Void},Ptr{Void},Cint,Cint,Ptr{UInt8},Cfloat,Cfloat,ImVec2),label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size)
end

function igPlotHistogram(label::Ptr{UInt8},values::Ptr{Cfloat},values_count::Cint,values_offset::Cint,overlay_text::Ptr{UInt8},scale_min::Cfloat,scale_max::Cfloat,graph_size::ImVec2,stride::Cint)
    ccall((:igPlotHistogram,cimgui),Void,(Ptr{UInt8},Ptr{Cfloat},Cint,Cint,Ptr{UInt8},Cfloat,Cfloat,ImVec2,Cint),label,values,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size,stride)
end

function igPlotHistogram2(label::Ptr{UInt8},values_getter::Ptr{Void},data::Ptr{Void},values_count::Cint,values_offset::Cint,overlay_text::Ptr{UInt8},scale_min::Cfloat,scale_max::Cfloat,graph_size::ImVec2)
    ccall((:igPlotHistogram2,cimgui),Void,(Ptr{UInt8},Ptr{Void},Ptr{Void},Cint,Cint,Ptr{UInt8},Cfloat,Cfloat,ImVec2),label,values_getter,data,values_count,values_offset,overlay_text,scale_min,scale_max,graph_size)
end

function igProgressBar(fraction::Cfloat,size_arg::Ptr{ImVec2},overlay::Ptr{UInt8})
    ccall((:igProgressBar,cimgui),Void,(Cfloat,Ptr{ImVec2},Ptr{UInt8}),fraction,size_arg,overlay)
end

function igSliderFloat(label::Ptr{UInt8},v::Ptr{Cfloat},v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igSliderFloat,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_min,v_max,display_format,power)
end

function igSliderFloat2(label::Ptr{UInt8},v::Ptr{Cfloat},v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igSliderFloat2,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_min,v_max,display_format,power)
end

function igSliderFloat3(label::Ptr{UInt8},v::Ptr{Cfloat},v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igSliderFloat3,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_min,v_max,display_format,power)
end

function igSliderFloat4(label::Ptr{UInt8},v::Ptr{Cfloat},v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igSliderFloat4,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_min,v_max,display_format,power)
end

function igSliderAngle(label::Ptr{UInt8},v_rad::Ptr{Cfloat},v_degrees_min::Cfloat,v_degrees_max::Cfloat)
    ccall((:igSliderAngle,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat),label,v_rad,v_degrees_min,v_degrees_max)
end

function igSliderInt(label::Ptr{UInt8},v::Ptr{Cint},v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igSliderInt,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint,Cint,Ptr{UInt8}),label,v,v_min,v_max,display_format)
end

function igSliderInt2(label::Ptr{UInt8},v::Ptr{Cint},v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igSliderInt2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint,Cint,Ptr{UInt8}),label,v,v_min,v_max,display_format)
end

function igSliderInt3(label::Ptr{UInt8},v::Ptr{Cint},v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igSliderInt3,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint,Cint,Ptr{UInt8}),label,v,v_min,v_max,display_format)
end

function igSliderInt4(label::Ptr{UInt8},v::Ptr{Cint},v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igSliderInt4,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint,Cint,Ptr{UInt8}),label,v,v_min,v_max,display_format)
end

function igVSliderFloat(label::Ptr{UInt8},size::ImVec2,v::Ptr{Cfloat},v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igVSliderFloat,cimgui),bool,(Ptr{UInt8},ImVec2,Ptr{Cfloat},Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,size,v,v_min,v_max,display_format,power)
end

function igVSliderInt(label::Ptr{UInt8},size::ImVec2,v::Ptr{Cint},v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igVSliderInt,cimgui),bool,(Ptr{UInt8},ImVec2,Ptr{Cint},Cint,Cint,Ptr{UInt8}),label,size,v,v_min,v_max,display_format)
end

function igDragFloat(label::Ptr{UInt8},v::Ptr{Cfloat},v_speed::Cfloat,v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igDragFloat,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_speed,v_min,v_max,display_format,power)
end

function igDragFloat2(label::Ptr{UInt8},v::Ptr{Cfloat},v_speed::Cfloat,v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igDragFloat2,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_speed,v_min,v_max,display_format,power)
end

function igDragFloat3(label::Ptr{UInt8},v::Ptr{Cfloat},v_speed::Cfloat,v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igDragFloat3,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_speed,v_min,v_max,display_format,power)
end

function igDragFloat4(label::Ptr{UInt8},v::Ptr{Cfloat},v_speed::Cfloat,v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},power::Cfloat)
    ccall((:igDragFloat4,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Cfloat,Ptr{UInt8},Cfloat),label,v,v_speed,v_min,v_max,display_format,power)
end

function igDragFloatRange2(label::Ptr{UInt8},v_current_min::Ptr{Cfloat},v_current_max::Ptr{Cfloat},v_speed::Cfloat,v_min::Cfloat,v_max::Cfloat,display_format::Ptr{UInt8},display_format_max::Ptr{UInt8},power::Cfloat)
    ccall((:igDragFloatRange2,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Ptr{Cfloat},Cfloat,Cfloat,Cfloat,Ptr{UInt8},Ptr{UInt8},Cfloat),label,v_current_min,v_current_max,v_speed,v_min,v_max,display_format,display_format_max,power)
end

function igDragInt(label::Ptr{UInt8},v::Ptr{Cint},v_speed::Cfloat,v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igDragInt,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cfloat,Cint,Cint,Ptr{UInt8}),label,v,v_speed,v_min,v_max,display_format)
end

function igDragInt2(label::Ptr{UInt8},v::Ptr{Cint},v_speed::Cfloat,v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igDragInt2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cfloat,Cint,Cint,Ptr{UInt8}),label,v,v_speed,v_min,v_max,display_format)
end

function igDragInt3(label::Ptr{UInt8},v::Ptr{Cint},v_speed::Cfloat,v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igDragInt3,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cfloat,Cint,Cint,Ptr{UInt8}),label,v,v_speed,v_min,v_max,display_format)
end

function igDragInt4(label::Ptr{UInt8},v::Ptr{Cint},v_speed::Cfloat,v_min::Cint,v_max::Cint,display_format::Ptr{UInt8})
    ccall((:igDragInt4,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cfloat,Cint,Cint,Ptr{UInt8}),label,v,v_speed,v_min,v_max,display_format)
end

function igDragIntRange2(label::Ptr{UInt8},v_current_min::Ptr{Cint},v_current_max::Ptr{Cint},v_speed::Cfloat,v_min::Cint,v_max::Cint,display_format::Ptr{UInt8},display_format_max::Ptr{UInt8})
    ccall((:igDragIntRange2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{Cint},Cfloat,Cint,Cint,Ptr{UInt8},Ptr{UInt8}),label,v_current_min,v_current_max,v_speed,v_min,v_max,display_format,display_format_max)
end

function igInputText(label::Ptr{UInt8},buf::Ptr{UInt8},buf_size::Csize_t,flags::ImGuiInputTextFlags,callback::ImGuiTextEditCallback,user_data::Ptr{Void})
    ccall((:igInputText,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},Csize_t,ImGuiInputTextFlags,ImGuiTextEditCallback,Ptr{Void}),label,buf,buf_size,flags,callback,user_data)
end

function igInputTextMultiline(label::Ptr{UInt8},buf::Ptr{UInt8},buf_size::Csize_t,size::ImVec2,flags::ImGuiInputTextFlags,callback::ImGuiTextEditCallback,user_data::Ptr{Void})
    ccall((:igInputTextMultiline,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},Csize_t,ImVec2,ImGuiInputTextFlags,ImGuiTextEditCallback,Ptr{Void}),label,buf,buf_size,size,flags,callback,user_data)
end

function igInputFloat(label::Ptr{UInt8},v::Ptr{Cfloat},step::Cfloat,step_fast::Cfloat,decimal_precision::Cint,extra_flags::ImGuiInputTextFlags)
    ccall((:igInputFloat,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cfloat,Cfloat,Cint,ImGuiInputTextFlags),label,v,step,step_fast,decimal_precision,extra_flags)
end

function igInputFloat2(label::Ptr{UInt8},v::Ptr{Cfloat},decimal_precision::Cint,extra_flags::ImGuiInputTextFlags)
    ccall((:igInputFloat2,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cint,ImGuiInputTextFlags),label,v,decimal_precision,extra_flags)
end

function igInputFloat3(label::Ptr{UInt8},v::Ptr{Cfloat},decimal_precision::Cint,extra_flags::ImGuiInputTextFlags)
    ccall((:igInputFloat3,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cint,ImGuiInputTextFlags),label,v,decimal_precision,extra_flags)
end

function igInputFloat4(label::Ptr{UInt8},v::Ptr{Cfloat},decimal_precision::Cint,extra_flags::ImGuiInputTextFlags)
    ccall((:igInputFloat4,cimgui),bool,(Ptr{UInt8},Ptr{Cfloat},Cint,ImGuiInputTextFlags),label,v,decimal_precision,extra_flags)
end

function igInputInt(label::Ptr{UInt8},v::Ptr{Cint},step::Cint,step_fast::Cint,extra_flags::ImGuiInputTextFlags)
    ccall((:igInputInt,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Cint,Cint,ImGuiInputTextFlags),label,v,step,step_fast,extra_flags)
end

function igInputInt2(label::Ptr{UInt8},v::Ptr{Cint},extra_flags::ImGuiInputTextFlags)
    ccall((:igInputInt2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},ImGuiInputTextFlags),label,v,extra_flags)
end

function igInputInt3(label::Ptr{UInt8},v::Ptr{Cint},extra_flags::ImGuiInputTextFlags)
    ccall((:igInputInt3,cimgui),bool,(Ptr{UInt8},Ptr{Cint},ImGuiInputTextFlags),label,v,extra_flags)
end

function igInputInt4(label::Ptr{UInt8},v::Ptr{Cint},extra_flags::ImGuiInputTextFlags)
    ccall((:igInputInt4,cimgui),bool,(Ptr{UInt8},Ptr{Cint},ImGuiInputTextFlags),label,v,extra_flags)
end

function igTreeNode(str_label_id::Ptr{UInt8})
    ccall((:igTreeNode,cimgui),bool,(Ptr{UInt8},),str_label_id)
end

function igTreeNodeStrV(str_id::Ptr{UInt8},fmt::Ptr{UInt8},args::va_list)
    ccall((:igTreeNodeStrV,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},va_list),str_id,fmt,args)
end

function igTreeNodePtrV(ptr_id::Ptr{Void},fmt::Ptr{UInt8},args::va_list)
    ccall((:igTreeNodePtrV,cimgui),bool,(Ptr{Void},Ptr{UInt8},va_list),ptr_id,fmt,args)
end

function igTreePushStr(str_id::Ptr{UInt8})
    ccall((:igTreePushStr,cimgui),Void,(Ptr{UInt8},),str_id)
end

function igTreePushPtr(ptr_id::Ptr{Void})
    ccall((:igTreePushPtr,cimgui),Void,(Ptr{Void},),ptr_id)
end

function igTreePop()
    ccall((:igTreePop,cimgui),Void,())
end

function igSetNextTreeNodeOpened(opened::bool,cond::ImGuiSetCond)
    ccall((:igSetNextTreeNodeOpened,cimgui),Void,(bool,ImGuiSetCond),opened,cond)
end

function igSelectable(label::Ptr{UInt8},selected::bool,flags::ImGuiSelectableFlags,size::ImVec2)
    ccall((:igSelectable,cimgui),bool,(Ptr{UInt8},bool,ImGuiSelectableFlags,ImVec2),label,selected,flags,size)
end

function igSelectableEx(label::Ptr{UInt8},p_selected::Ptr{bool},flags::ImGuiSelectableFlags,size::ImVec2)
    ccall((:igSelectableEx,cimgui),bool,(Ptr{UInt8},Ptr{bool},ImGuiSelectableFlags,ImVec2),label,p_selected,flags,size)
end

function igListBox(label::Ptr{UInt8},current_item::Ptr{Cint},items::Ptr{Ptr{UInt8}},items_count::Cint,height_in_items::Cint)
    ccall((:igListBox,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{Ptr{UInt8}},Cint,Cint),label,current_item,items,items_count,height_in_items)
end

function igListBox2(label::Ptr{UInt8},current_item::Ptr{Cint},items_getter::Ptr{Void},data::Ptr{Void},items_count::Cint,height_in_items::Cint)
    ccall((:igListBox2,cimgui),bool,(Ptr{UInt8},Ptr{Cint},Ptr{Void},Ptr{Void},Cint,Cint),label,current_item,items_getter,data,items_count,height_in_items)
end

function igListBoxHeader(label::Ptr{UInt8},size::ImVec2)
    ccall((:igListBoxHeader,cimgui),bool,(Ptr{UInt8},ImVec2),label,size)
end

function igListBoxHeader2(label::Ptr{UInt8},items_count::Cint,height_in_items::Cint)
    ccall((:igListBoxHeader2,cimgui),bool,(Ptr{UInt8},Cint,Cint),label,items_count,height_in_items)
end

function igListBoxFooter()
    ccall((:igListBoxFooter,cimgui),Void,())
end

function igValueBool(prefix::Ptr{UInt8},b::bool)
    ccall((:igValueBool,cimgui),Void,(Ptr{UInt8},bool),prefix,b)
end

function igValueInt(prefix::Ptr{UInt8},v::Cint)
    ccall((:igValueInt,cimgui),Void,(Ptr{UInt8},Cint),prefix,v)
end

function igValueUInt(prefix::Ptr{UInt8},v::UInt32)
    ccall((:igValueUInt,cimgui),Void,(Ptr{UInt8},UInt32),prefix,v)
end

function igValueFloat(prefix::Ptr{UInt8},v::Cfloat,float_format::Ptr{UInt8})
    ccall((:igValueFloat,cimgui),Void,(Ptr{UInt8},Cfloat,Ptr{UInt8}),prefix,v,float_format)
end

function igValueColor(prefix::Ptr{UInt8},v::ImVec4)
    ccall((:igValueColor,cimgui),Void,(Ptr{UInt8},ImVec4),prefix,v)
end

function igValueColor2(prefix::Ptr{UInt8},v::UInt32)
    ccall((:igValueColor2,cimgui),Void,(Ptr{UInt8},UInt32),prefix,v)
end

function igSetTooltipV(fmt::Ptr{UInt8},args::va_list)
    ccall((:igSetTooltipV,cimgui),Void,(Ptr{UInt8},va_list),fmt,args)
end

function igBeginTooltip()
    ccall((:igBeginTooltip,cimgui),Void,())
end

function igEndTooltip()
    ccall((:igEndTooltip,cimgui),Void,())
end

function igBeginMainMenuBar()
    ccall((:igBeginMainMenuBar,cimgui),bool,())
end

function igEndMainMenuBar()
    ccall((:igEndMainMenuBar,cimgui),Void,())
end

function igBeginMenuBar()
    ccall((:igBeginMenuBar,cimgui),bool,())
end

function igEndMenuBar()
    ccall((:igEndMenuBar,cimgui),Void,())
end

function igBeginMenu(label::Ptr{UInt8},enabled::bool)
    ccall((:igBeginMenu,cimgui),bool,(Ptr{UInt8},bool),label,enabled)
end

function igEndMenu()
    ccall((:igEndMenu,cimgui),Void,())
end

function igMenuItem(label::Ptr{UInt8},shortcut::Ptr{UInt8},selected::bool,enabled::bool)
    ccall((:igMenuItem,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},bool,bool),label,shortcut,selected,enabled)
end

function igMenuItemPtr(label::Ptr{UInt8},shortcut::Ptr{UInt8},p_selected::Ptr{bool},enabled::bool)
    ccall((:igMenuItemPtr,cimgui),bool,(Ptr{UInt8},Ptr{UInt8},Ptr{bool},bool),label,shortcut,p_selected,enabled)
end

function igOpenPopup(str_id::Ptr{UInt8})
    ccall((:igOpenPopup,cimgui),Void,(Ptr{UInt8},),str_id)
end

function igBeginPopup(str_id::Ptr{UInt8})
    ccall((:igBeginPopup,cimgui),bool,(Ptr{UInt8},),str_id)
end

function igBeginPopupModal(name::Ptr{UInt8},p_opened::Ptr{bool},extra_flags::ImGuiWindowFlags)
    ccall((:igBeginPopupModal,cimgui),bool,(Ptr{UInt8},Ptr{bool},ImGuiWindowFlags),name,p_opened,extra_flags)
end

function igBeginPopupContextItem(str_id::Ptr{UInt8},mouse_button::Cint)
    ccall((:igBeginPopupContextItem,cimgui),bool,(Ptr{UInt8},Cint),str_id,mouse_button)
end

function igBeginPopupContextWindow(also_over_items::bool,str_id::Ptr{UInt8},mouse_button::Cint)
    ccall((:igBeginPopupContextWindow,cimgui),bool,(bool,Ptr{UInt8},Cint),also_over_items,str_id,mouse_button)
end

function igBeginPopupContextVoid(str_id::Ptr{UInt8},mouse_button::Cint)
    ccall((:igBeginPopupContextVoid,cimgui),bool,(Ptr{UInt8},Cint),str_id,mouse_button)
end

function igEndPopup()
    ccall((:igEndPopup,cimgui),Void,())
end

function igCloseCurrentPopup()
    ccall((:igCloseCurrentPopup,cimgui),Void,())
end

function igLogToTTY(max_depth::Cint)
    ccall((:igLogToTTY,cimgui),Void,(Cint,),max_depth)
end

function igLogToFile(max_depth::Cint,filename::Ptr{UInt8})
    ccall((:igLogToFile,cimgui),Void,(Cint,Ptr{UInt8}),max_depth,filename)
end

function igLogToClipboard(max_depth::Cint)
    ccall((:igLogToClipboard,cimgui),Void,(Cint,),max_depth)
end

function igLogFinish()
    ccall((:igLogFinish,cimgui),Void,())
end

function igLogButtons()
    ccall((:igLogButtons,cimgui),Void,())
end

function igIsItemHovered()
    ccall((:igIsItemHovered,cimgui),bool,())
end

function igIsItemHoveredRect()
    ccall((:igIsItemHoveredRect,cimgui),bool,())
end

function igIsItemActive()
    ccall((:igIsItemActive,cimgui),bool,())
end

function igIsItemVisible()
    ccall((:igIsItemVisible,cimgui),bool,())
end

function igIsAnyItemHovered()
    ccall((:igIsAnyItemHovered,cimgui),bool,())
end

function igIsAnyItemActive()
    ccall((:igIsAnyItemActive,cimgui),bool,())
end

function igGetItemRectMin(pOut::Ptr{ImVec2})
    ccall((:igGetItemRectMin,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetItemRectMax(pOut::Ptr{ImVec2})
    ccall((:igGetItemRectMax,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetItemRectSize(pOut::Ptr{ImVec2})
    ccall((:igGetItemRectSize,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igIsWindowHovered()
    ccall((:igIsWindowHovered,cimgui),bool,())
end

function igIsWindowFocused()
    ccall((:igIsWindowFocused,cimgui),bool,())
end

function igIsRootWindowFocused()
    ccall((:igIsRootWindowFocused,cimgui),bool,())
end

function igIsRootWindowOrAnyChildFocused()
    ccall((:igIsRootWindowOrAnyChildFocused,cimgui),bool,())
end

function igIsRectVisible(item_size::ImVec2)
    ccall((:igIsRectVisible,cimgui),bool,(ImVec2,),item_size)
end

function igIsPosHoveringAnyWindow(pos::ImVec2)
    ccall((:igIsPosHoveringAnyWindow,cimgui),bool,(ImVec2,),pos)
end

function igGetTime()
    ccall((:igGetTime,cimgui),Cfloat,())
end

function igGetFrameCount()
    ccall((:igGetFrameCount,cimgui),Cint,())
end

function igGetStyleColName(idx::ImGuiCol)
    ccall((:igGetStyleColName,cimgui),Ptr{UInt8},(ImGuiCol,),idx)
end

function igCalcItemRectClosestPoint(pOut::Ptr{ImVec2},pos::ImVec2,on_edge::bool,outward::Cfloat)
    ccall((:igCalcItemRectClosestPoint,cimgui),Void,(Ptr{ImVec2},ImVec2,bool,Cfloat),pOut,pos,on_edge,outward)
end

function igCalcTextSize(pOut::Ptr{ImVec2},text::Ptr{UInt8},text_end::Ptr{UInt8},hide_text_after_double_hash::bool,wrap_width::Cfloat)
    ccall((:igCalcTextSize,cimgui),Void,(Ptr{ImVec2},Ptr{UInt8},Ptr{UInt8},bool,Cfloat),pOut,text,text_end,hide_text_after_double_hash,wrap_width)
end

function igCalcListClipping(items_count::Cint,items_height::Cfloat,out_items_display_start::Ptr{Cint},out_items_display_end::Ptr{Cint})
    ccall((:igCalcListClipping,cimgui),Void,(Cint,Cfloat,Ptr{Cint},Ptr{Cint}),items_count,items_height,out_items_display_start,out_items_display_end)
end

function igBeginChildFrame(id::ImGuiID,size::ImVec2,extra_flags::ImGuiWindowFlags)
    ccall((:igBeginChildFrame,cimgui),bool,(ImGuiID,ImVec2,ImGuiWindowFlags),id,size,extra_flags)
end

function igEndChildFrame()
    ccall((:igEndChildFrame,cimgui),Void,())
end

function igColorConvertU32ToFloat4(pOut::Ptr{ImVec4},_in::ImU32)
    ccall((:igColorConvertU32ToFloat4,cimgui),Void,(Ptr{ImVec4},ImU32),pOut,_in)
end

function igColorConvertFloat4ToU32(_in::ImVec4)
    ccall((:igColorConvertFloat4ToU32,cimgui),ImU32,(ImVec4,),_in)
end

function igColorConvertRGBtoHSV(r::Cfloat,g::Cfloat,b::Cfloat,out_h::Ptr{Cfloat},out_s::Ptr{Cfloat},out_v::Ptr{Cfloat})
    ccall((:igColorConvertRGBtoHSV,cimgui),Void,(Cfloat,Cfloat,Cfloat,Ptr{Cfloat},Ptr{Cfloat},Ptr{Cfloat}),r,g,b,out_h,out_s,out_v)
end

function igColorConvertHSVtoRGB(h::Cfloat,s::Cfloat,v::Cfloat,out_r::Ptr{Cfloat},out_g::Ptr{Cfloat},out_b::Ptr{Cfloat})
    ccall((:igColorConvertHSVtoRGB,cimgui),Void,(Cfloat,Cfloat,Cfloat,Ptr{Cfloat},Ptr{Cfloat},Ptr{Cfloat}),h,s,v,out_r,out_g,out_b)
end

function igGetKeyIndex(key::ImGuiKey)
    ccall((:igGetKeyIndex,cimgui),Cint,(ImGuiKey,),key)
end

function igIsKeyDown(key_index::Cint)
    ccall((:igIsKeyDown,cimgui),bool,(Cint,),key_index)
end

function igIsKeyPressed(key_index::Cint,repeat::bool)
    ccall((:igIsKeyPressed,cimgui),bool,(Cint,bool),key_index,repeat)
end

function igIsKeyReleased(key_index::Cint)
    ccall((:igIsKeyReleased,cimgui),bool,(Cint,),key_index)
end

function igIsMouseDown(button::Cint)
    ccall((:igIsMouseDown,cimgui),bool,(Cint,),button)
end

function igIsMouseClicked(button::Cint,repeat::bool)
    ccall((:igIsMouseClicked,cimgui),bool,(Cint,bool),button,repeat)
end

function igIsMouseDoubleClicked(button::Cint)
    ccall((:igIsMouseDoubleClicked,cimgui),bool,(Cint,),button)
end

function igIsMouseReleased(button::Cint)
    ccall((:igIsMouseReleased,cimgui),bool,(Cint,),button)
end

function igIsMouseHoveringWindow()
    ccall((:igIsMouseHoveringWindow,cimgui),bool,())
end

function igIsMouseHoveringAnyWindow()
    ccall((:igIsMouseHoveringAnyWindow,cimgui),bool,())
end

function igIsMouseHoveringRect(pos_min::ImVec2,pos_max::ImVec2,clip::bool)
    ccall((:igIsMouseHoveringRect,cimgui),bool,(ImVec2,ImVec2,bool),pos_min,pos_max,clip)
end

function igIsMouseDragging(button::Cint,lock_threshold::Cfloat)
    ccall((:igIsMouseDragging,cimgui),bool,(Cint,Cfloat),button,lock_threshold)
end

function igGetMousePos(pOut::Ptr{ImVec2})
    ccall((:igGetMousePos,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetMousePosOnOpeningCurrentPopup(pOut::Ptr{ImVec2})
    ccall((:igGetMousePosOnOpeningCurrentPopup,cimgui),Void,(Ptr{ImVec2},),pOut)
end

function igGetMouseDragDelta(pOut::Ptr{ImVec2},button::Cint,lock_threshold::Cfloat)
    ccall((:igGetMouseDragDelta,cimgui),Void,(Ptr{ImVec2},Cint,Cfloat),pOut,button,lock_threshold)
end

function igResetMouseDragDelta(button::Cint)
    ccall((:igResetMouseDragDelta,cimgui),Void,(Cint,),button)
end

function igGetMouseCursor()
    ccall((:igGetMouseCursor,cimgui),ImGuiMouseCursor,())
end

function igSetMouseCursor(_type::ImGuiMouseCursor)
    ccall((:igSetMouseCursor,cimgui),Void,(ImGuiMouseCursor,),_type)
end

function igCaptureKeyboardFromApp()
    ccall((:igCaptureKeyboardFromApp,cimgui),Void,())
end

function igCaptureMouseFromApp()
    ccall((:igCaptureMouseFromApp,cimgui),Void,())
end

function igMemAlloc(sz::Csize_t)
    ccall((:igMemAlloc,cimgui),Ptr{Void},(Csize_t,),sz)
end

function igMemFree(ptr::Ptr{Void})
    ccall((:igMemFree,cimgui),Void,(Ptr{Void},),ptr)
end

function igGetClipboardText()
    ccall((:igGetClipboardText,cimgui),Ptr{UInt8},())
end

function igSetClipboardText(text::Ptr{UInt8})
    ccall((:igSetClipboardText,cimgui),Void,(Ptr{UInt8},),text)
end

function igGetVersion()
    ccall((:igGetVersion,cimgui),Ptr{UInt8},())
end

function igGetInternalState()
    ccall((:igGetInternalState,cimgui),Ptr{Void},())
end

function igGetInternalStateSize()
    ccall((:igGetInternalStateSize,cimgui),Csize_t,())
end

function igSetInternalState(state::Ptr{Void},construct::bool)
    ccall((:igSetInternalState,cimgui),Void,(Ptr{Void},bool),state,construct)
end

function ImFontAtlas_GetTexDataAsRGBA32(atlas::Ptr{ImFontAtlas},out_pixels::Ptr{Ptr{Cuchar}},out_width::Ptr{Cint},out_height::Ptr{Cint},out_bytes_per_pixel::Ptr{Cint})
    ccall((:ImFontAtlas_GetTexDataAsRGBA32,cimgui),Void,(Ptr{ImFontAtlas},Ptr{Ptr{Cuchar}},Ptr{Cint},Ptr{Cint},Ptr{Cint}),atlas,out_pixels,out_width,out_height,out_bytes_per_pixel)
end

function ImFontAtlas_GetTexDataAsAlpha8(atlas::Ptr{ImFontAtlas},out_pixels::Ptr{Ptr{Cuchar}},out_width::Ptr{Cint},out_height::Ptr{Cint},out_bytes_per_pixel::Ptr{Cint})
    ccall((:ImFontAtlas_GetTexDataAsAlpha8,cimgui),Void,(Ptr{ImFontAtlas},Ptr{Ptr{Cuchar}},Ptr{Cint},Ptr{Cint},Ptr{Cint}),atlas,out_pixels,out_width,out_height,out_bytes_per_pixel)
end

function ImFontAtlas_SetTexID(atlas::Ptr{ImFontAtlas},tex::Ptr{Void})
    ccall((:ImFontAtlas_SetTexID,cimgui),Void,(Ptr{ImFontAtlas},Ptr{Void}),atlas,tex)
end

function ImFontAtlas_AddFont(atlas::Ptr{ImFontAtlas},font_cfg::Ptr{ImFontConfig})
    ccall((:ImFontAtlas_AddFont,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{ImFontConfig}),atlas,font_cfg)
end

function ImFontAtlas_AddFontDefault(atlas::Ptr{ImFontAtlas},font_cfg::Ptr{ImFontConfig})
    ccall((:ImFontAtlas_AddFontDefault,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{ImFontConfig}),atlas,font_cfg)
end

function ImFontAtlas_AddFontFromFileTTF(atlas::Ptr{ImFontAtlas},filename::Ptr{UInt8},size_pixels::Cfloat,font_cfg::Ptr{ImFontConfig},glyph_ranges::Ptr{ImWchar})
    ccall((:ImFontAtlas_AddFontFromFileTTF,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{UInt8},Cfloat,Ptr{ImFontConfig},Ptr{ImWchar}),atlas,filename,size_pixels,font_cfg,glyph_ranges)
end

function ImFontAtlas_AddFontFromMemoryTTF(atlas::Ptr{ImFontAtlas},ttf_data::Ptr{Void},ttf_size::Cint,size_pixels::Cfloat,font_cfg::Ptr{ImFontConfig},glyph_ranges::Ptr{ImWchar})
    ccall((:ImFontAtlas_AddFontFromMemoryTTF,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{Void},Cint,Cfloat,Ptr{ImFontConfig},Ptr{ImWchar}),atlas,ttf_data,ttf_size,size_pixels,font_cfg,glyph_ranges)
end

function ImFontAtlas_AddFontFromMemoryCompressedTTF(atlas::Ptr{ImFontAtlas},compressed_ttf_data::Ptr{Void},compressed_ttf_size::Cint,size_pixels::Cfloat,font_cfg::Ptr{ImFontConfig},glyph_ranges::Ptr{ImWchar})
    ccall((:ImFontAtlas_AddFontFromMemoryCompressedTTF,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{Void},Cint,Cfloat,Ptr{ImFontConfig},Ptr{ImWchar}),atlas,compressed_ttf_data,compressed_ttf_size,size_pixels,font_cfg,glyph_ranges)
end

function ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(atlas::Ptr{ImFontAtlas},compressed_ttf_data_base85::Ptr{UInt8},size_pixels::Cfloat,font_cfg::Ptr{ImFontConfig},glyph_ranges::Ptr{ImWchar})
    ccall((:ImFontAtlas_AddFontFromMemoryCompressedBase85TTF,cimgui),Ptr{ImFont},(Ptr{ImFontAtlas},Ptr{UInt8},Cfloat,Ptr{ImFontConfig},Ptr{ImWchar}),atlas,compressed_ttf_data_base85,size_pixels,font_cfg,glyph_ranges)
end

function ImFontAtlas_ClearTexData(atlas::Ptr{ImFontAtlas})
    ccall((:ImFontAtlas_ClearTexData,cimgui),Void,(Ptr{ImFontAtlas},),atlas)
end

function ImFontAtlas_Clear(atlas::Ptr{ImFontAtlas})
    ccall((:ImFontAtlas_Clear,cimgui),Void,(Ptr{ImFontAtlas},),atlas)
end

function ImGuiIO_AddInputCharacter(c::UInt16)
    ccall((:ImGuiIO_AddInputCharacter,cimgui),Void,(UInt16,),c)
end

function ImGuiIO_AddInputCharactersUTF8(utf8_chars::Ptr{UInt8})
    ccall((:ImGuiIO_AddInputCharactersUTF8,cimgui),Void,(Ptr{UInt8},),utf8_chars)
end

function ImGuiIO_ClearInputCharacters()
    ccall((:ImGuiIO_ClearInputCharacters,cimgui),Void,())
end

function ImDrawData_DeIndexAllBuffers(drawData::Ptr{ImDrawData})
    ccall((:ImDrawData_DeIndexAllBuffers,cimgui),Void,(Ptr{ImDrawData},),drawData)
end

function ImDrawList_GetVertexBufferSize(list::Ptr{ImDrawList})
    ccall((:ImDrawList_GetVertexBufferSize,cimgui),Cint,(Ptr{ImDrawList},),list)
end

function ImDrawList_GetVertexPtr(list::Ptr{ImDrawList},n::Cint)
    ccall((:ImDrawList_GetVertexPtr,cimgui),Ptr{ImDrawVert},(Ptr{ImDrawList},Cint),list,n)
end

function ImDrawList_GetIndexBufferSize(list::Ptr{ImDrawList})
    ccall((:ImDrawList_GetIndexBufferSize,cimgui),Cint,(Ptr{ImDrawList},),list)
end

function ImDrawList_GetIndexPtr(list::Ptr{ImDrawList},n::Cint)
    ccall((:ImDrawList_GetIndexPtr,cimgui),Ptr{ImDrawIdx},(Ptr{ImDrawList},Cint),list,n)
end

function ImDrawList_GetCmdSize(list::Ptr{ImDrawList})
    ccall((:ImDrawList_GetCmdSize,cimgui),Cint,(Ptr{ImDrawList},),list)
end

function ImDrawList_GetCmdPtr(list::Ptr{ImDrawList},n::Cint)
    ccall((:ImDrawList_GetCmdPtr,cimgui),Ptr{ImDrawCmd},(Ptr{ImDrawList},Cint),list,n)
end

function ImDrawList_Clear(list::Ptr{ImDrawList})
    ccall((:ImDrawList_Clear,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_ClearFreeMemory(list::Ptr{ImDrawList})
    ccall((:ImDrawList_ClearFreeMemory,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_PushClipRect(list::Ptr{ImDrawList},clip_rect::ImVec4)
    ccall((:ImDrawList_PushClipRect,cimgui),Void,(Ptr{ImDrawList},ImVec4),list,clip_rect)
end

function ImDrawList_PushClipRectFullScreen(list::Ptr{ImDrawList})
    ccall((:ImDrawList_PushClipRectFullScreen,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_PopClipRect(list::Ptr{ImDrawList})
    ccall((:ImDrawList_PopClipRect,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_PushTextureID(list::Ptr{ImDrawList},texture_id::ImTextureID)
    ccall((:ImDrawList_PushTextureID,cimgui),Void,(Ptr{ImDrawList},ImTextureID),list,texture_id)
end

function ImDrawList_PopTextureID(list::Ptr{ImDrawList})
    ccall((:ImDrawList_PopTextureID,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_AddLine(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,col::ImU32,thickness::Cfloat)
    ccall((:ImDrawList_AddLine,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32,Cfloat),list,a,b,col,thickness)
end

function ImDrawList_AddRect(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,col::ImU32,rounding::Cfloat,rounding_corners::Cint)
    ccall((:ImDrawList_AddRect,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32,Cfloat,Cint),list,a,b,col,rounding,rounding_corners)
end

function ImDrawList_AddRectFilled(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,col::ImU32,rounding::Cfloat,rounding_corners::Cint)
    ccall((:ImDrawList_AddRectFilled,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32,Cfloat,Cint),list,a,b,col,rounding,rounding_corners)
end

function ImDrawList_AddRectFilledMultiColor(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,col_upr_left::ImU32,col_upr_right::ImU32,col_bot_right::ImU32,col_bot_left::ImU32)
    ccall((:ImDrawList_AddRectFilledMultiColor,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32,ImU32,ImU32,ImU32),list,a,b,col_upr_left,col_upr_right,col_bot_right,col_bot_left)
end

function ImDrawList_AddTriangleFilled(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,c::ImVec2,col::ImU32)
    ccall((:ImDrawList_AddTriangleFilled,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImVec2,ImU32),list,a,b,c,col)
end

function ImDrawList_AddCircle(list::Ptr{ImDrawList},centre::ImVec2,radius::Cfloat,col::ImU32,num_segments::Cint)
    ccall((:ImDrawList_AddCircle,cimgui),Void,(Ptr{ImDrawList},ImVec2,Cfloat,ImU32,Cint),list,centre,radius,col,num_segments)
end

function ImDrawList_AddCircleFilled(list::Ptr{ImDrawList},centre::ImVec2,radius::Cfloat,col::ImU32,num_segments::Cint)
    ccall((:ImDrawList_AddCircleFilled,cimgui),Void,(Ptr{ImDrawList},ImVec2,Cfloat,ImU32,Cint),list,centre,radius,col,num_segments)
end

function ImDrawList_AddText(list::Ptr{ImDrawList},pos::ImVec2,col::ImU32,text_begin::Ptr{UInt8},text_end::Ptr{UInt8})
    ccall((:ImDrawList_AddText,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImU32,Ptr{UInt8},Ptr{UInt8}),list,pos,col,text_begin,text_end)
end

function ImDrawList_AddTextExt(list::Ptr{ImDrawList},font::Ptr{ImFont},font_size::Cfloat,pos::ImVec2,col::ImU32,text_begin::Ptr{UInt8},text_end::Ptr{UInt8},wrap_width::Cfloat,cpu_fine_clip_rect::Ptr{ImVec4})
    ccall((:ImDrawList_AddTextExt,cimgui),Void,(Ptr{ImDrawList},Ptr{ImFont},Cfloat,ImVec2,ImU32,Ptr{UInt8},Ptr{UInt8},Cfloat,Ptr{ImVec4}),list,font,font_size,pos,col,text_begin,text_end,wrap_width,cpu_fine_clip_rect)
end

function ImDrawList_AddImage(list::Ptr{ImDrawList},user_texture_id::ImTextureID,a::ImVec2,b::ImVec2,uv0::ImVec2,uv1::ImVec2,col::ImU32)
    ccall((:ImDrawList_AddImage,cimgui),Void,(Ptr{ImDrawList},ImTextureID,ImVec2,ImVec2,ImVec2,ImVec2,ImU32),list,user_texture_id,a,b,uv0,uv1,col)
end

function ImDrawList_AddPolyline(list::Ptr{ImDrawList},points::Ptr{ImVec2},num_points::Cint,col::ImU32,closed::bool,thickness::Cfloat,anti_aliased::bool)
    ccall((:ImDrawList_AddPolyline,cimgui),Void,(Ptr{ImDrawList},Ptr{ImVec2},Cint,ImU32,bool,Cfloat,bool),list,points,num_points,col,closed,thickness,anti_aliased)
end

function ImDrawList_AddConvexPolyFilled(list::Ptr{ImDrawList},points::Ptr{ImVec2},num_points::Cint,col::ImU32,anti_aliased::bool)
    ccall((:ImDrawList_AddConvexPolyFilled,cimgui),Void,(Ptr{ImDrawList},Ptr{ImVec2},Cint,ImU32,bool),list,points,num_points,col,anti_aliased)
end

function ImDrawList_AddBezierCurve(list::Ptr{ImDrawList},pos0::ImVec2,cp0::ImVec2,cp1::ImVec2,pos1::ImVec2,col::ImU32,thickness::Cfloat,num_segments::Cint)
    ccall((:ImDrawList_AddBezierCurve,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImVec2,ImVec2,ImU32,Cfloat,Cint),list,pos0,cp0,cp1,pos1,col,thickness,num_segments)
end

function ImDrawList_PathClear(list::Ptr{ImDrawList})
    ccall((:ImDrawList_PathClear,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_PathLineTo(list::Ptr{ImDrawList},pos::ImVec2)
    ccall((:ImDrawList_PathLineTo,cimgui),Void,(Ptr{ImDrawList},ImVec2),list,pos)
end

function ImDrawList_PathLineToMergeDuplicate(list::Ptr{ImDrawList},pos::ImVec2)
    ccall((:ImDrawList_PathLineToMergeDuplicate,cimgui),Void,(Ptr{ImDrawList},ImVec2),list,pos)
end

function ImDrawList_PathFill(list::Ptr{ImDrawList},col::ImU32)
    ccall((:ImDrawList_PathFill,cimgui),Void,(Ptr{ImDrawList},ImU32),list,col)
end

function ImDrawList_PathStroke(list::Ptr{ImDrawList},col::ImU32,closed::bool,thickness::Cfloat)
    ccall((:ImDrawList_PathStroke,cimgui),Void,(Ptr{ImDrawList},ImU32,bool,Cfloat),list,col,closed,thickness)
end

function ImDrawList_PathArcTo(list::Ptr{ImDrawList},centre::ImVec2,radius::Cfloat,a_min::Cfloat,a_max::Cfloat,num_segments::Cint)
    ccall((:ImDrawList_PathArcTo,cimgui),Void,(Ptr{ImDrawList},ImVec2,Cfloat,Cfloat,Cfloat,Cint),list,centre,radius,a_min,a_max,num_segments)
end

function ImDrawList_PathArcToFast(list::Ptr{ImDrawList},centre::ImVec2,radius::Cfloat,a_min_of_12::Cint,a_max_of_12::Cint)
    ccall((:ImDrawList_PathArcToFast,cimgui),Void,(Ptr{ImDrawList},ImVec2,Cfloat,Cint,Cint),list,centre,radius,a_min_of_12,a_max_of_12)
end

function ImDrawList_PathBezierCurveTo(list::Ptr{ImDrawList},p1::ImVec2,p2::ImVec2,p3::ImVec2,num_segments::Cint)
    ccall((:ImDrawList_PathBezierCurveTo,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImVec2,Cint),list,p1,p2,p3,num_segments)
end

function ImDrawList_PathRect(list::Ptr{ImDrawList},rect_min::ImVec2,rect_max::ImVec2,rounding::Cfloat,rounding_corners::Cint)
    ccall((:ImDrawList_PathRect,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,Cfloat,Cint),list,rect_min,rect_max,rounding,rounding_corners)
end

function ImDrawList_ChannelsSplit(list::Ptr{ImDrawList},channels_count::Cint)
    ccall((:ImDrawList_ChannelsSplit,cimgui),Void,(Ptr{ImDrawList},Cint),list,channels_count)
end

function ImDrawList_ChannelsMerge(list::Ptr{ImDrawList})
    ccall((:ImDrawList_ChannelsMerge,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_ChannelsSetCurrent(list::Ptr{ImDrawList},channel_index::Cint)
    ccall((:ImDrawList_ChannelsSetCurrent,cimgui),Void,(Ptr{ImDrawList},Cint),list,channel_index)
end

function ImDrawList_AddCallback(list::Ptr{ImDrawList},callback::ImDrawCallback,callback_data::Ptr{Void})
    ccall((:ImDrawList_AddCallback,cimgui),Void,(Ptr{ImDrawList},ImDrawCallback,Ptr{Void}),list,callback,callback_data)
end

function ImDrawList_AddDrawCmd(list::Ptr{ImDrawList})
    ccall((:ImDrawList_AddDrawCmd,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_PrimReserve(list::Ptr{ImDrawList},idx_count::Cint,vtx_count::Cint)
    ccall((:ImDrawList_PrimReserve,cimgui),Void,(Ptr{ImDrawList},Cint,Cint),list,idx_count,vtx_count)
end

function ImDrawList_PrimRect(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,col::ImU32)
    ccall((:ImDrawList_PrimRect,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32),list,a,b,col)
end

function ImDrawList_PrimRectUV(list::Ptr{ImDrawList},a::ImVec2,b::ImVec2,uv_a::ImVec2,uv_b::ImVec2,col::ImU32)
    ccall((:ImDrawList_PrimRectUV,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImVec2,ImVec2,ImU32),list,a,b,uv_a,uv_b,col)
end

function ImDrawList_PrimVtx(list::Ptr{ImDrawList},pos::ImVec2,uv::ImVec2,col::ImU32)
    ccall((:ImDrawList_PrimVtx,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32),list,pos,uv,col)
end

function ImDrawList_PrimWriteVtx(list::Ptr{ImDrawList},pos::ImVec2,uv::ImVec2,col::ImU32)
    ccall((:ImDrawList_PrimWriteVtx,cimgui),Void,(Ptr{ImDrawList},ImVec2,ImVec2,ImU32),list,pos,uv,col)
end

function ImDrawList_PrimWriteIdx(list::Ptr{ImDrawList},idx::ImDrawIdx)
    ccall((:ImDrawList_PrimWriteIdx,cimgui),Void,(Ptr{ImDrawList},ImDrawIdx),list,idx)
end

function ImDrawList_UpdateClipRect(list::Ptr{ImDrawList})
    ccall((:ImDrawList_UpdateClipRect,cimgui),Void,(Ptr{ImDrawList},),list)
end

function ImDrawList_UpdateTextureID(list::Ptr{ImDrawList})
    ccall((:ImDrawList_UpdateTextureID,cimgui),Void,(Ptr{ImDrawList},),list)
end

function setRenderCallback(rc::Function)
    const rrc = cfunction(rc, Void, ())
    ccall((:setRenderCallback,cimgui),Void,(Ptr{Void},),rrc)
end

function setupAll()
    ccall((:setupAll,cimgui),bool,())
end

function mainLoop()
    ccall((:mainLoop,cimgui),Void,())
end

function destroyAll()
    ccall((:destroyAll,cimgui),Void,())
end


text:
using MarginalLogDensities
using Distributions
using StatsPlots
using Random
using Optim
using BenchmarkTools

Random.seed!(1234)
ncategories = 8
categories = 1:ncategories
μ0 = 5.0
σ0 = 5.0
aa = rand(Normal(μ0, σ0), ncategories)
b = 4.5
σ = 0.5
const category = repeat(categories, inner=50)
const n = length(category)
const x = rand(Uniform(-1, 1), n)
μ = [aa[category[i]] + b * x[i] for i in 1:n]
const y = rand.(Normal.(μ, σ))

scatter(x, y, color=category, label="")

function loglik(θ::Vector{T}) where T
    μ0 = θ[1]
    σ0 = exp(θ[2])
    aa = θ[3:10]
    b = θ[11]
    σ = exp(θ[12])
    μ = [aa[category[i]] + b * x[i] for i in 1:n]
    return loglikelihood(Normal(μ0, σ0), aa) + sum(logpdf.(Normal.(μ, σ), y))
end

θtrue = [μ0; log(σ0); aa; b; log(σ)]
nθ = length(θtrue)
loglik(θtrue)
θmarg = θtrue[[1, 2, 11, 12]]

mld = MarginalLogDensity(loglik, nθ, collect(3:10))
@btime mld($aa, $θmarg) # 5.3 μs
@btime mld($θmarg) # 115 μs
@profiler for i in 1:5000
    mld([μ0, log(σ0), b, log(σ)])
end

opt = optimize(θjoint -> -mld(θjoint), ones(4))
μ0_opt, logσ0_opt, b_opt, logσ_opt = opt.minimizer

                    # should be:
μ0_opt              # 5.0
exp(logσ0_opt)      # 5.0
b_opt               # 4.5
exp(logσ_opt)       # 0.5

θ_opt = [μ0_opt, exp(logσ0_opt), b_opt, exp(logσ_opt)]

using FiniteDiff, LinearAlgebra
H = FiniteDiff.finite_difference_hessian(θjoint -> -mld(θjoint), opt.minimizer)
std_errors = 1 ./ sqrt.(diag(H))

θ_names = ["μ₀", "σ₀", "b", "σ"]
scatter(θ_names, θ_opt, yerror=2*std_errors, label="Estimate",
    xlabel="Parameter", ylabel="Value")
scatter!(θ_names, [μ0, σ0, b, σ], label="Truth")

ext: jl


text:
# This file is part of the IntervalArithmetic.jl package; MIT licensed

isempty(x::ValidInterval) = false
isempty(x::EmptyInterval) = true

isnai(::ValidInterval) = false
isnai(::NotAnInterval) = true

isentire(x::ValidInterval) = x == entireinterval(x)

isbounded(x::Interval) = isfinite(x.lo) && isfinite(x.hi)
isunbounded(x::Interval) = !isbounded(x)

"""
    isthin(x)

Checks if `x` is the set consisting of a single exactly
representable float. Any float which is not exactly representable
does *not* yield a thin interval. Corresponds to `isSingleton` of
the standard.
"""
isthin(x::Interval) = x.lo == x.hi

"""
    isatomic(x::Interval)

Check whether an interval `x` is *atomic*, i.e. is unable to be split.
This occurs when the interval is empty, or when the upper bound equals the lower bound or the `nextfloat` of the lower bound.
"""
isatomic(x::Interval) = (x.hi == x.lo) || (x.hi == nextfloat(x.lo))

iscommon(x::Interval) = isbounded(x)

for f in (:isentire, :isbounded, :isunbounded, :isthin, :isatomic, :iscommon)
    @eval ($f)(::EmptyInterval) = false
end

## Comparisons

"""
    ==(a,b)

Checks if the intervals `a` and `b` have equal bounds.
"""
==(a::Interval, b::Interval) = a.lo == b.lo && a.hi == b.hi
==(::EmptyInterval, ::EmptyInterval) = true
==(::ValidInterval, ::ValidInterval) = false

# Weakly less, \le, <=
<=(a::Interval, b::Interval) = (a.lo ≤ b.lo) && (a.hi ≤ b.hi)
<=(::EmptyInterval, ::EmptyInterval) = true
<=(::ValidInterval, ::ValidInterval) = false

# Auxiliary function: equivalent to </<=, but Inf <,<= Inf returning true
islessprime(a::T, b::T) where T <: Real = a < b ||
    ( a == b && (isinf(a) || isinf(b)) )

# Strict less: <
<(a::Interval, b::Interval) =
    islessprime(a.lo, b.lo) && islessprime(a.hi, b.hi)
<(::EmptyInterval, ::EmptyInterval) = true
<(::ValidInterval, ::ValidInterval) = false

function precedes end
const ≼ = precedes # \preccurlyeq
≼(a::Interval, b::Interval) = a.hi ≤ b.lo
≼(::ValidInterval, ::ValidInterval) = true

function strictprecedes end
const ≺ = strictprecedes # \prec
≺(a::Interval, b::Interval) = a.hi < b.lo
≺(::ValidInterval, ::ValidInterval) = true

"""
    in(x, a)
    ∈(x, a)

Checks if the number `x` is a member of the interval `a`, treated as a set.
Corresponds to `isMember` in the ITF-1788 Standard.
"""
in(x::Real, a::Interval) = isfinite(x) && a.lo <= x <= a.hi
in(::Real, ::EmptyInterval) = false

"""
    issubset(a,b)
    ⊆(a,b)

Checks if all the points of the interval `a` are within the interval `b`.
"""
⊆(a::Interval, b::Interval) = b.lo ≤ a.lo && a.hi ≤ b.hi
⊆(::Interval, ::EmptyInterval) = false
⊆(::EmptyInterval, ::ValidInterval) = true

zero_in(a::ValidInterval) = zero(a) ⊆ a

⊂(a::ValidInterval, b::ValidInterval) = a ⊆ b && a ≠ b

⊇(a::ValidInterval, b::ValidInterval) = b ⊆ a

⊃(a::ValidInterval, b::ValidInterval) = b ⊂ a

function isinterior end
const ⪽ = isinterior  # \subsetdot
⪽(a::Interval, b::Interval) = islessprime(b.lo, a.lo) && islessprime(a.hi, b.hi)
⪽(::Interval, ::EmptyInterval) = false
⪽(::EmptyInterval, ::ValidInterval) = true

# for zero we can avoid islessprime
contains_zero(a::Interval{T}) where T = a.lo < zero(T) < a.hi
contains_zero(::EmptyInterval) = false

# Disjoint:
isdisjoint(a::Interval, b::Interval) =
    islessprime(b.hi, a.lo) || islessprime(a.hi, b.lo)
isdisjoint(::ValidInterval, ::ValidInterval) = true


text:
#!/bin/bash
# -*- mode: julia -*-
#=
exec julia --color=yes --startup-file=no -e "include(popfirst!(ARGS))" "${BASH_SOURCE[0]}" "$@"
=#

# dicom2nifti.jl
# Simple DICOM to NIfTI converter

# This script walks through the current working directory looking for DICOM
# files and sorts them into volumes. It then creates directories corresponding
# to each protocol, and saves nii files named by series number. It has
# (barely) been tested with DICOM files from a Siemens scanner. It may not
# work with other scanners. It may give incorrect information. Test thoroughly
# and use at your own risk.

using DICOM, NIfTI, ArgParse, LinearAlgebra

function parse_commandline()
    s = ArgParseSettings()
    s.description = "DICOM to NIfTI converter"

    @add_arg_table s begin
        "--extension"
            help = "assume files with given extension are DICOM files. Set to blank for no extension."
            default = ".dcm"
        "--sphinx"
            help = "correct for sphinx position (for monkeys)"
            action = :store_true
        "--axes"
            help = """orientation of tensor in the resulting volume. This is a three-character label
            that determines how the data is stored, and how it is displayed in applications that do
            not make use of the orientation matrix in the NIfTI header. Valid characters are:
            L (= left), R (= right), A (= anterior), P (= posterior), I (= inferior), and
            S (= superior). If not specified, the orientation in the DICOM file is preserved."""
            default = nothing
        "dicomdir"
            help = "directory of DICOM files"
            required = true
        "niftidir"
            help = "directory in which to put NIfTI files"
            required = true
    end

    parse_args(s)
end

function main()
    cmd = parse_commandline()

    if cmd["axes"] == nothing
        axes = nothing
    else
        axes = uppercase(cmd["axes"])
        if length(axes) != 3 || (!('R' in axes) && !('L' in axes)) ||
                (!('A' in axes) && !('P' in axes)) ||
                (!('S' in axes) && !('I' in axes))
            error("Invalid axes provided")
        end
    end

    transform = cmd["sphinx"] ? [1 0 0; 0 0 1; 0 -1 0] : [-1 0 0; 0 -1 0; 0 0 1]

    # Load all DICOMs into an array, indexed by series number
    dicoms = Dict{Int, Any}()
    for (root, dirs, files) in walkdir(cmd["dicomdir"])
        for file in files
            fpath = joinpath(root, file)
            if !endswith(fpath, cmd["extension"])
                return
            end

            local d
            println(fpath)
            d = DICOM.dcm_parse(fpath)

            if !(tag"Series Number" in keys(d))
                println("No series number found for $fpath; ignoring")
                return
            end
            series_number = d[tag"Series Number"]

            dicom_arr = get(dicoms, series_number, nothing)
            if dicom_arr == nothing
                dicoms[series_number] = dicom_arr = []
            end
            push!(dicom_arr, d)
        end
    end

    # Sort DICOMs
    for (series_number, slices) in dicoms
        d = slices[1]

        protocol_name = d[tag"Protocol Name"]
        orientation = d[tag"Image Orientation (Patient)"]
        pixel_spacing = d[tag"Pixel Spacing"]
        slice_spacing = slice_thickness = d[tag"Slice Thickness"]
        if tag"Spacing Between Slices" in keys(d)
            slice_spacing = d[tag"Spacing Between Slices"]
        end
        time_step = false
        if tag"Repetition Time" in keys(d)
            time_step = d[tag"Repetition Time"] # This is the TR, but may not be the time step
        end
        phase_encoding_direction = d[tag"In-plane Phase Encoding Direction"]
        pixel_rows = d[tag"Rows"]
        pixel_cols = d[tag"Columns"]

        # Convert orientation to RAS
        orientation = transform*reshape(orientation, (3, 2))

        # Determine Z as cross product of X and Y
        orientation = hcat(orientation, cross(orientation[:, 1], orientation[:, 2]))

        # Scale by pixel size
        orientation = orientation*[pixel_spacing[1] 0 0; 0 pixel_spacing[2] 0; 0 0 slice_spacing]

        # Find Z coordinates of each slice
        image_positions = transform * hcat([d[tag"Image Position (Patient)"] for d in slices]...)
        z_coords = [dot(image_positions[:, i], orientation[:, 3])
            for i = 1:size(image_positions, 2)]

        # Sort Z coordinates
        p = sortperm(z_coords)

        # Concatenate slices along Z axis according to increasing Z coordinate
        raw = cat([slices[i][tag"Pixel Data"] for i in p]..., dims = 3)

        orientation = hcat(orientation, image_positions[:, p[1]])

        dim_info = phase_encoding_direction == "ROW" ? (1, 2, 3) :
                phase_encoding_direction == "COL" ? (2, 1, 3) :
                (0, 0, 0)

        voxel_size = tuple(pixel_spacing..., slice_spacing)

        # Permute according to axes specified on command line
        if axes != nothing
            # Determine permutation of current volume to RAS
            ras = Array{Int,1}(undef, 3)
            sign = Array{Bool,1}(undef, 3)
            rg = [1:3;]
            abs_orientation = abs.(orientation)
            for i = 1:3
                idx = findmax(abs_orientation[i, rg])[2]
                ras[i] = splice!(rg, idx)
                sign[i] = orientation[i, ras[i]] >= 0
            end

            # Determine permutation of RAS to user-preferred orientation
            specified_axes = Int[(c in "RL" ? 1 :
                                  c in "AP" ? 2 : 3)
                                 for c in axes]
            specified_sign = Bool[c in "RAS" for c in axes]
            output_axes = ras[specified_axes]

            # Permute
            raw = permutedims(raw, output_axes)
            orientation[:, 1:3] = orientation[:, output_axes]
            voxel_size = voxel_size[output_axes]
            dim_info = dim_info[output_axes]

            # Flip signs and dimensions
            flip_sign = findall(sign[specified_axes] .!= specified_sign)
            orientation[:, flip_sign] = -orientation[:, flip_sign]
            for dim in flip_sign
                raw = reverse(raw, dims=dim)
                orientation[dim, 4] += (sign[specified_axes[dim]] ? 1 : -1) *
                    (size(raw, dim) - 1)*voxel_size[dim]
            end
        end

        # Create a directory for each protocol
        protocol_dir = joinpath(cmd["niftidir"], replace(protocol_name, "/" => ""))

        if !isdir(cmd["niftidir"])
            mkdir(cmd["niftidir"])
        end
        if !isdir(protocol_dir)
            mkdir(protocol_dir)
        end

        # Write NIfTI volumes
        # convert to Float32 as mricron and fsleyes apparently do not support UInt16
        ni = NIVolume(Array{Float32, 3}(raw); voxel_size=voxel_size,
            orientation=convert(Array{Float32, 2}, orientation), dim_info=dim_info,
            time_step=time_step != false ? time_step : 0f0)
        niwrite(joinpath(protocol_dir, "$(series_number).nii"), ni)
    end
end

main()


text:
using SafeTestsets

@safetestset "Tree Tests" begin include("tree_tests.jl") end
@safetestset "Forest Tests" begin include("forest_tests.jl") end


text:
### Generic rand methods

# univariate

function _rand!(s::Sampleable{Univariate}, A::AbstractArray)
    for i in 1:length(A)
        @inbounds A[i] = rand(s)
    end
    return A
end
rand!(s::Sampleable{Univariate}, A::AbstractArray) = _rand!(s, A)

rand(s::Sampleable{Univariate}, dims::Dims) =
    _rand!(s, Array(eltype(s), dims))

rand(s::Sampleable{Univariate}, dims::Int...) =
    _rand!(s, Array(eltype(s), dims))

# multivariate

function _rand!(s::Sampleable{Multivariate}, A::AbstractMatrix)
    for i = 1:size(A,2)
        _rand!(s, slice(A,:,i))
    end
    return A
end

function rand!(s::Sampleable{Multivariate}, A::AbstractVector)
    length(A) == length(s) ||
        throw(DimensionMismatch("Output size inconsistent with sample length."))
    _rand!(s, A)
end

function rand!(s::Sampleable{Multivariate}, A::AbstractMatrix)
    size(A,1) == length(s) ||
        throw(DimensionMismatch("Output size inconsistent with sample length."))
    _rand!(s, A)
end

rand(s::Sampleable{Multivariate}) =
    _rand!(s, Array(eltype(s), length(s)))

rand(s::Sampleable{Multivariate}, n::Int) =
    _rand!(s, Array(eltype(s), length(s), n))

# matrix-variate

function _rand!{M<:Matrix}(s::Sampleable{Matrixvariate}, X::AbstractArray{M})
    for i in 1:length(X)
        X[i] = rand(s)
    end
    return X
end

rand!{M<:Matrix}(s::Sampleable{Matrixvariate}, X::AbstractArray{M}) =
    _rand!(s, X)

rand(s::Sampleable{Matrixvariate}, n::Int) =
    rand!(s, Array(Matrix{eltype(s)}, n))

# sampler

# one can specialize this function to provide more efficient samplers
# for certain distributions
sampler(d::Distribution) = d


text:
using Jack
using Test

@test true


text:
using SparseArrays
using StatsBase
using LinearAlgebra
using Random
using ProgressMeter
using LinearAlgebra
using Test
using ForwardDiff
using Calculus
#include("core.jl")
J=GeoPhyInv

nx=5
nz=5
nznx=nz*nx
ddx=22.5
ddz=10.3

p=randn(nznx+1)
p[end]=0.0
Q=abs.(randn(nz,nx))
σ=abs.(randn(nz,nx))
psi0=randn(nznx)

#paA=Param(nx,nz,σ)
#paB=Param(nx,nz,Q)
#A=paA.A
#B=paB.A

function func_test(x,p)
	global psi0
	x=reshape(x,nz,nx)
	paA=J.Poisson.Param(nx,nz,x)

	psi=vec(J.Poisson.applyinvA(p,paA))
	f= sum(abs2,psi.-psi0)
	return f
end

function grad_test(x,p)
	global psi0
	paA=J.Poisson.Param(nx,nz,x)

	psi=vec(J.Poisson.applyinvA(p,paA))

	adjsrc=-2.0*(psi.-psi0)

	lambda=vec(J.Poisson.applyinvAt(adjsrc,paA))
	#println(size(lambda))

	return vec((lambda*psi'))'*hcat(vec.(paA.dAdx)...)
end

f = x->func_test(x, p);

gcalc = Calculus.gradient(f);
g3=reshape(gcalc(vec(σ)),nz,nx);

g2=reshape(grad_test(σ,p),nz,nx)

@test ≈(g2,g3, rtol=1e-5)


text:
"""
Problema de asignación. (Vanderbei LP, pg. 227). Dado un conjunto S de m personas, un conjunto D de m tareas, y para cada iS,jD un costo cij de asignar la tarea j a la persona i, el problema de asignación consiste en asignar a cada persona una y solo una tarea, de manera tal que se minimize el costo total. Formule este problema como un problema de programación lineal con enteros. Escriba una función para resolverlo, que tome como entrada una matriz de costos cij arbitraria.

"""

export solve_with_brute_force;
function solve_with_brute_force(m::Matrix{T}):: Vector{Vector{T}} where {T<:Number}
    checkmatrix(m);
    return reverse.(min_reversed_combs(m));
end # brute_force

export get_combinations;
"""
    Returns a Vector{Vector{T}} with all the posible combinations of
     the elements in the matrix m. Only square matrices of Numbers are allowed.
"""
function get_combinations(m::Matrix{T}):: Vector{Vector{T}} where {T<:Number}
    checkmatrix(m);
    return reverse.(possible_reversed_combinatoins(m));
end

function min_reversed_combs(m::Matrix{T}):: Vector{Vector{T}} where {T<:Number}

    #Store combinations
    local coms = Vector{Vector{T}}()

    #Stop statement
    if size(m) == (1,1)
        push!(coms,[m[1,1]]);
        return coms;
    end

    #Recursion block
    rowsCount::Int = size(m,1)
    local subComs::Vector{Vector{T}}
    for r in 1:rowsCount

        #Recursion call
        subComs = min_reversed_combs(getsub(m,r,1));

        #Adding
        srowsCount = size(subComs,1);
        for sr in 1:srowsCount

            #Adding head
            push!(subComs[sr],m[r][1]);

            #Adding subCom
            push!(coms,subComs[sr]);
        end
    end

    return get_min_coms(coms);
end

function possible_reversed_combinatoins(m::Matrix{T}):: Vector{Vector{T}} where {T<:Number}

    #Store combinations
    local coms = Vector{Vector{T}}()

    #Stop statement
    if size(m) == (1,1)
        push!(coms,[m[1,1]]);
        return coms;
    end

    #Recursion block
    rowsCount::Int = size(m,1)
    local subComs::Vector{Vector{T}}
    for r in 1:rowsCount

        #Recursion call
        subComs = possible_reversed_combinatoins(getsub(m,r,1));

        #Adding
        srowsCount = size(subComs,1);
        for sr in 1:srowsCount

            #Adding head
            push!(subComs[sr],m[r][1]);

            #Adding subCom
            push!(coms,subComs[sr]);
        end
    end

    return coms;
end

function get_min_coms(coms::Vector{Vector{T}}):: typeof(coms) where {T<:Number}

    #min combinations
    mincoms = Vector{Vector{T}}();

    minsum = typemax(T);
    comsum = zero(T);
    for com in coms
        comsum = sum(com);
        if comsum < minsum
            mincoms = Vector{Vector{T}}();
            minsum = comsum;
        end

        if comsum == minsum
           push!(mincoms,com);
        end
    end

    return mincoms;
end

function getsub(m::Matrix{T}, rtd::Int, ctd::Int)::Matrix{T} where {T}

    sub = Matrix{T}(undef,size(m) .- 1);
    rowsCount = size(m,1);
    colCount = size(m,2);

    for d1 in 1:rowsCount
        for d2 in 1:colCount
            if d1 < rtd
                 if d2 < ctd
                   sub[d1,d2] = m[d1,d2]
                elseif d2 > ctd
                    sub[d1,d2 - 1] = m[d1,d2]
                end
            elseif d1 > rtd
                if d2 < ctd
                   sub[d1 - 1,d2] = m[d1,d2]
                elseif d2 > ctd
                    sub[d1 - 1,d2 - 1] = m[d1,d2]
                end
            end
        end
    end

    return sub
end


text:
__precompile__()

module InvariantCausal

    export causalSearch, screen_lasso, screen_HOLP, two_sample_chow, sukhatme_fisher_test, conditional_inv_test_chow, conditional_inv_test_logistic,
           GaussianSEM, simulate, causes, cov, random_gaussian_SEM, random_noise_intervened_SEM

    include("conditionalInvTests.jl")
    include("causalSearch.jl")
    include("SEM.jl")
    include("screening.jl")

    function _test_full()
        include(joinpath(@__DIR__, "..", "test", "test_full.jl"))
    end

end


text:
"""
Implementation of https://en.wikipedia.org/wiki/Three_men%27s_morris

The set of legal moves is always a subset of 1:9, but the meaning may
differ depending on the game state. It can have three meanings:
  1. Place a new stone at the given position
  2. Lift an existing stone at the given position
  3. Place the lifted stone at the given position

  X - O - .
  | \\ | / |
  . - X - O
  | / | \\ |
  O - X - .
"""
mutable struct Morris <: Game
  board :: Vector{Int} # We may want https://github.com/JuliaArrays/StaticArrays.jl
  current_player :: Int
  lifted :: Int # A number in 1:9 indicates a lifted piece, 0 indicates no lifted piece.
  status :: Status
  placements_left :: Int # Number of pieces that must still be placed
  actions_left :: Int # A move counter after which the game ends in a draw
end

Morris() where {M, N, K} = Morris(zeros(Int, 9), 1, 0, Status(), 6, 100)

function Base.copy(s :: Morris) :: Morris
  Morris(
    copy(s.board),
    s.current_player,
    s.lifted,
    s.status,
    s.placements_left,
    s.actions_left,
  )
end

current_player(game :: Morris) :: Int = game.current_player

const adjacency = [
  [2, 4, 5], [1, 3, 5], [2, 5, 6], [1, 5, 7], [1, 2, 3, 4, 6, 7, 8, 9],
  [3, 5, 9], [4, 5, 8], [7, 5, 9], [5, 6, 8]
  ]

# Returns a list of the Indices of all legal actions
function legal_actions(game :: Morris) :: Vector{ActionIndex}
  if game.actions_left <= 0
    []
  # Are we in the "place new piece" phase?
  elseif game.placements_left > 0
    # Pre-allocate a vector with the known correct size.
    result = Vector{ActionIndex}(undef, game.placements_left + 3)
    i = 1
    for j in 1:9
      if game.board[j] == 0
        result[i] = ActionIndex(j)
        i += 1
      end
    end
    result
  elseif game.lifted == 0
    result = Vector{ActionIndex}(undef, 3)
    # All pieces may be lifted. Lifting a piece that has no moves leads to
    # a loss.
    i = 1
    for j in 1:9
      if game.board[j] == game.current_player
        if i > 3
          draw(game)
        end
        result[i] = ActionIndex(j)
        i += 1
      end
    end
    result
  else
    # Placing a piece is only allowed on connected fields
    filter(i -> game.board[i] == 0, adjacency[game.lifted])
  end
end

# Legality of an action depends on the current game phase
function is_action_legal(game :: Morris, index :: ActionIndex) :: Bool
  if game.actions_left <= 0
    # The game is already be over
    false
  elseif game.placements_left > 0
    # All empty positions are legal placement targets.
    # The game can already be over if the first player has placed all their
    # tokens in a row.
    game.board[index] == 0 && !is_over(game)
  elseif game.lifted == 0
    # The player wants to lift a piece
    # They are allowed to lift any piece of their own color.
    game.board[index] == game.current_player
  else
    # The current player has lifted a piece at game.lifted. They can place it
    # on any empty adjacent position.
    index in adjacency[game.lifted] && game.board[index] == 0 && !is_over(game)
  end
end

function apply_action!(game :: Morris, index :: ActionIndex) :: Morris
  @assert is_action_legal(game, index) "Action $index is not allowed."

  # Update the board state
  if game.placements_left > 0
    game.board[index] = game.current_player
    # update victory condition
    game.status = morris_status(game, index)
    game.current_player = -game.current_player
    game.placements_left -= 1
  elseif game.lifted == 0
    game.lifted = index
    game.board[index] = 0
    if !lift_is_legal(game, index)
      game.status = Status(-game.current_player)
    end
  else
    game.board[index] = game.current_player
    game.lifted = 0
    game.actions_left -= 1
    # update victory condition
    game.status = morris_status(game, index)
    game.current_player = -game.current_player
  end
  game
end

function lift_is_legal(game :: Morris, index :: ActionIndex) :: Bool
  # If a player lifts a piece that has no legal moves they forfeit the game.
  for i in adjacency[index]
    if game.board[i] == 0
      return true
    end
  end
  false
end

function morris_status(game :: Morris, changed_index :: ActionIndex) :: Status
  if game.actions_left <= 0
    return Status(0)
  end

  current = game.current_player

  # This is essentially a manually unrolled nested loop
  isWon = if changed_index == 1
    (game.board[2] == current && game.board[3] == current) ||
    (game.board[5] == current && game.board[9] == current) ||
    (game.board[4] == current && game.board[7] == current)
  elseif changed_index == 2
    (game.board[1] == current && game.board[3] == current) ||
    (game.board[5] == current && game.board[8] == current)
  elseif changed_index == 3
    (game.board[1] == current && game.board[2] == current) ||
    (game.board[5] == current && game.board[7] == current) ||
    (game.board[6] == current && game.board[9] == current)
  elseif changed_index == 4
    (game.board[1] == current && game.board[7] == current) ||
    (game.board[5] == current && game.board[6] == current)
  elseif changed_index == 5
    (game.board[1] == current && game.board[9] == current) ||
    (game.board[2] == current && game.board[8] == current) ||
    (game.board[3] == current && game.board[7] == current) ||
    (game.board[4] == current && game.board[6] == current)
  elseif changed_index == 6
    (game.board[3] == current && game.board[9] == current) ||
    (game.board[4] == current && game.board[5] == current)
  elseif changed_index == 7
    (game.board[1] == current && game.board[4] == current) ||
    (game.board[3] == current && game.board[5] == current) ||
    (game.board[8] == current && game.board[9] == current)
  elseif changed_index == 8
    (game.board[2] == current && game.board[5] == current) ||
    (game.board[7] == current && game.board[9] == current)
  elseif changed_index == 9
    (game.board[1] == current && game.board[5] == current) ||
    (game.board[3] == current && game.board[6] == current) ||
    (game.board[7] == current && game.board[8] == current)
  else
    throw("changed_index is $(changed_index), which is out of bounds.")
  end

  if isWon
    Status(game.current_player)
  else
    Status()
  end
end

status(game :: Morris) :: Status = game.status

policy_length(:: Type{Morris}) :: Int = 9

"""
Size of the data representation of the game
The second channel encodes game.actions_left
"""
Base.size(:: Type{Morris}) :: Tuple{Int, Int, Int} = (3, 3, 2)

# Data representation of the game as layered 2d image
function representation(game :: Morris) :: Array{Float32, 3}
  # first layer
  firstLayer = reshape(game.current_player .* game.board, (3, 3, 1))
  # countdown layer
  countdown = game.actions_left
  secondLayer = Vector{Float32}(undef, 9)
  for i in 1:9
    secondLayer[i] = countdown % 2
    countdown = countdown / 2
  end
  secondLayer = reshape(secondLayer, (3, 3, 1))

  cat(firstLayer, secondLayer, dims = 3)
end

# function augment(game :: MNKGame{M, N, K}, label :: Vector{Float32}) where {M, N, K}
#   if M == N
#     boards = apply_dihedral_group(reshape(game.board, (M, N)))
#     games = [ MNKGame{M, N, K}(reshape(b, (M * N,)), game.current_player, game.status, game.move_count) for b in boards ]

#     matpol = reshape(label[2:end], (M, N))
#     matpols = apply_dihedral_group(matpol)
#     labels = [ vcat(label[1], reshape(mp, (M * N,))) for mp in matpols ]

#     games, labels
#   else
#     boards = apply_klein_four_group(reshape(game.board, (M, N)))
#     games = [ MNKGame{M, N, K}(reshape(b, (M * N,)), game.current_player, game.status) for b in boards ]

#     matpol = reshape(label[2:end], (M, N))
#     matpols = apply_klein_four_group(matpol)
#     labels = [ vcat(label[1], reshape(mp, (M * N,))) for mp in matpols ]

#     games, labels
#   end
# end

function draw(game :: Morris) :: Nothing
  board = game.board
  symbols = Dict(1 => "X", -1 => "O", 0 => "⋅")

  println(" $(symbols[board[1]]) - $(symbols[board[2]]) - $(symbols[board[3]])")
  println(" | \\ | / |")
  println(" $(symbols[board[4]]) - $(symbols[board[5]]) - $(symbols[board[6]])")
  println(" | / | \\ |")
  println(" $(symbols[board[7]]) - $(symbols[board[8]]) - $(symbols[board[9]])")
end

max_stars_repo_name: roSievers/jtac


text:
using FinEtools
using FinEtools.TetRemeshingModule
using NIfTI
using FinEtools.VoxelTetMeshingModule

File = "Head_256x256x126-256x256x252"
file = niread(File * ".nii")
bs = voxel_size(file.header) .* [size(file,1), size(file,2), size(file,3)-100]
vb = VoxelBoxVolume(file.raw[:, :, 101:end, 1], bs)
# vtkexport(File * ".vtk", vb)

im = ImageMesher(vb, zero(eltype(vb.data)), eltype(vb.data)[255])
mesh!(im)
println("Mesh size: initial = $(size(im.t,1))")
im.elementsizeweightfunctions = [ElementSizeWeightFunction(20.0, vec([112.0, 192.5, 26.5]), 45.0), ElementSizeWeightFunction(20.0, vec([157.0, 160.5, 0.5]), 45.0), ElementSizeWeightFunction(20.0, vec([56.0, 160.5, 0.5]), 45.0)]
for i = 1:12
    mesh!(im, 1.2)
    println("Mesh size: intermediate = $(size(im.t,1))")
end

fens = FENodeSet(im.v)
fes = FESetT4(im.t)
setlabel!(fes, im.tmid)

File = "Head_mesh.vtk"
vtkexportmesh(File, fens, fes)
@async run(`"paraview.exe" $File`)


text:
################################################################################
#                                 MgO:LiNbO₃                                   #
################################################################################
export MgO_LiNbO₃

"""
These functions create a symbolic representation (using ModelingToolkit) of the
Sellmeier Equation model for the temperature and wavelength dependence
of 5% MgO:LiNbO3's (congruent LiNbO3 (CLN) not stoichiometric LiNbO3 (SLN))
ordinary and extraordinary indices of refraction.
Equation form is based on "Temperature and
wavelength dependent refractive index equations for MgO-doped congruent
and stoichiometric LiNbO3" by Gayer et al., Applied Physics B 91,
343?348 (2008)
This model is then exported to other functions that use it and its
derivatives to return index, group index and GVD values as a function
of temperature and wavelength.
Variable units are lm in [um] and T in [deg C]
"""
function n²_MgO_LiNbO₃_sym(λ, T; a₁, a₂, a₃, a₄, a₅, a₆, b₁, b₂, b₃, b₄, T₀)
    f = (T - T₀) * (T + T₀ + 2*273.16)  # so-called 'temperature dependent parameter'
    λ² = λ^2
    a₁ + b₁*f + (a₂ + b₂*f) / (λ² - (a₃ + b₃*f)^2) + (a₄ + b₄*f) / (λ² - a₅^2) - a₆*λ²
end

pₑ = (
    a₁ = 5.756,
    a₂ = 0.0983,
    a₃ = 0.202,
    a₄ = 189.32,
    a₅ = 12.52,
    a₆ = 1.32e-2,
    b₁ = 2.86e-6,
    b₂ = 4.7e-8,
    b₃ = 6.113e-8,
    b₄ = 1.516e-4,
    T₀ = 24.5,      # reference temperature in [Deg C]
)
pₒ = (
    a₁ = 5.653,
    a₂ = 0.1185,
    a₃ = 0.2091,
    a₄ = 89.61,
    a₅ = 10.85,
    a₆ = 1.97e-2,
    b₁ = 7.941e-7,
    b₂ = 3.134e-8,
    b₃ = -4.641e-9,
    b₄ = -2.188e-6,
    T₀ = 24.5,      # reference temperature in [Deg C]
)

pᵪ₂ = (
	d₃₃ =   20.3,    #   pm/V
	d₃₁ =   -4.1,    #   pm/V
	d₂₂ =   2.1,     #   pm/V
	λs  =  [1.313, 1.313, 1.313/2.0]
)

function make_MgO_LiNbO₃(;pₒ=pₒ,pₑ=pₑ,pᵪ₂=pᵪ₂)
	@variables λ, T, λs[1:3]
	nₒ² = n²_MgO_LiNbO₃_sym(λ, T; pₒ...)
	nₑ² = n²_MgO_LiNbO₃_sym(λ, T; pₑ...)
	ε 	= diagm([nₒ², nₒ², nₑ²])
	d₃₃, d₃₁, d₂₂, λᵣs = pᵪ₂
	χ⁽²⁾ᵣ = cat(
		[ 	0.0	 	-d₂₂ 	d₃₁			#	xxx, xxy and xxz
		 	-d₂₂	0.0 	0.0			#	xyx, xyy and xyz
			d₃₁	 	0.0		0.0		],	#	xzx, xzy and xzz
		[ 	-d₂₂	0.0 	0.0			#	yxx, yxy and yxz
			0.0	 	d₂₂ 	d₃₁			#	yyx, yyy and yyz
			0.0	 	d₃₁		0.0		],	#	yzx, yzy and yzz
		[ 	d₃₁	 	0.0 	0.0			#	zxx, zxy and zxz
			0.0	 	d₃₁ 	0.0			#	zyx, zyy and zyz
			0.0	 	0.0 	d₃₃		],	#	zzx, zzy and zzz
		 dims = 3
	)
	nₒ = sqrt(nₒ²)
	ngₒ = ng_model(nₒ,λ)
	gvdₒ = gvd_model(nₒ,λ)
	nₑ = sqrt(nₑ²)
	ngₑ = ng_model(nₑ,λ)
	gvdₑ = gvd_model(nₑ,λ)
	models = Dict([
		:nₒ		=>	nₒ,
		:ngₒ	=>	ngₒ,
		:gvdₒ	=>	gvdₒ,
		:nₑ		=>	nₑ,
		:ngₑ	=>	ngₑ,
		:gvdₑ	=>	gvdₑ,
		:ng		=>	diagm([ngₒ, ngₒ, ngₑ]),
		:gvd	=>	diagm([gvdₒ, gvdₒ, gvdₑ]),
		:ε 		=> 	ε,
		:χ⁽²⁾	=>	SArray{Tuple{3,3,3}}(Δₘ(λs,ε, λᵣs, χ⁽²⁾ᵣ)),
	])
	defaults =	Dict([
		:λ		=>		0.8,	# μm
		:T		=>		24.5,	# °C
		:λs₁	=>		1.064,	# μm
		:λs₂	=>		1.064,	# μm
		:λs₃	=>		0.532,	# μm

	])
	Material(
		models,
		defaults,
		:MgO_LiNbO₃,
		colorant"seagreen2", #RGB{N0f8}(0.22,0.596,0.149),	#
		)
end

################################################################

MgO_LiNbO₃ = make_MgO_LiNbO₃()


text:
"""
To deal with calcium issue:

Take tau_ca out of the calcium currents themselves, and put them in the soma, like a capacitance

What do compartments need?
Reversal potentials
Capacitance
Hooks
Time constants (Ca + V)
Dict(:V => -60., :Ca => 0.1),
Dict(:Cm => -60., :τCa => 10., :Cainf => 0.05, :ENa => -50.)
Dict(:Cₘ => -60., :τCa => 200., :Ca∞ => 0.05, :ENa => -50.)

[eNa, eh, eK, eleak
[50,-20,-80,-50
reversals = Dict(:ENa => 50., :EH =>-20., :EK =>80., :ELeak =>-50.)
ics = Dict(:V => -60., :Ca => 0.05)
params = Dict(:Cₘ => 10., :τCa => 200., :Ca∞ => 0.05)
"""

abstract type Compartment end

struct Soma <: Compartment
    initial_states::Dict{Symbol, Float64}
    parameters::Dict{Symbol, Float64}
    hooks::Int64
end

max_stars_repo_name: wsphillips/NeuronBuilder

max_issues_repo_name: wsphillips/NeuronBuilder

max_forks_repo_name: wsphillips/NeuronBuilder


text:
using Distributions
using CausalInference
using LightGraphs

quantile(Normal(), 0.95)

if !isfile(joinpath("data","NCI-60.csv"))
    cd("data") do
        run(`wget http://nugget.unisa.edu.au/ParallelPC/data/real/NCI-60.csv`)
    end
end

data = readdlm("data/NCI-60.csv")
d = size(data,2)
X = data[:,1:d]'
d, n = size(X)
C = Symmetric(cor(X, 2))
p = 0.01
@time h, s = skeleton(d, gausscitest, (C,n), quantile(Normal(), 1-p/2))
println("inferred edges ", ne(h))
writedlm("data/adjac.csv", adjacency_matrix(h))


text:
using DSP
using Unitful

export mix, mult, silence, envelope, noise, highpass, lowpass, bandpass,
  bandstop, tone, ramp, harmonic_complex, attenuate, asstream,
  rampon, rampoff, fadeto, irn

"""
    mix(x,y,...)

mix several sounds (or streams) together so that they play at the same time.

Unlike normal addition, this acts as if each sound is padded with
zeros at the end so that the lengths of all sounds match.
"""
mix{R}(xs::Union{Audible{R},Array}...) = soundop((x,y) -> x .+ y,xs...)

"""
    mult(x,y,...)

Mutliply several sounds (or streams) together. Typically used to apply an
amplitude envelope.

Unlike normal multiplication, this acts as if each sound is padded with
ones at the end so that the lengths of all sounds match.
"""
mult{R}(xs::Union{Audible{R},Array}...) = soundop((x,y) -> x .* y,xs...)

"""
    silence(length;[sample_rate=samplerate()])

Creates period of silence of the given length (in seconds).
"""
function silence(length;sample_rate=samplerate())
  audible(t -> zeros(t),length,false,sample_rate=sample_rate)
end

"""
    envelope(mult,length;[sample_rate_Hz=44100])

creates an envelope of a given multiplier and length (in seconds).

If mult = 0 this is the same as calling [`silence`](@ref). This function
is useful in conjunction with [`fadeto`](@ref) and [`mult`](@ref)
when defining an envelope that changes in level. For example,
the following will play a 1kHz tone for 1 second, which changes
in volume halfway through to a softer level.

    mult(tone(1000,1),fadeto(envelope(1,0.5),envelope(0.1,0.5)))

"""
function envelope(mult,length;sample_rate=samplerate())
  audible(t -> mult*ones(t),length,sample_rate=sample_rate)
end

"""
    noise(length=Inf;[sample_rate_Hz=44100],[rng=RandomDevice()])

Creates a period of white noise of the given length (in seconds).

You can create an infinite stream of noise by passing a length of Inf, or
leaving out the length entirely.
"""
function noise(len=Inf;sample_rate=samplerate(),rng=RandomDevice())
  audible((i::UnitRange{Int}) -> 1.0-2.0rand(rng,length(i)),len,
          false,sample_rate=sample_rate)
end

"""
    tone(freq,length;[sample_rate=samplerate()],[phase=0])

Creates a pure tone of the given frequency and length (in seconds).

You can create an infinitely long tone by passing a length of Inf, or leaving
out the length entirely.
"""
function tone(freq,len=Inf;sample_rate=samplerate(),phase=0.0)
  freq_Hz = ustrip(inHz(freq))
  audible(t -> sin.(2π*t * freq_Hz + phase),len,
          sample_rate=sample_rate)
end

function complex_cycle(f0,harmonics,amps,sample_rate_Hz,phases)
  @assert all(0 .<= phases) && all(phases .< 2π)
	n = maximum(harmonics)+1

  # generate single cycle of complex
  cycle = silence((1/f0),sample_rate=sample_rate_Hz)

	highest_freq = tone(f0,2n*length(cycle)*samples;sample_rate=sample_rate_Hz)

	for (amp,harm,phase) in zip(amps,harmonics,phases)
		phase_offset = round(Int,n*phase/2π*sample_rate_Hz/f0)
    wave = highest_freq[(1:length(cycle)) * (n-harm) + phase_offset]
		cycle += amp*wave[1:length(cycle)]
	end

  cycle
end

"""
    harmonic_complex(f0,harmonics,amps,length,
                     [sample_rate=samplerate()],[phases=zeros(length(harmonics))])

Creates a harmonic complex of the given length, with the specified harmonics
at the given amplitudes. This implementation is somewhat superior
to simply summing a number of pure tones generated using `tone`, because
it avoids beating in the sound that may occur due floating point errors.

You can create an infinitely long complex by passing a length of Inf, or leaving
out the length entirely.
"""
function harmonic_complex(f0,harmonics,amps,len=Inf;
						              sample_rate=samplerate(),
                          phases=zeros(length(harmonics)))
  cycle = complex_cycle(inHz(f0),harmonics,amps,
                        inHz(Int,sample_rate),phases)
  N = size(cycle,1)
  audible((i::UnitRange{Int}) -> cycle[(i.-1) .% N + 1],len,false,sample_rate=sample_rate)
end

"""
    irn(n,λ,[length=Inf];[g=1],[sample_rate=samplerate()],
                         [rng=Base.GLOBAL_RNG])

Creates an iterated ripple ``y_n(t)`` for a noise ``y_0(t)`` according to
the following formula.

``
y_n(t) = y_{n-1}(t) + g⋅y_{n-1}(t-d)
``

You can create an infinitely long IRN by passing a length of Inf, or leaving
out the length entirely.

!!! note "RNG must be reproduceable"

    For the streaming implementation, the noise's RNG is copied to generate the
    iterations, so copying this RNG must reliabley reproduce the same sequence
    of noise.  This means you cannot use `RandomDevice`.
"""
function irn(n,λ,length=Inf;g=1,sample_rate=samplerate(),rng=Base.GLOBAL_RNG)
  irn_helper(noise(length,sample_rate=sample_rate,rng=rng),n,λ,g,rng)
end

function irn_helper(source,n,λ,g,rng)
  if n == 0
    source
  else
    irn_helper(mix(source,[silence(λ); g * source_again(source,rng)]),n-1,λ,g,rng)
  end
end

source_again(source::Sound,rng) = source
source_again(source::Stream,rng) = noise(rng=deepcopy(rng))

"""
    bandpass(x,low,high;[order=5])

Band-pass filter the sound (or stream) at the specified frequencies.

Filtering uses a butterworth filter of the given order.
"""
bandpass(x,low,high;order=5) = filter_helper(x,low,high,Bandpass,order)

"""
    bandstop(x,low,high,[order=5],[sample_rate_Hz=samplerate(x)])

Band-stop filter of the sound (or stream) at the specified frequencies.

Filtering uses a butterworth filter of the given order.
"""
bandstop(x,low,high;order=5) = filter_helper(x,low,high,Bandstop,order)

"""
    lowpass(x,low,[order=5],[sample_rate_Hz=samplerate(x)])

Low-pass filter the sound (or stream) at the specified frequency.

Filtering uses a butterworth filter of the given order.
"""
lowpass(x,low;order=5) = filter_helper(x,low,0,Lowpass,order)

"""
    highpass(x,high,[order=5],[sample_rate_Hz=samplerate(x)])

High-pass filter the sound (or stream) at the specified frequency.

Filtering uses a butterworth filter of the given order.
"""
highpass(x,high;order=5) = filter_helper(x,0,high,Highpass,order)

function buildfilt(samplerate,low,high,kind)
  if kind == Bandpass
	  Bandpass(float(ustrip(inHz(low))),float(ustrip(inHz(high))),fs=samplerate)
  elseif kind == Lowpass
    Lowpass(float(ustrip(inHz(low))),fs=samplerate)
  elseif kind == Highpass
    Highpass(float(ustrip(inHz(high))),fs=samplerate)
  elseif kind == Bandstop
    Bandstop(float(ustrip(inHz(low))),float(ustrip(inHz(high))),fs=samplerate)
  end
end

function filter_helper(audible,low,high,kind,order)
  ftype = buildfilt(ustrip(samplerate(audible)),low,high,kind)
  f = digitalfilter(ftype,Butterworth(order))
  audiofn(x -> DSP.filt(f,x),audible)
end

"""
    ramp(x,[length=5ms])

Applies a half cosine ramp to start and end of the sound.

Ramps prevent clicks at the start and end of sounds.
"""
function ramp{R}(x::Sound{R},len=5ms)
  ramp_n = insamples(len,R*Hz)
	if nsamples(x) < 2ramp_n
    error("Cannot apply two $(rounded_time(len,R)) ramps to ",
          "$(rounded_time(duration(x),R)) sound.")
  end

  n = nsamples(x)
	r = audible(duration(x),false,sample_rate=R*Hz) do t
    ifelse.(t .< ramp_n,
      -0.5.*cos.(π.*t./ramp_n).+0.5,
    ifelse.(t .< n .- ramp_n,
      1,
      -0.5.*cos.(π.*(t .- n .+ ramp_n)./ramp_n.+π).+0.5))
	end
	mult(x,r)
end

"""
    rampon(stream,[len=5ms])

Applies a half consine ramp to start of the sound or stream.
"""
function rampon{R}(x::Audible{R},len=5ms)
  ramp_n = insamples(len,R*Hz)
	if nsamples(x) < ramp_n
    error("Cannot apply a $(rounded_time(len,R)) ramp to ",
          "$(rounded_time(duration(x),R)) sound.")
  end

	r = audible(ramp_n*samples,false,sample_rate=R*Hz) do t
    -0.5.*cos.(π.*t./ramp_n).+0.5
	end
	mult(x,r)
end

"""
    rampoff(stream,[len=5ms],[after=len])

Applies a half consine ramp to the end sound, or to a stream.

For streams, you can specify how many seconds after the newly
modified stream begins playing the rampoff should finish.
"""

function rampoff{R}(x::Sound{R},len=5ms)
  rampoff_helper(x,insamples(len,R*Hz),nsamples(x))
end

function rampoff{R}(x::AbstractStream{R},len=5ms,after=len)
  rampoff_helper(x,insamples(len,R*Hz),insamples(after,R*Hz))
end

function rampoff_helper{R}(x::Audible{R},len::Int,after::Int)
	if !(0 < after <= nsamples(x))
    if len > nsamples(x)
      error("Cannot apply $(rounded_time(len/R,R)) ramp to",
            " $(rounded_time(duration(x),R)) of audio.")
    else
      error("Cannot apply $(rounded_time(len/R,R)) ramp after ",
            "$(rounded_time(after/R - len/R,R)) to",
            " $(rounded_time(duration(x),R)) of audio.")
    end
  end

  rampstart = (after - len)
	r = audible(after*samples,false) do t
    ifelse.(t .< rampstart,1,-0.5.*cos.(π.*(t.-rampstart)./len.+π).+0.5)
	end
	mult(limit(x,after),r)
end

"""
    fadeto(a,b,[transition=50ms],[after=overlap])

A smooth transition from a to b, overlapping the end of one
with the start of the other by `overlap`.

For streams you can specify how long after the newly
modified stream begins playing the transition should finish.
"""
function fadeto{R}(a::Sound{R},b::Sound{R},transition=50ms)
  mix(rampoff(a,transition),
      [silence(duration(a) - transition); rampon(b,transition)])
end

function fadeto(old::AbstractStream,new::AbstractStream,channel::Int=1,
                transition=50ms,after=50ms)
  mix(rampoff(old,transition,after),
      [silence(after - transition); rampon(new,transition)])
end

"""
    attenuate(x,atten_dB;[time_constant])

Apply the given decibels of attenuation to the sound (or stream) relative to a
power level of 1.

This function normalizes the sound to have a root mean squared value of 1 and
then reduces the sound by a factor of ``10^{-a/20}``, where ``a`` = `atten_dB`.

The keyword argument `time_constant` determines the time across which the sound
is normalized to power 1, which, for sounds, defaults to the entire sound and,
for streams, defaults to 1 second.
"""
# TODO: allow a time constant for Sound's using braodcast operator
function attenuate(x::Sound,atten_dB)
	similar(x) .= 10^(-atten_dB/20) .* x ./ rms(x)
end
function attenuate(x::AbstractStream,atten_dB;time_constant=1s)
	audiofn(soundop((x,y) -> x ./ y,x,rms(deepcopy(x),time_constant))) do x
    10^(-atten_dB/20) .* x
  end
end

rms(x::Sound) = sqrt(mean(x.^2))
function rms{R}(audio::Audible{R},len)
  decay = 1 - 1 / (ustrip(inseconds(len,R))*R)
  let μ² = 1.0, N = 1.0
    audiofn(audio) do xs
      ys = similar(xs,size(xs,1))
      for i in 1:size(xs,1)
        ys[i] = sqrt(μ² ./ N)
        μ² = decay*μ² + mean(xs[i,:])^2
        N = decay*N + 1
      end
      ys
    end
  end
end


text:
using Pkg
Pkg.activate(@__DIR__)

using Dates
using HTTP
using MySQL
using JSON3
using StructTypes

struct jsonObj
    id::Int
    randomNumber::Int
end

StructTypes.StructType(::Type{jsonObj}) = StructTypes.Struct()

HTTP.listen("0.0.0.0" , 8080, reuseaddr = true) do http
    target = http.message.target

    HTTP.setstatus(http, 200)
    HTTP.setheader(http, "Server" => "Julia-HTTP")
    HTTP.setheader(http, "Date" => Dates.format(Dates.now(), Dates.RFC1123Format) * " GMT")

    if endswith(target, "/plaintext")
        HTTP.setheader(http, "Content-Type" => "text/plain")
        HTTP.startwrite(http)
        write(http, "Hello, World!")

    elseif endswith(target, "/json")
        HTTP.setheader(http, "Content-Type" => "application/json")
        startwrite(http)
        JSON3.write(http, (;message = "Hello, World!"))

    elseif endswith(target, "/db")
        HTTP.setheader(http, "Content-Type" => "application/json")
        randNum = rand(1:10000)

        conn = DBInterface.connect(MySQL.Connection, "tfb-database", "benchmarkdbuser", "benchmarkdbpass", db="hello_world")
        sqlQuery = "SELECT * FROM World WHERE id = $randNum"
        results = DBInterface.execute(conn, sqlQuery)
        row = first(results)
        dbNumber = row[2]
        jsonString = "{\"id\":$randNum,\"randomNumber\":$dbNumber}"

        startwrite(http)
        JSON3.write(http, (JSON3.read(jsonString)))

    elseif occursin("/queries", target)
        HTTP.setheader(http, "Content-Type" => "application/json")
        numQueries = -1

        try
            numQueries = parse(Int64, (split(target, "="))[2])

        catch ArgumentError
            numQueries = 1

        finally
            if numQueries > 500
                numQueries = 500
            end

            if numQueries < 1
                numQueries = 1
            end
        end

        # randNumList = rand(Int64, 1:10000, numQueries)
        conn = DBInterface.connect(MySQL.Connection, "tfb-database", "benchmarkdbuser", "benchmarkdbpass", db="hello_world")

        responseArray = Array{jsonObj}(undef, numQueries)
        for i in 1:numQueries
            # randNum = randNumList[i]
            randNum = rand(1:10000)
            sqlQuery = "SELECT * FROM World WHERE id = $randNum"
            results = DBInterface.execute(conn, sqlQuery)
            row = first(results)
            dbNumber = row[2]
            responseArray[i] = JSON3.read("{\"id\":$randNum,\"randomNumber\":$dbNumber}", jsonObj)
        end

        startwrite(http)
        JSON3.write(http, responseArray)
        # JSON3.write(http, (JSON3.read(responseArray, JSON3.Array)))

    else
        HTTP.setstatus(http, 404)
        startwrite(http)
        write(http, "Not Found")

    end
end

max_stars_repo_name: frejsoya/FrameworkBenchmarks

max_issues_repo_name: frejsoya/FrameworkBenchmarks

max_forks_repo_name: frejsoya/FrameworkBenchmarks