webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.95k stars 172 forks source link

Floats #367

Closed crystalthoughts closed 4 months ago

crystalthoughts commented 4 months ago

Hi, is it possible to send floats between backend and frontend? I notice only int, string and bool is available on bind?

hassandraga commented 4 months ago

Probably this is good to be added, will see. Thank you. for now, you can send raw binary.

function floatToUint8Array(floatValue) {
  const floatArray = new Float32Array([floatValue]);
  return new Uint8Array(floatArray.buffer);
}

const myFloat = 3.14159;
myBackendFun(floatToUint8Array(myFloat))
hassandraga commented 4 months ago

Added.

myBackendFun(123.456)
double f = webui_get_float(e);
neroist commented 4 months ago

@hassandraga Wouldn't webui_return_float be nice aswell?

hassandraga commented 4 months ago

I forgot. Sorry, my bad! Added.

crystalthoughts commented 4 months ago

Thanks! So glad i found this

On Thu, 30 May 2024 at 01:04, Hassan DRAGA @.***> wrote:

I forgot. Sorry, my bad! Added https://github.com/webui-dev/webui/commit/4517ba498290276a5ccc1636873af3e971a656f5 .

— Reply to this email directly, view it on GitHub https://github.com/webui-dev/webui/issues/367#issuecomment-2138392455, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSNQQG2R53QBW4GNX7NP7TZEZNHPAVCNFSM6AAAAABIJ6LFVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZYGM4TENBVGU . You are receiving this because you authored the thread.Message ID: @.***>