start of rename to cell
@@ -279,7 +279,7 @@ $_.receiver(msg => {
|
|||||||
- Custom formats: Aseprite animations, etc.
|
- Custom formats: Aseprite animations, etc.
|
||||||
|
|
||||||
### Developer Tools
|
### Developer Tools
|
||||||
- Built-in documentation system with `prosperon.DOC`
|
- Built-in documentation system with `cell.DOC`
|
||||||
- Tracy profiler integration for performance monitoring
|
- Tracy profiler integration for performance monitoring
|
||||||
- Imgui debugging tools
|
- Imgui debugging tools
|
||||||
- Console logging with various severity levels
|
- Console logging with various severity levels
|
||||||
|
|||||||
10
Makefile
@@ -1,22 +1,22 @@
|
|||||||
debug: FORCE
|
debug: FORCE
|
||||||
meson setup build_dbg -Dbuildtype=debug
|
meson setup build_dbg -Dbuildtype=debug
|
||||||
meson compile -C build_dbg
|
meson install -C build_dbg
|
||||||
|
|
||||||
fast: FORCE
|
fast: FORCE
|
||||||
meson setup build_fast
|
meson setup build_fast
|
||||||
meson compile -C build_fast
|
meson install -C build_fast
|
||||||
|
|
||||||
release: FORCE
|
release: FORCE
|
||||||
meson setup -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true build_release
|
meson setup -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true build_release
|
||||||
meson compile -C build_release
|
meson install -C build_release
|
||||||
|
|
||||||
sanitize: FORCE
|
sanitize: FORCE
|
||||||
meson setup -Db_sanitize=address -Db_sanitize=memory -Db_sanitize=leak -Db_sanitize=undefined build_sani
|
meson setup -Db_sanitize=address -Db_sanitize=memory -Db_sanitize=leak -Db_sanitize=undefined build_sani
|
||||||
meson compile -C build_sani
|
meson install -C build_sani
|
||||||
|
|
||||||
small: FORCE
|
small: FORCE
|
||||||
meson setup -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true build_small
|
meson setup -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true build_small
|
||||||
meson compile -C build_small
|
meson install -C build_small
|
||||||
|
|
||||||
web: FORCE
|
web: FORCE
|
||||||
meson setup -Deditor=false -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true --cross-file emscripten.cross build_web
|
meson setup -Deditor=false -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true --cross-file emscripten.cross build_web
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Provides a consistent way to create documentation for prosperon elements. Objects are documented by adding docstrings directly to object-like things (functions, objects, ...), or to an object's own "doc object".
|
Provides a consistent way to create documentation for prosperon elements. Objects are documented by adding docstrings directly to object-like things (functions, objects, ...), or to an object's own "doc object".
|
||||||
|
|
||||||
Docstrings are set to the symbol `prosperon.DOC`
|
Docstrings are set to the symbol `cell.DOC`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Suppose we have a module that returns a function
|
// Suppose we have a module that returns a function
|
||||||
@@ -24,9 +24,9 @@ var greet = {
|
|||||||
hello() { log.console('hello!') }
|
hello() { log.console('hello!') }
|
||||||
}
|
}
|
||||||
|
|
||||||
greet[prosperon.DOC] = {}
|
greet[cell.DOC] = {}
|
||||||
greet[prosperon.DOC][prosperon.DOC] = 'An object full of different greeter functions'
|
greet[cell.DOC][cell.DOC] = 'An object full of different greeter functions'
|
||||||
greet[prosperon.DOC].hello = 'A greeter that says, "hello!"'
|
greet[cell.DOC].hello = 'A greeter that says, "hello!"'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,6 @@ this.delay(_ => {
|
|||||||
The global object called `prosperon` has a variety of engine specific settings on it that can be set to influence how the engine behaves. For example, `prosperon.argv` contains a list of the command line arguments given to prosperon; `prosperon.PATH` is an array of paths to resolve resources such as modules and images. `prosperon` is fully documented in the API section.
|
The global object called `prosperon` has a variety of engine specific settings on it that can be set to influence how the engine behaves. For example, `prosperon.argv` contains a list of the command line arguments given to prosperon; `prosperon.PATH` is an array of paths to resolve resources such as modules and images. `prosperon` is fully documented in the API section.
|
||||||
|
|
||||||
## Getting help
|
## Getting help
|
||||||
The `prosperon` global has a 'doc' function, which can be invoked on any engine object to see a description of it and its members. For example, to learn about `prosperon`, try printing out `prosperon.doc(prosperon)` in your `main.js`.
|
The `prosperon` global has a 'doc' function, which can be invoked on any engine object to see a description of it and its members. For example, to learn about `prosperon`, try printing out `cell.DOC(prosperon)` in your `main.js`.
|
||||||
|
|
||||||
Writing documentation for your own modules and game components will be explored in the chapter on actors & modules.
|
Writing documentation for your own modules and game components will be explored in the chapter on actors & modules.
|
||||||
242
meson.build
@@ -1,4 +1,4 @@
|
|||||||
project('prosperon', ['c', 'cpp'],
|
project('cell', ['c', 'cpp'],
|
||||||
version: '0.9.3',
|
version: '0.9.3',
|
||||||
meson_version: '>=1.4',
|
meson_version: '>=1.4',
|
||||||
default_options : [ 'cpp_std=c++11'])
|
default_options : [ 'cpp_std=c++11'])
|
||||||
@@ -13,21 +13,21 @@ fs = import('fs')
|
|||||||
add_project_arguments('-pedantic', language: ['c'])
|
add_project_arguments('-pedantic', language: ['c'])
|
||||||
|
|
||||||
git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false)
|
git_tag_cmd = run_command('git', 'describe', '--tags', '--abbrev=0', check: false)
|
||||||
prosperon_version = 'unknown'
|
cell_version = 'unknown'
|
||||||
if git_tag_cmd.returncode() == 0
|
if git_tag_cmd.returncode() == 0
|
||||||
prosperon_version = git_tag_cmd.stdout().strip()
|
cell_version = git_tag_cmd.stdout().strip()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
git_commit_cmd = run_command('git', 'rev-parse', '--short', 'HEAD', check: false)
|
git_commit_cmd = run_command('git', 'rev-parse', '--short', 'HEAD', check: false)
|
||||||
prosperon_commit = 'unknown'
|
cell_commit = 'unknown'
|
||||||
if git_commit_cmd.returncode() == 0
|
if git_commit_cmd.returncode() == 0
|
||||||
prosperon_commit = git_commit_cmd.stdout().strip()
|
cell_commit = git_commit_cmd.stdout().strip()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Important: pass the definitions without double-escaping quotes
|
# Important: pass the definitions without double-escaping quotes
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
'-DPROSPERON_VERSION="' + prosperon_version + '"',
|
'-DCELL_VERSION="' + cell_version + '"',
|
||||||
'-DPROSPERON_COMMIT="' + prosperon_commit + '"',
|
'-DCELL_COMMIT="' + cell_commit + '"',
|
||||||
language : 'c'
|
language : 'c'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -67,21 +67,31 @@ endif
|
|||||||
|
|
||||||
cmake = import('cmake')
|
cmake = import('cmake')
|
||||||
|
|
||||||
mbedtls_opts = cmake.subproject_options()
|
# Try to find system-installed mbedtls first
|
||||||
mbedtls_opts.add_cmake_defines({
|
mbedtls_dep = dependency('mbedtls', static: true, required: false)
|
||||||
'ENABLE_PROGRAMS': 'OFF', # Disable Mbed TLS programs
|
mbedx509_dep = dependency('mbedx509', static: true, required: false)
|
||||||
'ENABLE_TESTING': 'OFF', # Disable Mbed TLS tests
|
mbedcrypto_dep = dependency('mbedcrypto', static: true, required: false)
|
||||||
'CMAKE_BUILD_TYPE': 'Release', # Optimize for release
|
|
||||||
'MBEDTLS_FATAL_WARNINGS': 'ON', # Treat warnings as errors
|
if not mbedtls_dep.found() or not mbedx509_dep.found() or not mbedcrypto_dep.found()
|
||||||
'USE_STATIC_MBEDTLS_LIBRARY': 'ON',# Build static libraries
|
message('⚙ System mbedtls not found, building subproject...')
|
||||||
'USE_SHARED_MBEDTLS_LIBRARY': 'OFF'# Disable shared libraries
|
mbedtls_opts = cmake.subproject_options()
|
||||||
})
|
mbedtls_opts.add_cmake_defines({
|
||||||
mbedtls_proj = cmake.subproject('mbedtls', options: mbedtls_opts)
|
'ENABLE_PROGRAMS': 'OFF', # Disable Mbed TLS programs
|
||||||
deps += [
|
'ENABLE_TESTING': 'OFF', # Disable Mbed TLS tests
|
||||||
mbedtls_proj.dependency('mbedtls'),
|
'CMAKE_BUILD_TYPE': 'Release', # Optimize for release
|
||||||
mbedtls_proj.dependency('mbedx509'),
|
'MBEDTLS_FATAL_WARNINGS': 'ON', # Treat warnings as errors
|
||||||
mbedtls_proj.dependency('mbedcrypto')
|
'USE_STATIC_MBEDTLS_LIBRARY': 'ON',# Build static libraries
|
||||||
]
|
'USE_SHARED_MBEDTLS_LIBRARY': 'OFF'# Disable shared libraries
|
||||||
|
})
|
||||||
|
mbedtls_proj = cmake.subproject('mbedtls', options: mbedtls_opts)
|
||||||
|
deps += [
|
||||||
|
mbedtls_proj.dependency('mbedtls'),
|
||||||
|
mbedtls_proj.dependency('mbedx509'),
|
||||||
|
mbedtls_proj.dependency('mbedcrypto')
|
||||||
|
]
|
||||||
|
else
|
||||||
|
deps += [mbedtls_dep, mbedx509_dep, mbedcrypto_dep]
|
||||||
|
endif
|
||||||
|
|
||||||
sdl3_opts = cmake.subproject_options()
|
sdl3_opts = cmake.subproject_options()
|
||||||
sdl3_opts.add_cmake_defines({
|
sdl3_opts.add_cmake_defines({
|
||||||
@@ -130,33 +140,111 @@ if host_machine.system() == 'emscripten'
|
|||||||
method : 'pkg-config', # or 'cmake' if you prefer
|
method : 'pkg-config', # or 'cmake' if you prefer
|
||||||
required : true)
|
required : true)
|
||||||
else
|
else
|
||||||
sdl3_proj = cmake.subproject('sdl3', options : sdl3_opts)
|
# Try to find system-installed SDL3 first
|
||||||
deps += sdl3_proj.dependency('SDL3-static')
|
sdl3_dep = dependency('sdl3', static: true, required: false)
|
||||||
|
|
||||||
|
if not sdl3_dep.found()
|
||||||
|
message('⚙ System SDL3 not found, building subproject...')
|
||||||
|
sdl3_proj = cmake.subproject('sdl3', options : sdl3_opts)
|
||||||
|
deps += sdl3_proj.dependency('SDL3-static')
|
||||||
|
else
|
||||||
|
deps += sdl3_dep
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
quickjs_opts = []
|
quickjs_opts = []
|
||||||
|
|
||||||
quickjs_opts += 'default_library=static'
|
quickjs_opts += 'default_library=static'
|
||||||
deps += dependency('quickjs', static:true, default_options:quickjs_opts)
|
|
||||||
deps += dependency('qjs-layout', static:true)
|
# Try to find system-installed quickjs first
|
||||||
deps += dependency('qjs-miniz', static:true)
|
quickjs_dep = dependency('quickjs', static: true, required: false)
|
||||||
deps += dependency('physfs', static:true)
|
if not quickjs_dep.found()
|
||||||
|
message('⚙ System quickjs not found, building subproject...')
|
||||||
|
deps += dependency('quickjs', static:true, default_options:quickjs_opts)
|
||||||
|
else
|
||||||
|
deps += quickjs_dep
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to find system-installed qjs-layout first
|
||||||
|
qjs_layout_dep = dependency('qjs-layout', static: true, required: false)
|
||||||
|
if not qjs_layout_dep.found()
|
||||||
|
message('⚙ System qjs-layout not found, building subproject...')
|
||||||
|
deps += dependency('qjs-layout', static:true)
|
||||||
|
else
|
||||||
|
deps += qjs_layout_dep
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to find system-installed qjs-miniz first
|
||||||
|
qjs_miniz_dep = dependency('qjs-miniz', static: true, required: false)
|
||||||
|
if not qjs_miniz_dep.found()
|
||||||
|
message('⚙ System qjs-miniz not found, building subproject...')
|
||||||
|
deps += dependency('qjs-miniz', static:true)
|
||||||
|
else
|
||||||
|
deps += qjs_miniz_dep
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to find system-installed physfs first
|
||||||
|
physfs_dep = dependency('physfs', static: true, required: false)
|
||||||
|
if not physfs_dep.found()
|
||||||
|
message('⚙ System physfs not found, building subproject...')
|
||||||
|
deps += dependency('physfs', static:true)
|
||||||
|
else
|
||||||
|
deps += physfs_dep
|
||||||
|
endif
|
||||||
|
|
||||||
deps += dependency('threads')
|
deps += dependency('threads')
|
||||||
deps += dependency('chipmunk', static:true)
|
|
||||||
|
# Try to find system-installed chipmunk first
|
||||||
|
chipmunk_dep = dependency('chipmunk', static: true, required: false)
|
||||||
|
if not chipmunk_dep.found()
|
||||||
|
message('⚙ System chipmunk not found, building subproject...')
|
||||||
|
deps += dependency('chipmunk', static:true)
|
||||||
|
else
|
||||||
|
deps += chipmunk_dep
|
||||||
|
endif
|
||||||
|
|
||||||
if host_machine.system() != 'emscripten'
|
if host_machine.system() != 'emscripten'
|
||||||
deps += dependency('enet', static:true)
|
# Try to find system-installed enet first
|
||||||
|
enet_dep = dependency('enet', static: true, required: false)
|
||||||
|
if not enet_dep.found()
|
||||||
|
message('⚙ System enet not found, building subproject...')
|
||||||
|
deps += dependency('enet', static:true)
|
||||||
|
else
|
||||||
|
deps += enet_dep
|
||||||
|
endif
|
||||||
src += 'qjs_enet.c'
|
src += 'qjs_enet.c'
|
||||||
|
|
||||||
tracy_opts = ['fibers=true', 'no_exit=true', 'libunwind_backtrace=true']
|
tracy_opts = ['fibers=true', 'no_exit=true', 'libunwind_backtrace=true']
|
||||||
add_project_arguments('-DTRACY_ENABLE', language:['c','cpp'])
|
add_project_arguments('-DTRACY_ENABLE', language:['c','cpp'])
|
||||||
deps += dependency('tracy', static:true, default_options:tracy_opts)
|
|
||||||
|
# Try to find system-installed tracy first
|
||||||
|
tracy_dep = dependency('tracy', static: true, required: false)
|
||||||
|
if not tracy_dep.found()
|
||||||
|
message('⚙ System tracy not found, building subproject...')
|
||||||
|
deps += dependency('tracy', static:true, default_options:tracy_opts)
|
||||||
|
else
|
||||||
|
deps += tracy_dep
|
||||||
|
endif
|
||||||
|
|
||||||
src += 'qjs_dmon.c'
|
src += 'qjs_dmon.c'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
deps += dependency('soloud', static:true)
|
# Try to find system-installed soloud first
|
||||||
deps += dependency('libqrencode', static:true)
|
soloud_dep = dependency('soloud', static: true, required: false)
|
||||||
|
if not soloud_dep.found()
|
||||||
|
message('⚙ System soloud not found, building subproject...')
|
||||||
|
deps += dependency('soloud', static:true)
|
||||||
|
else
|
||||||
|
deps += soloud_dep
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Try to find system-installed qrencode first
|
||||||
|
qr_dep = dependency('qrencode', static: true, required: false)
|
||||||
|
if not qr_dep.found()
|
||||||
|
message('⚙ System qrencode not found, building subproject...')
|
||||||
|
deps += dependency('libqrencode', static:true)
|
||||||
|
else
|
||||||
|
deps += qr_dep
|
||||||
|
endif
|
||||||
|
|
||||||
# Storefront SDK support
|
# Storefront SDK support
|
||||||
storefront = get_option('storefront')
|
storefront = get_option('storefront')
|
||||||
@@ -193,7 +281,7 @@ link_args = link
|
|||||||
sources = []
|
sources = []
|
||||||
src += [
|
src += [
|
||||||
'anim.c', 'config.c', 'datastream.c','font.c','HandmadeMath.c','jsffi.c','model.c',
|
'anim.c', 'config.c', 'datastream.c','font.c','HandmadeMath.c','jsffi.c','model.c',
|
||||||
'render.c','simplex.c','spline.c', 'transform.c','prosperon.c', 'wildmatch.c',
|
'render.c','simplex.c','spline.c', 'transform.c','cell.c', 'wildmatch.c',
|
||||||
'sprite.c', 'rtree.c', 'qjs_nota.c', 'qjs_soloud.c', 'qjs_sdl.c', 'qjs_sdl_video.c', 'qjs_sdl_surface.c', 'qjs_math.c', 'qjs_geometry.c', 'qjs_transform.c', 'qjs_sprite.c', 'qjs_io.c', 'qjs_fd.c', 'qjs_os.c', 'qjs_actor.c',
|
'sprite.c', 'rtree.c', 'qjs_nota.c', 'qjs_soloud.c', 'qjs_sdl.c', 'qjs_sdl_video.c', 'qjs_sdl_surface.c', 'qjs_math.c', 'qjs_geometry.c', 'qjs_transform.c', 'qjs_sprite.c', 'qjs_io.c', 'qjs_fd.c', 'qjs_os.c', 'qjs_actor.c',
|
||||||
'qjs_qr.c', 'qjs_wota.c', 'monocypher.c', 'qjs_blob.c', 'qjs_crypto.c', 'qjs_time.c', 'qjs_http.c', 'qjs_rtree.c', 'qjs_spline.c', 'qjs_js.c', 'qjs_debug.c'
|
'qjs_qr.c', 'qjs_wota.c', 'monocypher.c', 'qjs_blob.c', 'qjs_crypto.c', 'qjs_time.c', 'qjs_http.c', 'qjs_rtree.c', 'qjs_spline.c', 'qjs_js.c', 'qjs_debug.c'
|
||||||
]
|
]
|
||||||
@@ -222,87 +310,33 @@ foreach file : src
|
|||||||
sources += files(full_path)
|
sources += files(full_path)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
if get_option('editor')
|
|
||||||
# sources += 'source/qjs_imgui.cpp'
|
|
||||||
# foreach imgui : imsrc
|
|
||||||
# sources += tp / 'imgui' / imgui
|
|
||||||
# endforeach
|
|
||||||
endif
|
|
||||||
|
|
||||||
includers = []
|
includers = []
|
||||||
foreach inc : includes
|
foreach inc : includes
|
||||||
includers += include_directories(inc)
|
includers += include_directories(inc)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
zip_folders = ['scripts', 'fonts', 'icons']
|
|
||||||
zip_paths = []
|
|
||||||
foreach folder: zip_folders
|
|
||||||
zip_paths += meson.project_source_root() / folder
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
# Produce core.zip
|
|
||||||
core = custom_target('core.zip',
|
|
||||||
output : 'core.zip',
|
|
||||||
command : ['sh', '-c',
|
|
||||||
'cd ' + meson.project_source_root() +
|
|
||||||
' && echo "Rebuilding core.zip" && rm -f ' + meson.current_build_dir() + '/core.zip && ' +
|
|
||||||
'zip -r ' + meson.current_build_dir() + '/core.zip scripts fonts icons'
|
|
||||||
],
|
|
||||||
build_always_stale: true,
|
|
||||||
build_by_default: true
|
|
||||||
)
|
|
||||||
|
|
||||||
prosperon_raw = executable('prosperon_raw', sources,
|
|
||||||
dependencies: deps,
|
|
||||||
include_directories: includers,
|
|
||||||
link_args: link,
|
|
||||||
build_rpath: '$ORIGIN',
|
|
||||||
install:false
|
|
||||||
)
|
|
||||||
|
|
||||||
strip_enabled = ['release', 'minsize'].contains(get_option('buildtype'))
|
|
||||||
|
|
||||||
if strip_enabled
|
|
||||||
prosperon_raw_stripped = custom_target('prosperon_raw_stripped',
|
|
||||||
input: prosperon_raw,
|
|
||||||
output: 'prosperon_raw_stripped',
|
|
||||||
command: [
|
|
||||||
'sh', '-c',
|
|
||||||
'strip "$1" && cp "$1" "$2"',
|
|
||||||
'stripper',
|
|
||||||
'@INPUT@',
|
|
||||||
'@OUTPUT@'
|
|
||||||
],
|
|
||||||
build_by_default: true
|
|
||||||
)
|
|
||||||
exe_for_concat = prosperon_raw_stripped
|
|
||||||
else
|
|
||||||
exe_for_concat = prosperon_raw
|
|
||||||
endif
|
|
||||||
|
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
exe_ext = '.exe'
|
exe_ext = '.exe'
|
||||||
else
|
else
|
||||||
exe_ext = ''
|
exe_ext = ''
|
||||||
endif
|
endif
|
||||||
|
|
||||||
prosperon = custom_target('prosperon',
|
strip_enabled = ['release', 'minsize'].contains(get_option('buildtype'))
|
||||||
output: 'prosperon' + exe_ext,
|
|
||||||
input: [exe_for_concat, core],
|
if strip_enabled
|
||||||
command: [
|
add_project_link_arguments('-s', language: ['c', 'cpp'])
|
||||||
'sh', '-c',
|
endif
|
||||||
'cat "$1" "$2" > "$3" && chmod +x "$3" >/dev/null 2>&1',
|
|
||||||
'concat',
|
cell = executable('cell', sources,
|
||||||
'@INPUT0@',
|
dependencies: deps,
|
||||||
'@INPUT1@',
|
include_directories: includers,
|
||||||
'@OUTPUT@'
|
link_args: link,
|
||||||
],
|
build_rpath: '$ORIGIN',
|
||||||
build_always_stale: true,
|
install: true
|
||||||
build_by_default: true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
prosperon_dep = declare_dependency(
|
cell_dep = declare_dependency(
|
||||||
link_with: prosperon
|
link_with: cell
|
||||||
)
|
)
|
||||||
|
|
||||||
copy_tests = custom_target(
|
copy_tests = custom_target(
|
||||||
@@ -329,5 +363,5 @@ tests = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
foreach file : tests
|
foreach file : tests
|
||||||
test(file, prosperon_raw, args:['tests/' + file + '.js'], depends:copy_tests)
|
test(file, cell, args:['tests/' + file + '.js'], depends:copy_tests)
|
||||||
endforeach
|
endforeach
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
var spline = this
|
|
||||||
|
|
||||||
spline.catmull[prosperon.DOC] = "Perform Catmull-Rom spline sampling on an array of 2D points, returning an array of samples."
|
|
||||||
spline.bezier[prosperon.DOC] = "Perform a Bezier spline (or catmull) sampling on 2D points, returning an array of sampled points."
|
|
||||||
|
|
||||||
return spline
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
var video = this
|
|
||||||
|
|
||||||
video.make_video[prosperon.DOC] = "Decode a video file (MPEG, etc.) from an ArrayBuffer, returning a datastream object."
|
|
||||||
|
|
||||||
return video
|
|
||||||
@@ -2,7 +2,7 @@ var math = use('math')
|
|||||||
var color = use('color')
|
var color = use('color')
|
||||||
|
|
||||||
var draw = {}
|
var draw = {}
|
||||||
draw[prosperon.DOC] = `
|
draw[cell.DOC] = `
|
||||||
A collection of 2D drawing functions that create drawing command lists.
|
A collection of 2D drawing functions that create drawing command lists.
|
||||||
These are pure functions that return plain JavaScript objects representing
|
These are pure functions that return plain JavaScript objects representing
|
||||||
drawing operations. No rendering or actor communication happens here.
|
drawing operations. No rendering or actor communication happens here.
|
||||||
@@ -115,7 +115,7 @@ draw.point = function(pos, size, opt = {}, material) {
|
|||||||
material: material
|
material: material
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
draw.point[prosperon.DOC] = `
|
draw.point[cell.DOC] = `
|
||||||
:param pos: A 2D position ([x, y]) where the point should be drawn.
|
:param pos: A 2D position ([x, y]) where the point should be drawn.
|
||||||
:param size: The size of the point.
|
:param size: The size of the point.
|
||||||
:param opt: Optional geometry properties.
|
:param opt: Optional geometry properties.
|
||||||
|
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
|
Before Width: | Height: | Size: 438 B After Width: | Height: | Size: 438 B |
|
Before Width: | Height: | Size: 398 B After Width: | Height: | Size: 398 B |
|
Before Width: | Height: | Size: 337 B After Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 390 B |
|
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 376 B After Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 381 B |
|
Before Width: | Height: | Size: 313 B After Width: | Height: | Size: 313 B |
|
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
|
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 378 B |
@@ -1,5 +1,5 @@
|
|||||||
var geometry = this
|
var geometry = this
|
||||||
geometry[prosperon.DOC] = `
|
geometry[cell.DOC] = `
|
||||||
A collection of geometry-related functions for circles, spheres, boxes, polygons,
|
A collection of geometry-related functions for circles, spheres, boxes, polygons,
|
||||||
and rectangle utilities. Some functionality is implemented in C and exposed here.
|
and rectangle utilities. Some functionality is implemented in C and exposed here.
|
||||||
`
|
`
|
||||||
@@ -7,7 +7,7 @@ and rectangle utilities. Some functionality is implemented in C and exposed here
|
|||||||
var math = use('math')
|
var math = use('math')
|
||||||
|
|
||||||
geometry.box = {}
|
geometry.box = {}
|
||||||
geometry.box[prosperon.DOC] = `
|
geometry.box[cell.DOC] = `
|
||||||
An object for box-related operations. Overridden later by a function definition, so
|
An object for box-related operations. Overridden later by a function definition, so
|
||||||
its direct usage is overshadowed. Contains:
|
its direct usage is overshadowed. Contains:
|
||||||
- points(ll, ur): Return an array of four 2D points for a box from ll (lower-left) to ur (upper-right).
|
- points(ll, ur): Return an array of four 2D points for a box from ll (lower-left) to ur (upper-right).
|
||||||
@@ -16,7 +16,7 @@ its direct usage is overshadowed. Contains:
|
|||||||
geometry.box.points = function (ll, ur) {
|
geometry.box.points = function (ll, ur) {
|
||||||
return [ll, ll.add([ur.x - ll.x, 0]), ur, ll.add([0, ur.y - ll.y])]
|
return [ll, ll.add([ur.x - ll.x, 0]), ur, ll.add([0, ur.y - ll.y])]
|
||||||
}
|
}
|
||||||
geometry.box.points[prosperon.DOC] = `
|
geometry.box.points[cell.DOC] = `
|
||||||
:param ll: Lower-left coordinate as a 2D vector (x,y).
|
:param ll: Lower-left coordinate as a 2D vector (x,y).
|
||||||
:param ur: Upper-right coordinate as a 2D vector (x,y).
|
:param ur: Upper-right coordinate as a 2D vector (x,y).
|
||||||
:return: An array of four points forming the corners of the box in order [ll, lower-right, ur, upper-left].
|
:return: An array of four points forming the corners of the box in order [ll, lower-right, ur, upper-left].
|
||||||
@@ -24,14 +24,14 @@ Compute the four corners of a box given lower-left and upper-right corners.
|
|||||||
`
|
`
|
||||||
|
|
||||||
geometry.sphere = {}
|
geometry.sphere = {}
|
||||||
geometry.sphere[prosperon.DOC] = `
|
geometry.sphere[cell.DOC] = `
|
||||||
Sphere-related geometry functions:
|
Sphere-related geometry functions:
|
||||||
- volume(r): Return the volume of a sphere with radius r.
|
- volume(r): Return the volume of a sphere with radius r.
|
||||||
- random(r, theta, phi): Return a random point on or inside a sphere.
|
- random(r, theta, phi): Return a random point on or inside a sphere.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.circle = {}
|
geometry.circle = {}
|
||||||
geometry.circle[prosperon.DOC] = `
|
geometry.circle[cell.DOC] = `
|
||||||
Circle-related geometry functions:
|
Circle-related geometry functions:
|
||||||
- area(r): Return the area of a circle with radius r.
|
- area(r): Return the area of a circle with radius r.
|
||||||
- random(r, theta): Return a random 2D point on a circle; uses sphere.random internally and extracts x,z.
|
- random(r, theta): Return a random 2D point on a circle; uses sphere.random internally and extracts x,z.
|
||||||
@@ -40,7 +40,7 @@ Circle-related geometry functions:
|
|||||||
geometry.sphere.volume = function (r) {
|
geometry.sphere.volume = function (r) {
|
||||||
return (Math.pi * r * r * r * 4) / 3
|
return (Math.pi * r * r * r * 4) / 3
|
||||||
}
|
}
|
||||||
geometry.sphere.volume[prosperon.DOC] = `
|
geometry.sphere.volume[cell.DOC] = `
|
||||||
:param r: The sphere radius.
|
:param r: The sphere radius.
|
||||||
:return: The volume of the sphere, calculated as (4/3) * pi * r^3.
|
:return: The volume of the sphere, calculated as (4/3) * pi * r^3.
|
||||||
`
|
`
|
||||||
@@ -55,7 +55,7 @@ geometry.sphere.random = function (r, theta = [0, 1], phi = [-0.5, 0.5]) {
|
|||||||
var pa = Math.turn2rad(Math.random_range(phi[0], phi[1]))
|
var pa = Math.turn2rad(Math.random_range(phi[0], phi[1]))
|
||||||
return [ra * Math.sin(ta) * Math.cos(pa), ra * Math.sin(ta) * Math.sin(pa), ra * Math.cos(ta)]
|
return [ra * Math.sin(ta) * Math.cos(pa), ra * Math.sin(ta) * Math.sin(pa), ra * Math.cos(ta)]
|
||||||
}
|
}
|
||||||
geometry.sphere.random[prosperon.DOC] = `
|
geometry.sphere.random[cell.DOC] = `
|
||||||
:param r: A single number (radius) or a 2-element array [minRadius, maxRadius].
|
:param r: A single number (radius) or a 2-element array [minRadius, maxRadius].
|
||||||
:param theta: A single number or 2-element array defining the range in turns for the theta angle, default [0,1].
|
:param theta: A single number or 2-element array defining the range in turns for the theta angle, default [0,1].
|
||||||
:param phi: A single number or 2-element array defining the range in turns for the phi angle, default [-0.5,0.5].
|
:param phi: A single number or 2-element array defining the range in turns for the phi angle, default [-0.5,0.5].
|
||||||
@@ -66,7 +66,7 @@ Generate a random point inside a sphere of variable radius, distributing angles
|
|||||||
geometry.circle.area = function (r) {
|
geometry.circle.area = function (r) {
|
||||||
return Math.pi * r * r
|
return Math.pi * r * r
|
||||||
}
|
}
|
||||||
geometry.circle.area[prosperon.DOC] = `
|
geometry.circle.area[cell.DOC] = `
|
||||||
:param r: Radius of the circle.
|
:param r: Radius of the circle.
|
||||||
:return: The area, pi * r^2.
|
:return: The area, pi * r^2.
|
||||||
`
|
`
|
||||||
@@ -74,7 +74,7 @@ geometry.circle.area[prosperon.DOC] = `
|
|||||||
geometry.circle.random = function (r, theta) {
|
geometry.circle.random = function (r, theta) {
|
||||||
return geometry.sphere.random(r, theta).xz
|
return geometry.sphere.random(r, theta).xz
|
||||||
}
|
}
|
||||||
geometry.circle.random[prosperon.DOC] = `
|
geometry.circle.random[cell.DOC] = `
|
||||||
:param r: A radius or [minRadius, maxRadius].
|
:param r: A radius or [minRadius, maxRadius].
|
||||||
:param theta: Angle range in turns (single number or [min,max]).
|
:param theta: Angle range in turns (single number or [min,max]).
|
||||||
:return: A 2D point (x,z) in the circle, using the sphere random generator and ignoring y.
|
:return: A 2D point (x,z) in the circle, using the sphere random generator and ignoring y.
|
||||||
@@ -91,7 +91,7 @@ geometry.box = function (w, h) {
|
|||||||
]
|
]
|
||||||
return points
|
return points
|
||||||
}
|
}
|
||||||
geometry.box[prosperon.DOC] = `
|
geometry.box[cell.DOC] = `
|
||||||
:param w: The width of the box.
|
:param w: The width of the box.
|
||||||
:param h: The height of the box.
|
:param h: The height of the box.
|
||||||
:return: An array of four 2D points representing the corners of a rectangle centered at [0,0].
|
:return: An array of four 2D points representing the corners of a rectangle centered at [0,0].
|
||||||
@@ -101,7 +101,7 @@ Construct a box centered at the origin with the given width and height. This ove
|
|||||||
geometry.ngon = function (radius, n) {
|
geometry.ngon = function (radius, n) {
|
||||||
return geometry.arc(radius, 360, n)
|
return geometry.arc(radius, 360, n)
|
||||||
}
|
}
|
||||||
geometry.ngon[prosperon.DOC] = `
|
geometry.ngon[cell.DOC] = `
|
||||||
:param radius: The radius of the n-gon from center to each vertex.
|
:param radius: The radius of the n-gon from center to each vertex.
|
||||||
:param n: Number of sides/vertices.
|
:param n: Number of sides/vertices.
|
||||||
:return: An array of 2D points forming a regular n-gon.
|
:return: An array of 2D points forming a regular n-gon.
|
||||||
@@ -118,7 +118,7 @@ geometry.arc = function (radius, angle, n, start = 0) {
|
|||||||
for (var i = 0; i < n; i++) points.push(math.rotate([radius, 0], start + arclen * i))
|
for (var i = 0; i < n; i++) points.push(math.rotate([radius, 0], start + arclen * i))
|
||||||
return points
|
return points
|
||||||
}
|
}
|
||||||
geometry.arc[prosperon.DOC] = `
|
geometry.arc[cell.DOC] = `
|
||||||
:param radius: The distance from center to the arc points.
|
:param radius: The distance from center to the arc points.
|
||||||
:param angle: The total angle (in degrees) over which points are generated, capped at 360.
|
:param angle: The total angle (in degrees) over which points are generated, capped at 360.
|
||||||
:param n: Number of segments (if <=1, empty array is returned).
|
:param n: Number of segments (if <=1, empty array is returned).
|
||||||
@@ -131,7 +131,7 @@ geometry.circle.points = function (radius, n) {
|
|||||||
if (n <= 1) return []
|
if (n <= 1) return []
|
||||||
return geometry.arc(radius, 360, n)
|
return geometry.arc(radius, 360, n)
|
||||||
}
|
}
|
||||||
geometry.circle.points[prosperon.DOC] = `
|
geometry.circle.points[cell.DOC] = `
|
||||||
:param radius: The circle's radius.
|
:param radius: The circle's radius.
|
||||||
:param n: Number of points around the circle.
|
:param n: Number of points around the circle.
|
||||||
:return: An array of 2D points equally spaced around a full 360-degree circle.
|
:return: An array of 2D points equally spaced around a full 360-degree circle.
|
||||||
@@ -141,7 +141,7 @@ Shortcut for geometry.arc(radius, 360, n).
|
|||||||
geometry.corners2points = function (ll, ur) {
|
geometry.corners2points = function (ll, ur) {
|
||||||
return [ll, ll.add([ur.x, 0]), ur, ll.add([0, ur.y])]
|
return [ll, ll.add([ur.x, 0]), ur, ll.add([0, ur.y])]
|
||||||
}
|
}
|
||||||
geometry.corners2points[prosperon.DOC] = `
|
geometry.corners2points[cell.DOC] = `
|
||||||
:param ll: Lower-left 2D coordinate.
|
:param ll: Lower-left 2D coordinate.
|
||||||
:param ur: Upper-right 2D coordinate (relative offset in x,y).
|
:param ur: Upper-right 2D coordinate (relative offset in x,y).
|
||||||
:return: A four-point array of corners [ll, lower-right, upper-right, upper-left].
|
:return: A four-point array of corners [ll, lower-right, upper-right, upper-left].
|
||||||
@@ -158,7 +158,7 @@ geometry.sortpointsccw = function (points) {
|
|||||||
})
|
})
|
||||||
return ccw.map(function (x) { return x.add(cm) })
|
return ccw.map(function (x) { return x.add(cm) })
|
||||||
}
|
}
|
||||||
geometry.sortpointsccw[prosperon.DOC] = `
|
geometry.sortpointsccw[cell.DOC] = `
|
||||||
:param points: An array of 2D points.
|
:param points: An array of 2D points.
|
||||||
:return: A new array of the same points, sorted counterclockwise around their centroid.
|
:return: A new array of the same points, sorted counterclockwise around their centroid.
|
||||||
Sort an array of points in CCW order based on their angles from the centroid.
|
Sort an array of points in CCW order based on their angles from the centroid.
|
||||||
@@ -185,61 +185,61 @@ geometry.points2cm = function(points) {
|
|||||||
})
|
})
|
||||||
return [x / n, y / n]
|
return [x / n, y / n]
|
||||||
}
|
}
|
||||||
geometry.points2cm[prosperon.DOC] = `
|
geometry.points2cm[cell.DOC] = `
|
||||||
:param points: An array of 2D points.
|
:param points: An array of 2D points.
|
||||||
:return: The centroid (average x,y) of the given points.
|
:return: The centroid (average x,y) of the given points.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_intersection[prosperon.DOC] = `
|
geometry.rect_intersection[cell.DOC] = `
|
||||||
:param a: The first rectangle as {x, y, w, h}.
|
:param a: The first rectangle as {x, y, w, h}.
|
||||||
:param b: The second rectangle as {x, y, w, h}.
|
:param b: The second rectangle as {x, y, w, h}.
|
||||||
:return: A rectangle that is the intersection of the two. May have zero width/height if no overlap.
|
:return: A rectangle that is the intersection of the two. May have zero width/height if no overlap.
|
||||||
Return the intersection of two rectangles. The result may be empty if no intersection.
|
Return the intersection of two rectangles. The result may be empty if no intersection.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_intersects[prosperon.DOC] = `
|
geometry.rect_intersects[cell.DOC] = `
|
||||||
:param a: Rectangle {x,y,w,h}.
|
:param a: Rectangle {x,y,w,h}.
|
||||||
:param b: Rectangle {x,y,w,h}.
|
:param b: Rectangle {x,y,w,h}.
|
||||||
:return: A boolean indicating whether the two rectangles overlap.
|
:return: A boolean indicating whether the two rectangles overlap.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_expand[prosperon.DOC] = `
|
geometry.rect_expand[cell.DOC] = `
|
||||||
:param a: Rectangle {x,y,w,h}.
|
:param a: Rectangle {x,y,w,h}.
|
||||||
:param b: Rectangle {x,y,w,h}.
|
:param b: Rectangle {x,y,w,h}.
|
||||||
:return: A new rectangle that covers the bounds of both input rectangles.
|
:return: A new rectangle that covers the bounds of both input rectangles.
|
||||||
Merge or combine two rectangles, returning their bounding rectangle.
|
Merge or combine two rectangles, returning their bounding rectangle.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_inside[prosperon.DOC] = `
|
geometry.rect_inside[cell.DOC] = `
|
||||||
:param inner: A rectangle to test.
|
:param inner: A rectangle to test.
|
||||||
:param outer: A rectangle that may contain 'inner'.
|
:param outer: A rectangle that may contain 'inner'.
|
||||||
:return: True if 'inner' is completely inside 'outer', otherwise false.
|
:return: True if 'inner' is completely inside 'outer', otherwise false.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_random[prosperon.DOC] = `
|
geometry.rect_random[cell.DOC] = `
|
||||||
:param rect: A rectangle {x,y,w,h}.
|
:param rect: A rectangle {x,y,w,h}.
|
||||||
:return: A random point within the rectangle (uniform distribution).
|
:return: A random point within the rectangle (uniform distribution).
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.cwh2rect[prosperon.DOC] = `
|
geometry.cwh2rect[cell.DOC] = `
|
||||||
:param center: A 2D point [cx, cy].
|
:param center: A 2D point [cx, cy].
|
||||||
:param wh: A 2D size [width, height].
|
:param wh: A 2D size [width, height].
|
||||||
:return: A rectangle {x, y, w, h} with x,y set to center and w,h set to the given size.
|
:return: A rectangle {x, y, w, h} with x,y set to center and w,h set to the given size.
|
||||||
Helper: convert a center point and width/height vector to a rect object.
|
Helper: convert a center point and width/height vector to a rect object.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_point_inside[prosperon.DOC] = `
|
geometry.rect_point_inside[cell.DOC] = `
|
||||||
:param rect: A rectangle {x,y,w,h}.
|
:param rect: A rectangle {x,y,w,h}.
|
||||||
:param point: A 2D point [px, py].
|
:param point: A 2D point [px, py].
|
||||||
:return: True if the point lies inside the rectangle, otherwise false.
|
:return: True if the point lies inside the rectangle, otherwise false.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_pos[prosperon.DOC] = `
|
geometry.rect_pos[cell.DOC] = `
|
||||||
:param rect: A rectangle {x,y,w,h}.
|
:param rect: A rectangle {x,y,w,h}.
|
||||||
:return: A 2D vector [x,y] giving the rectangle's position.
|
:return: A 2D vector [x,y] giving the rectangle's position.
|
||||||
`
|
`
|
||||||
|
|
||||||
geometry.rect_move[prosperon.DOC] = `
|
geometry.rect_move[cell.DOC] = `
|
||||||
:param rect: A rectangle {x,y,w,h}.
|
:param rect: A rectangle {x,y,w,h}.
|
||||||
:param offset: A 2D vector to add to the rectangle's position.
|
:param offset: A 2D vector to add to the rectangle's position.
|
||||||
:return: A new rectangle with updated x,y offset.
|
:return: A new rectangle with updated x,y offset.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
var graphics = this
|
var graphics = this
|
||||||
|
|
||||||
graphics[prosperon.DOC] = `
|
graphics[cell.DOC] = `
|
||||||
Provides functionality for loading and managing images, fonts, textures, and sprite meshes.
|
Provides functionality for loading and managing images, fonts, textures, and sprite meshes.
|
||||||
Includes both JavaScript and C-implemented routines for creating geometry buffers, performing
|
Includes both JavaScript and C-implemented routines for creating geometry buffers, performing
|
||||||
rectangle packing, etc.
|
rectangle packing, etc.
|
||||||
@@ -197,7 +197,7 @@ var image = {}
|
|||||||
image.dimensions = function() {
|
image.dimensions = function() {
|
||||||
return [this.texture.width, this.texture.height].scale([this.rect[2], this.rect[3]])
|
return [this.texture.width, this.texture.height].scale([this.rect[2], this.rect[3]])
|
||||||
}
|
}
|
||||||
image.dimensions[prosperon.DOC] = `
|
image.dimensions[cell.DOC] = `
|
||||||
:return: A 2D array [width, height] that is the scaled size of this image (texture size * rect size).
|
:return: A 2D array [width, height] that is the scaled size of this image (texture size * rect size).
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ function pack_into_sheet(images) {
|
|||||||
graphics.is_image = function(obj) {
|
graphics.is_image = function(obj) {
|
||||||
if (obj.texture && obj.rect) return true
|
if (obj.texture && obj.rect) return true
|
||||||
}
|
}
|
||||||
graphics.is_image[prosperon.DOC] = `
|
graphics.is_image[cell.DOC] = `
|
||||||
:param obj: An object to check.
|
:param obj: An object to check.
|
||||||
:return: True if 'obj' has a .texture and a .rect property, indicating it's an image object.
|
:return: True if 'obj' has a .texture and a .rect property, indicating it's an image object.
|
||||||
`
|
`
|
||||||
@@ -266,7 +266,7 @@ graphics.texture = function texture(path) {
|
|||||||
cache.set(id, image)
|
cache.set(id, image)
|
||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
graphics.texture[prosperon.DOC] = `
|
graphics.texture[cell.DOC] = `
|
||||||
:param path: A string path to an image file or an already-loaded image object.
|
:param path: A string path to an image file or an already-loaded image object.
|
||||||
:return: An image object with {surface, texture, frames?, etc.} depending on the format.
|
:return: An image object with {surface, texture, frames?, etc.} depending on the format.
|
||||||
Load or retrieve a cached image, converting it into a GPU texture. If 'path' is already an object, it’s returned directly.
|
Load or retrieve a cached image, converting it into a GPU texture. If 'path' is already an object, it’s returned directly.
|
||||||
@@ -280,7 +280,7 @@ graphics.texture.total_size = function() {
|
|||||||
// Not yet implemented, presumably sum of (texture.width * texture.height * 4) for images in RAM
|
// Not yet implemented, presumably sum of (texture.width * texture.height * 4) for images in RAM
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
graphics.texture.total_size[prosperon.DOC] = `
|
graphics.texture.total_size[cell.DOC] = `
|
||||||
:return: The total estimated memory size of all cached textures in RAM, in bytes. (Not yet implemented.)
|
:return: The total estimated memory size of all cached textures in RAM, in bytes. (Not yet implemented.)
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ graphics.texture.total_vram = function() {
|
|||||||
// Not yet implemented, presumably sum of GPU memory usage
|
// Not yet implemented, presumably sum of GPU memory usage
|
||||||
return vram
|
return vram
|
||||||
}
|
}
|
||||||
graphics.texture.total_vram[prosperon.DOC] = `
|
graphics.texture.total_vram[cell.DOC] = `
|
||||||
:return: The total estimated GPU memory usage of all cached textures, in bytes. (Not yet implemented.)
|
:return: The total estimated GPU memory usage of all cached textures, in bytes. (Not yet implemented.)
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ graphics.tex_hotreload = function tex_hotreload(file) {
|
|||||||
|
|
||||||
merge_objects(oldimg, img, ['surface', 'texture', 'loop', 'time'])
|
merge_objects(oldimg, img, ['surface', 'texture', 'loop', 'time'])
|
||||||
}
|
}
|
||||||
graphics.tex_hotreload[prosperon.DOC] = `
|
graphics.tex_hotreload[cell.DOC] = `
|
||||||
:param file: The file path that was changed on disk.
|
:param file: The file path that was changed on disk.
|
||||||
:return: None
|
:return: None
|
||||||
Reload the image for the given file, updating the cached copy in memory and GPU.
|
Reload the image for the given file, updating the cached copy in memory and GPU.
|
||||||
@@ -364,7 +364,7 @@ graphics.get_font = function get_font(path, size) {
|
|||||||
|
|
||||||
return font
|
return font
|
||||||
}
|
}
|
||||||
graphics.get_font[prosperon.DOC] = `
|
graphics.get_font[cell.DOC] = `
|
||||||
:param path: A string path to a font file, optionally with ".size" appended.
|
:param path: A string path to a font file, optionally with ".size" appended.
|
||||||
:param size: Pixel size of the font, if not included in 'path'.
|
:param size: Pixel size of the font, if not included in 'path'.
|
||||||
:return: A font object with .surface and .texture for rendering text.
|
:return: A font object with .surface and .texture for rendering text.
|
||||||
@@ -382,14 +382,14 @@ graphics.queue_sprite_mesh = function(queue) {
|
|||||||
}
|
}
|
||||||
return [mesh.pos, mesh.uv, mesh.color, mesh.indices]
|
return [mesh.pos, mesh.uv, mesh.color, mesh.indices]
|
||||||
}
|
}
|
||||||
graphics.queue_sprite_mesh[prosperon.DOC] = `
|
graphics.queue_sprite_mesh[cell.DOC] = `
|
||||||
:param queue: An array of draw commands, some of which are {type:'sprite'} objects.
|
:param queue: An array of draw commands, some of which are {type:'sprite'} objects.
|
||||||
:return: An array of references to GPU buffers [pos,uv,color,indices].
|
:return: An array of references to GPU buffers [pos,uv,color,indices].
|
||||||
Builds a single geometry mesh for all sprite-type commands in the queue, storing first_index/num_indices
|
Builds a single geometry mesh for all sprite-type commands in the queue, storing first_index/num_indices
|
||||||
so they can be rendered in one draw call.
|
so they can be rendered in one draw call.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_text_buffer[prosperon.DOC] = `
|
graphics.make_text_buffer[cell.DOC] = `
|
||||||
:param text: The string to render.
|
:param text: The string to render.
|
||||||
:param rect: A rectangle specifying position and possibly wrapping.
|
:param rect: A rectangle specifying position and possibly wrapping.
|
||||||
:param angle: Rotation angle (unused or optional).
|
:param angle: Rotation angle (unused or optional).
|
||||||
@@ -400,7 +400,7 @@ graphics.make_text_buffer[prosperon.DOC] = `
|
|||||||
Generate a GPU buffer mesh of text quads for rendering with a font, etc.
|
Generate a GPU buffer mesh of text quads for rendering with a font, etc.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.rectpack[prosperon.DOC] = `
|
graphics.rectpack[cell.DOC] = `
|
||||||
:param width: The width of the area to pack into.
|
:param width: The width of the area to pack into.
|
||||||
:param height: The height of the area to pack into.
|
:param height: The height of the area to pack into.
|
||||||
:param sizes: An array of [w,h] pairs for the rectangles to pack.
|
:param sizes: An array of [w,h] pairs for the rectangles to pack.
|
||||||
@@ -408,39 +408,39 @@ graphics.rectpack[prosperon.DOC] = `
|
|||||||
Perform a rectangle packing using the stbrp library. Return positions for each rect.
|
Perform a rectangle packing using the stbrp library. Return positions for each rect.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_texture[prosperon.DOC] = `
|
graphics.make_texture[cell.DOC] = `
|
||||||
:param data: Raw image bytes (PNG, JPG, etc.) as an ArrayBuffer.
|
:param data: Raw image bytes (PNG, JPG, etc.) as an ArrayBuffer.
|
||||||
:return: An SDL_Surface object representing the decoded image in RAM, for use with GPU or software rendering.
|
:return: An SDL_Surface object representing the decoded image in RAM, for use with GPU or software rendering.
|
||||||
Convert raw image bytes into an SDL_Surface object.
|
Convert raw image bytes into an SDL_Surface object.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_gif[prosperon.DOC] = `
|
graphics.make_gif[cell.DOC] = `
|
||||||
:param data: An ArrayBuffer containing GIF data.
|
:param data: An ArrayBuffer containing GIF data.
|
||||||
:return: An object with frames[], each frame having its own .surface. Some also have a .texture for GPU use.
|
:return: An object with frames[], each frame having its own .surface. Some also have a .texture for GPU use.
|
||||||
Load a GIF, returning its frames. If it's a single-frame GIF, the result may have .surface only.
|
Load a GIF, returning its frames. If it's a single-frame GIF, the result may have .surface only.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_aseprite[prosperon.DOC] = `
|
graphics.make_aseprite[cell.DOC] = `
|
||||||
:param data: An ArrayBuffer containing Aseprite (ASE) file data.
|
:param data: An ArrayBuffer containing Aseprite (ASE) file data.
|
||||||
:return: An object containing frames or animations, each with .surface. May also have top-level .surface for a single-layer case.
|
:return: An object containing frames or animations, each with .surface. May also have top-level .surface for a single-layer case.
|
||||||
Load an Aseprite/ASE file from an array of bytes, returning frames or animations.
|
Load an Aseprite/ASE file from an array of bytes, returning frames or animations.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.cull_sprites[prosperon.DOC] = `
|
graphics.cull_sprites[cell.DOC] = `
|
||||||
:param sprites: An array of sprite objects (each has rect or transform).
|
:param sprites: An array of sprite objects (each has rect or transform).
|
||||||
:param camera: A camera or bounding rectangle defining the view area.
|
:param camera: A camera or bounding rectangle defining the view area.
|
||||||
:return: A new array of sprites that are visible in the camera's view.
|
:return: A new array of sprites that are visible in the camera's view.
|
||||||
Filter an array of sprites to only those visible in the provided camera’s view.
|
Filter an array of sprites to only those visible in the provided camera’s view.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_font[prosperon.DOC] = `
|
graphics.make_font[cell.DOC] = `
|
||||||
:param data: TTF/OTF file data as an ArrayBuffer.
|
:param data: TTF/OTF file data as an ArrayBuffer.
|
||||||
:param size: Pixel size for rendering glyphs.
|
:param size: Pixel size for rendering glyphs.
|
||||||
:return: A font object with surface, texture, and glyph data, for text rendering with make_text_buffer.
|
:return: A font object with surface, texture, and glyph data, for text rendering with make_text_buffer.
|
||||||
Load a font from TTF/OTF data at the given size.
|
Load a font from TTF/OTF data at the given size.
|
||||||
`
|
`
|
||||||
|
|
||||||
graphics.make_line_prim[prosperon.DOC] = `
|
graphics.make_line_prim[cell.DOC] = `
|
||||||
:param points: An array of [x,y] points forming the line.
|
:param points: An array of [x,y] points forming the line.
|
||||||
:param thickness: The thickness (width) of the polyline.
|
:param thickness: The thickness (width) of the polyline.
|
||||||
:param startCap: (Unused) Possibly the type of cap for the start.
|
:param startCap: (Unused) Possibly the type of cap for the start.
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 867 B After Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |