Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d613d03
wip
burdockcascade Jul 25, 2026
2c618fc
wip
burdockcascade Jul 25, 2026
ab7ae19
update d file
burdockcascade Jul 25, 2026
c7989fc
chore: update pull request trigger types in verify.yml
burdockcascade Jul 25, 2026
d994de1
chore: remove debug output for script input in main.cpp
burdockcascade Jul 25, 2026
9d0174f
include <string> header in core.hpp
burdockcascade Jul 25, 2026
b07d9ad
remove unused headers and include quickjs.h in js_types.hpp
burdockcascade Jul 25, 2026
3c41e3e
fix: change RAYLIB_VERSION_STR and QUICKJS_VERSION_STR to inline vari…
burdockcascade Jul 25, 2026
0359935
fix: change function declarations to non-inline in js_context.hpp
burdockcascade Jul 25, 2026
73489d4
fix: add error handling for argument conversion in constructors
burdockcascade Jul 25, 2026
aa8b690
fix: swap width and height parameters in JSApplication constructor
burdockcascade Jul 25, 2026
4f8dc8d
fix: add additional properties to JSDrawOptions in api_context.cpp
burdockcascade Jul 25, 2026
f336270
fix: change draw_options declarations to const in api_context.cpp
burdockcascade Jul 25, 2026
47056bb
fix
burdockcascade Jul 25, 2026
be13165
fix
burdockcascade Jul 25, 2026
fcd3006
fix: correct argument index for alpha channel in JSColor constructor
burdockcascade Jul 25, 2026
2401d31
fix: remove Font export from module in hostapi.hpp
burdockcascade Jul 25, 2026
280ecce
fix: include <type_traits> in js_utils.hpp
burdockcascade Jul 25, 2026
2dcacab
fix: correct argument order for Application initialization in README
burdockcascade Jul 25, 2026
431a368
fix: correct argument order for Application initialization in solar2d.js
burdockcascade Jul 25, 2026
6a5c78d
fix: correct argument order for Application initialization in shapes2.js
burdockcascade Jul 25, 2026
ccfe5ff
refactor: remove Font class and update drawPixel method signature in …
burdockcascade Jul 25, 2026
8150421
fix: resolve exception handling in update and draw function calls in …
burdockcascade Jul 25, 2026
17fd277
fix: update constructor argument types to use double for JSVector2 in…
burdockcascade Jul 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
release:
types: [published]

permissions:
contents: write

jobs:
release-ubuntu:
name: Release on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake g++-14 ninja-build libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build -S . -DCMAKE_BUILD_TYPE=Release
env:
CXX: g++-14
- name: Build Target
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Package Asset
run: tar -czvf vectorjs-linux.tar.gz -C ${{ github.workspace }}/build vectorjs
- name: Upload Binary to Release
uses: softprops/action-gh-release@v2
with:
files: vectorjs-linux.tar.gz

release-windows:
name: Release on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Configure CMake
run: cmake -B ${{ github.workspace }}\build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build Target
run: cmake --build ${{ github.workspace }}\build --config Release
- name: Package Asset
shell: pwsh
run: Compress-Archive -Path "${{ github.workspace }}\build\Release\vectorjs.exe" -DestinationPath "vectorjs-windows.zip"
- name: Upload Binary to Release
uses: softprops/action-gh-release@v2
with:
files: vectorjs-windows.zip

release-mac:
name: Release on macOS
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Ninja
run: brew install ninja
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build Target
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Package Asset
run: tar -czvf vectorjs-macos.tar.gz -C ${{ github.workspace }}/build vectorjs
- name: Upload Binary to Release
uses: softprops/action-gh-release@v2
with:
files: vectorjs-macos.tar.gz
60 changes: 60 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Verify
concurrency:
cancel-in-progress: false
group: verify

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
types: [opened, synchronize, reopened]

jobs:
verify-ubuntu:
name: Verify on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake g++-14 ninja-build libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build -S . -DCMAKE_BUILD_TYPE=Release
env:
CXX: g++-14
- name: Build Target
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Verify Executable Production
run: ls -l ${{ github.workspace }}/build/vectorjs

verify-windows:
name: Verify on Windows
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Configure CMake
run: cmake -B ${{ github.workspace }}\build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build Target
run: cmake --build ${{ github.workspace }}\build --config Release
- name: Verify Executable Production
shell: pwsh
run: Test-Path "${{ github.workspace }}\build\Release\vectorjs.exe"

verify-mac:
name: Verify on macOS
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Ninja
run: brew install ninja
- name: Configure CMake
run: cmake -B ${{ github.workspace }}/build -S . -DCMAKE_BUILD_TYPE=Release
- name: Build Target
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Verify Executable Production
run: ls -l ${{ github.workspace }}/build/vectorjs
98 changes: 98 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
cmake_minimum_required(VERSION 3.28)
project(vectorjs VERSION 0.1.0 LANGUAGES CXX)

# Require C++23 standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(FetchContent)

option(ENABLE_MSVC_WIN_MAIN "Hide the console window for MSVC builds" OFF)

# -----------------------------------------------------------------------------
# 1. Dependencies
# -----------------------------------------------------------------------------

# CLI11 (Header-only CLI parser)
FetchContent_Declare(
cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11.git
GIT_TAG v2.6.2
)
set(CLI11_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(CLI11_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)

# raylib (Windowing, input, and graphics library)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG 6.0
)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)

# qjs
FetchContent_Declare(
qjs
GIT_REPOSITORY https://github.com/quickjs-ng/quickjs
GIT_TAG v0.15.1
)

# Bring all dependencies into the build tree automatically
FetchContent_MakeAvailable(cli11 raylib qjs)

# -----------------------------------------------------------------------------
# 2. Executable Target
# -----------------------------------------------------------------------------

# Define the target executable
add_executable(vectorjs)

# Add source files to the target
target_sources(vectorjs PRIVATE
"src/main.cpp"
"src/js_engine.cpp"
"src/core.cpp"
"src/api/api_context.cpp"
"src/api/api_classes.cpp"
"src/api/api_enums.cpp"
)

# Hide console on Windows, keep standard main() entry point
if(MSVC AND ENABLE_MSVC_WIN_MAIN)
target_link_options(vectorjs PRIVATE
"LINKER:/SUBSYSTEM:WINDOWS"
"LINKER:/ENTRY:mainCRTStartup"
)
endif()

# Include directories
target_include_directories(vectorjs PRIVATE src)

# Link dependencies
target_link_libraries(vectorjs PRIVATE
CLI11::CLI11
raylib
qjs
)

# -----------------------------------------------------------------------------
# 3. Options
# -----------------------------------------------------------------------------

#function(add_feature_flag OPTION_NAME DESCRIPTION DEFAULT_VAL MACRO_NAME)
# option(${OPTION_NAME} "${DESCRIPTION}" ${DEFAULT_VAL})
#
# if(${OPTION_NAME})
# target_compile_definitions(vectorjs PRIVATE ${MACRO_NAME}=1)
# else()
# target_compile_definitions(vectorjs PRIVATE ${MACRO_NAME}=0)
# endif()
#endfunction()
#
#add_feature_flag(ENABLE_2D "Enable 2D graphics systems" ON ENABLE_FEATURE_2D)
#add_feature_flag(ENABLE_3D "Enable 3D graphics systems" ON ENABLE_FEATURE_3D)
#add_feature_flag(ENABLE_FONT "Enable fonts" OFF ENABLE_FEATURE_FONT)
#add_feature_flag(ENABLE_AUDIO "Enable audio engine" ON ENABLE_FEATURE_AUDIO)

41 changes: 41 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# VectorJS

## Dependencies
* Raylib
* Quickjs-ng

## Example
```js
import {Application, Rectangle, Vector2, Palette } from "vectorjs";

const screenWidth = 800;
const screenHeight = 600;
const fpsPos = new Vector2(10, 10);
const rect = new Rectangle(30, 30, 200, 45);
const point1 = new Vector2(400, 150);
const point2 = new Vector2(300, 350);
const point3 = new Vector2(500, 350);

const app = new Application(screenWidth, screenHeight, "Window");
app.run({

onDraw(render) {
render.withLayer2D((ctx) => {
ctx.drawFPS(fpsPos);

ctx.shapes.drawRectangle(rect, {
color: Palette.RED
})

ctx.shapes.drawCircle(point1, 60, {
color: Palette.GREEN
})

ctx.shapes.drawTriangle(point1, point2, point3, {
color: Palette.BLUE
})

});
}
});
```
91 changes: 91 additions & 0 deletions examples/2d/clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Application, Vector2, Palette } from "vectorjs";

// Window configuration
const screenWidth = 600;
const screenHeight = 600;
const center = new Vector2(screenWidth / 2, screenHeight / 2);
const fpsPos = new Vector2(10, 10);

// Clock dimensions
const clockRadius = 200;
const hourHandLength = 100;
const minuteHandLength = 140;
const secondHandLength = 160;

const app = new Application(screenWidth, screenHeight, "Analog Clock");

app.run({
onDraw(render) {
render.withLayer2D((ctx) => {

// 1. Draw Clock Face Outer Ring & Center
ctx.shapes.drawCircle(center, clockRadius, {
color: Palette.WHITE
});
ctx.shapes.drawCircle(center, 8, {
color: Palette.BLACK
});

// 2. Draw Hour Ticks (12 main markers)
for (let i = 0; i < 12; i++) {
const angle = (i * 30 - 90) * (Math.PI / 180);
const innerRadius = clockRadius - 20;

const tickStart = new Vector2(
center.x + innerRadius * Math.cos(angle),
center.y + innerRadius * Math.sin(angle)
);
const tickEnd = new Vector2(
center.x + clockRadius * Math.cos(angle),
center.y + clockRadius * Math.sin(angle)
);

ctx.shapes.drawLine(tickStart, tickEnd, {
color: Palette.GRAY
});
}

// 3. Get Current Time
const now = new Date();
const hours = now.getHours() % 12;
const minutes = now.getMinutes();
const seconds = now.getSeconds();
const milliseconds = now.getMilliseconds();

// Smooth calculations for hand angles (in radians, -90 deg offset to start at 12 o'clock)
const secondAngle = ((seconds + milliseconds / 1000) * 6 - 90) * (Math.PI / 180);
const minuteAngle = ((minutes + seconds / 60) * 6 - 90) * (Math.PI / 180);
const hourAngle = ((hours + minutes / 60) * 30 - 90) * (Math.PI / 180);

// Calculate hand end positions
const hourHandEnd = new Vector2(
center.x + hourHandLength * Math.cos(hourAngle),
center.y + hourHandLength * Math.sin(hourAngle)
);
const minuteHandEnd = new Vector2(
center.x + minuteHandLength * Math.cos(minuteAngle),
center.y + minuteHandLength * Math.sin(minuteAngle)
);
const secondHandEnd = new Vector2(
center.x + secondHandLength * Math.cos(secondAngle),
center.y + secondHandLength * Math.sin(secondAngle)
);

// 4. Draw Clock Hands
// Hour Hand
ctx.shapes.drawLine(center, hourHandEnd, {
color: Palette.BLUE
});

// Minute Hand
ctx.shapes.drawLine(center, minuteHandEnd, {
color: Palette.GREEN
});

// Second Hand
ctx.shapes.drawLine(center, secondHandEnd, {
color: Palette.RED
});
});
}
});
Loading