From b3cdf90d39afd0b583a9b02c3f8febe01c1b228f Mon Sep 17 00:00:00 2001
From: bangbangsheshotmedown <apocalypse.praise@gmail.com>
Date: Tue, 29 Oct 2024 19:50:13 +0000
Subject: [PATCH 1/3] Add D example

---
 bindings/D/main.d | 88 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 bindings/D/main.d

diff --git a/bindings/D/main.d b/bindings/D/main.d
new file mode 100644
index 0000000..5fe6f10
--- /dev/null
+++ b/bindings/D/main.d
@@ -0,0 +1,88 @@
+import clay;
+
+import core.stdc.stdlib;
+
+__gshared:
+
+Clay_LayoutConfig layoutElement = { padding: {5} };
+
+extern(C) void main()
+{
+    ulong totalMemorySize = Clay_MinMemorySize();
+    Clay_Arena clayMemory = {
+        label: str("Clay Memory Arena"),
+        capacity: totalMemorySize,
+        memory: cast(char*)malloc(totalMemorySize)
+    };
+
+    Clay_Initialize(clayMemory, Clay_Dimensions(1024,768));
+    Clay_BeginLayout();
+    if (ClayBegin( Rectangle(color: Clay_Color(255,255,255,0)), Layout(layoutElement)))
+    {   }
+    ClayEnd();
+}
+
+
+// helper functions
+Clay_String str(string it)
+{
+    return Clay_String(cast(int)it.length, it.ptr);
+}
+
+bool ClayBegin(A...)(A configs)
+{
+    Clay__OpenElement();
+    foreach(config; configs)
+    {
+        alias T = typeof(config);
+        static if (is(T == Clay_ElementId))
+        {
+            Clay__AttachId(config);
+        }
+        else static if(is(T == Clay_LayoutConfig*))
+        {
+            Clay__AttachLayoutConfig(config);
+        }
+        else static if(is(T == Clay_ElementConfig))
+        {
+            Clay__AttachElementConfig(config.config, config.type);
+        }
+        else static assert(0, "unsupported " ~ typeof(config).stringof);
+    }
+
+    Clay__ElementPostConfiguration();
+    return true;
+}
+
+void ClayEnd()
+{
+    Clay__CloseElement();
+}
+
+Clay_ElementId Id(string label)
+{
+     return Clay__HashString(str(label), 0, 0);
+}
+
+Clay_LayoutConfig* Layout(lazy Clay_Sizing sizing = Clay_Sizing.init)
+{
+    Clay_LayoutConfig config;
+    config.sizing = sizing;
+    return Clay__StoreLayoutConfig(config);
+}
+
+Clay_LayoutConfig* Layout(Clay_LayoutConfig config)
+{
+    return Clay__StoreLayoutConfig(config);
+}
+
+Clay_ElementConfig Rectangle(lazy Clay_Color color = Clay_Color.init)
+{
+    Clay_RectangleElementConfig config;
+    config.color = color;
+
+    Clay_ElementConfig ret;
+    ret.type = Clay__ElementConfigType.CLAY__ELEMENT_CONFIG_TYPE_RECTANGLE;
+    ret.config.rectangleElementConfig = Clay__StoreRectangleElementConfig(config);
+    return ret;
+}

From 134beca09cdda368cc10d5192e8d0a6553c3fd19 Mon Sep 17 00:00:00 2001
From: bangbangsheshotmedown <apocalypse.praise@gmail.com>
Date: Tue, 29 Oct 2024 19:50:51 +0000
Subject: [PATCH 2/3] Add C file

---
 bindings/D/clay.c | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 bindings/D/clay.c

diff --git a/bindings/D/clay.c b/bindings/D/clay.c
new file mode 100644
index 0000000..43e8cb5
--- /dev/null
+++ b/bindings/D/clay.c
@@ -0,0 +1,2 @@
+#define CLAY_IMPLEMENTATION
+#include "../../clay.h"

From ea3e29be5cd002a28674fa58e615c6ad0c1cb06b Mon Sep 17 00:00:00 2001
From: bangbangsheshotmedown <apocalypse.praise@gmail.com>
Date: Tue, 29 Oct 2024 19:53:11 +0000
Subject: [PATCH 3/3] Create README.md

---
 bindings/D/README.md | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 bindings/D/README.md

diff --git a/bindings/D/README.md b/bindings/D/README.md
new file mode 100644
index 0000000..8d5c393
--- /dev/null
+++ b/bindings/D/README.md
@@ -0,0 +1,5 @@
+### D Language Example
+
+```
+dmd main.d clay.c
+```