Change Color struct in example

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
Slendi 2024-03-28 08:24:44 +02:00
parent 81b0c139ef
commit 3dbe9b6915
4 changed files with 39 additions and 15 deletions

5
.gitignore vendored
View File

@ -4,4 +4,7 @@ speedcat.pdb
test.exe test.exe
hello.ll hello.ll
*.ll *.ll
*.exe *.exe
*.dSYM
.DS_Store
raylib

4
build_test.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
odin run src -o:none -debug -out:speedcat '-extra-linker-flags:-L/opt/homebrew/opt/llvm/lib' -- test_type_checker.cat
clang -I/opt/homebrew/include /opt/homebrew/lib/libraylib.a -lm -framework Cocoa -framework OpenGL -framework IOKit test_type_checker.ll test.c -o raylib

25
test.c
View File

@ -1,7 +1,24 @@
#include <stdio.h>
#include <stdint.h> #include <stdint.h>
int32_t meow(int32_t x) { void ClearBackground(uint64_t rgba);
printf("%d\n", x); void ClearBackgroundWrap(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
return 500; ClearBackground((uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
(uint64_t)a);
}
void DrawRectangle(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
uint64_t rgba);
void DrawRectangleWrap(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
DrawRectangle(x, y, width, height,
(uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
(uint64_t)a);
}
void DrawCircle(uint32_t x, uint32_t y, float radius, uint64_t rgba);
void DrawCircleWrap(uint32_t x, uint32_t y, float radius, uint8_t r, uint8_t g,
uint8_t b, uint8_t a) {
DrawCircle(x, y, radius,
(uint64_t)r << 24 | (uint64_t)g << 16 | (uint64_t)b << 8 |
(uint64_t)a);
} }

View File

@ -40,31 +40,31 @@
\ \
\(meow (add 60 9)) -> meow \(meow (add 60 9)) -> meow
struct Color "packed" { struct Color {
r g b a: u8, a b g r: u8,
} }
fn InitWindow(w h: i32, title: i32) fn InitWindow(w h: i32, title: i32)
fn CloseWindow fn CloseWindow
fn ClearBackground(c: Color) fn ClearBackgroundWrap(c: Color)
fn BeginDrawing fn BeginDrawing
fn EndDrawing fn EndDrawing
fn DrawFPS(x y: i32) fn DrawFPS(x y: i32)
fn DrawRectangle(x y w h: i32, c: Color) fn DrawRectangleWrap(x y w h: i32, c: Color)
fn DrawCircle(x y: i32, r: f32, c: Color) fn DrawCircleWrap(x y: i32, r: f32, c: Color)
fn WindowShouldClose i32 fn WindowShouldClose i32
let white :: .Color{255 255 255 255} let white :: .Color{255 69 69 69}
let red :: .Color{255 0 0 255} let red :: .Color{255 0 0 255}
let blue :: .Color{0 0 255 255} let blue :: .Color{255 0 255 255}
InitWindow 640 480 0 InitWindow 640 480 0
for WindowShouldClose == 0 { for WindowShouldClose == 0 {
BeginDrawing BeginDrawing
ClearBackground white ClearBackgroundWrap white
DrawFPS 20 20 DrawFPS 20 20
\DrawRectangle 80 80 100 200 red DrawRectangleWrap 80 80 100 200 red
\DrawCircle 90 90 100.0 blue DrawCircleWrap 200 200 100.0 blue
EndDrawing EndDrawing
} }
CloseWindow CloseWindow