diff options
Diffstat (limited to 'cheatsheet')
| -rw-r--r-- | cheatsheet/cheatsheet.html | 1 | ||||
| -rw-r--r-- | cheatsheet/cheatsheet_zh.html | 181 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_audio.c | 73 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_colors.c | 31 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_core.c | 238 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_models.c | 93 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_shapes.c | 58 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_structs.c | 43 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_text.c | 55 | ||||
| -rw-r--r-- | cheatsheet/zh/raylib_textures.c | 116 |
10 files changed, 889 insertions, 0 deletions
diff --git a/cheatsheet/cheatsheet.html b/cheatsheet/cheatsheet.html index b24d415..c816d94 100644 --- a/cheatsheet/cheatsheet.html +++ b/cheatsheet/cheatsheet.html @@ -132,6 +132,7 @@ <p id="version">v4.2 quick reference card [<a id="downpdf" href="https://www.raylib.com/cheatsheet/raylib_cheatsheet_v4.2.pdf">download as PDF</a>]</p> </div> <br> + <p>Chinese Translation: <a href="cheatsheet_zh.html">以下为raylib所有API接口中文释义</a></p> <div id="fulldata"> <p id="pcore">module: rcore</p> <div id="core"><pre><code class="cpp"></code></pre></div> diff --git a/cheatsheet/cheatsheet_zh.html b/cheatsheet/cheatsheet_zh.html new file mode 100644 index 0000000..858dd59 --- /dev/null +++ b/cheatsheet/cheatsheet_zh.html @@ -0,0 +1,181 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + + <title>raylib - cheatsheet</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + + <meta name="title" content="raylib - cheatsheet"> + <meta name="description" content="raylib is a simple and easy-to-use library to enjoy videogames programming. Don't miss latest functions added to raylib... check raylib cheatsheet"> + <meta name="keywords" content="raylib, videogames, programming, C, C++, library, learn, study, simple, easy, free, open source, raysan"> + <meta name="viewport" content="width=device-width"> + + <!-- Open Graph metatags for sharing --> + <meta property="og:title" content="raylib - cheatsheet"/> + <meta property="og:image" content="https://www.raylib.com/common/img/raylib_logo_card.png"/> + <meta property="og:url" content="https://www.raylib.com" /> + <meta property="og:site_name" content="raylib"/> + <meta property="og:description" content="Don't miss latest functions added to raylib... check raylib cheatsheet"/> + + <!-- Add jQuery library --> + <script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script> + + <!-- hightlight.js - Syntax highlighting for the Web --> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/styles/docco.min.css"> + <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/highlight.min.js"></script> + + <style type="text/css"> + @font-face { + font-family: 'grixel_acme_7_wide_xtnd'; + src: url('../common/font/acme_7_wide_xtnd.eot'); + src: url('../common/font/acme_7_wide_xtnd.eot?#iefix') format('embedded-opentype'), + url('../common/font/acme_7_wide_xtnd.woff') format('woff'), + url('../common/font/acme_7_wide_xtnd.ttf') format('truetype'); + font-weight: normal; + font-style: normal; + font-size-adjust:0.49; + } + body{background-color:#f5f5f5;} + #fulldata{width: 1315px!important;} + .eximage img{margin: 0 auto; border: 1px solid; border-color: black; width:770px; height:auto;} + p{font-family: grixel_acme_7_wide_xtnd, Courier New, Verdana, Arial; font-size:13px; line-height:24px;} + pre code{font-family: Courier New; font-size:12px; width: auto!important; border: 1px solid; border-color:#b0b0b0; width:758px; height:auto; } + .exdownbtn{ + width:250px; height:30px; float:left; position: relative; cursor:pointer; font-weight:bold; font-size:10px; + line-height:30px; text-align: center; border-width:5px; background-color:#e1e1e1; color:#5c5a5a; + border:4px solid #898888; font-family: grixel_acme_7_wide_xtnd, Courier New, Verdana, Arial; + } + .exdownbtn:hover{background-color:#f0d6d6; color:#c55757; border:4px solid #e66666;} + #core pre code{border:10px solid; border-color:#888888; background-color:#dbdbe1; } + #shapes pre code{border:10px solid; border-color:#e66666; background-color:#e9d0d6; } + #textures pre code{border:10px solid; border-color:#75a06d; background-color:#c3e4bf; } + #text pre code{border:10px solid; border-color:#52b296; background-color:#b9e9dd; } + #models pre code{border:10px solid; border-color:#5d9cbd; background-color:#b9d6e8; } + #audio pre code{border:10px solid; border-color:#d3b157; background-color:#e5d7ae; } + #structs pre code{border:10px solid; border-color:#d2c9c6; background-color:#f8f8ff;} + #colors pre code{border:10px solid; border-color:#c6d2c6; background-color:#e9f1f2;} + #logo{width:128px; height:128px; float:left; position:relative; background-image:url(../common/img/raylib_logo.png);} + #header{position:relative; height:110px; width: 1000px;} + #title, #plinks, #version{position:relative; float:left; margin:0px; margin-left:10px; margin-top:10px;} + #plinks{color: gray;} + #plinks a, #copyright a{color: gray; text-decoration:none;} + #plinks a:hover{color: black;} + #version {margin-top: 23px; width:500px;} + #pcore{margin-bottom:-12px; margin-left:12px; color:#5c5a5a;} + #pshapes{margin-bottom:-12px; margin-left:12px; color:#c55757;} + #ptextures{margin-bottom:-12px; margin-left:12px; color:#60815a;} + #ptext{margin-bottom:-12px; margin-left:12px; color:#377764;} + #pmodels{margin-bottom:-12px; margin-left:12px; color:#417794;} + #paudio{margin-bottom:-12px; margin-left:12px; color:#8c7539;} + #pstructs{margin-bottom:-12px; margin-left:12px; color:#bcbccd;} + #pcolors{margin-bottom:-12px; margin-left:12px; color:#bcbccd;} + + #fullgroup{ + display: grid; + grid-column-gap: 20px; + grid-template-columns: auto auto; + } + + #copyright p{color:#8b8b8b; font-size:10px} + #copyright a:hover{color:black;} + + #downpdf{text-decoration: none;color:#aaaaaa;} + #downpdf:hover{color:#444;} + </style> + + <script type="text/javascript"> + $(document).ready(function() { + $.get('zh/raylib_core.c', function(data) { + $('#core pre code').text(data); + $('#core pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_shapes.c', function(data) { + $('#shapes pre code').text(data); + $('#shapes pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_textures.c', function(data) { + $('#textures pre code').text(data); + $('#textures pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_text.c', function(data) { + $('#text pre code').text(data); + $('#text pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_models.c', function(data) { + $('#models pre code').text(data); + $('#models pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_audio.c', function(data) { + $('#audio pre code').text(data); + $('#audio pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_colors.c', function(data) { + $('#colors pre code').text(data); + $('#colors pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('zh/raylib_structs.c', function(data) { + $('#structs pre code').text(data); + $('#structs pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + }); + </script> + </head> + + <body> + <div id="header"> + <a id="logo" href="https://www.raylib.com/index.html"></a> + <p id="title">以下为raylib所有API接口中文释义</p> + <p id="title">A simple and easy-to-use library to enjoy videogames programming</p> + <p id="plinks">[<a href="https://discord.gg/raylib">raylib Discord server</a>][<a href="https://github.com/raysan5/raylib">github.com/raysan5/raylib</a>][<a href="https://github.com/raysan5/raylib/blob/master/src/raylib.h">raylib.h</a>]</p> + </div> + <br> + <p>此翻译仅做参考与辅助学习, 可能会有点枯燥, 可以去阅读大佬的教程【<a href="https://zhuanlan.zhihu.com/p/526271216">https://zhuanlan.zhihu.com/p/526271216</a>】</p> + <p>该翻译稿为非盈利的, 是为了大家更好的学习与享受视频游戏编程的乐趣, 禁止在没有告诉译者的情况下擅自将其用作营利!!!</p> + <p>译者邮箱:[email protected] & [email protected]</p> + <p>本翻译由恒星联盟(starsunion.eu.org)成员Macky和HJQ进行翻译</p> + <br> + <div id="fulldata"> + <p id="pcore">module: rcore</p> + <div id="core"><pre><code class="cpp"></code></pre></div> + <p id="pshapes">module: rshapes</p> + <div id="shapes"><pre><code class="cpp"></code></pre></div> + <p id="ptextures">module: rtextures</p> + <div id="textures"><pre><code class="cpp"></code></pre></div> + <p id="ptext">module: rtext</p> + <div id="text"><pre><code class="cpp"></code></pre></div> + <p id="pmodels">module: rmodels</p> + <div id="models"><pre><code class="cpp"></code></pre></div> + <p id="paudio">module: raudio</p> + <div id="audio"><pre><code class="cpp"></code></pre></div> + + <div id="fullgroup"> + <div class="leftgroup"> + <p id="pstructs">structs</p> + <div id="structs"><pre><code class="cpp"></code></pre></div> + </div> + <div class="rightgroup"> + <p id="pcolors">colors</p> + <div id="colors"><pre><code class="cpp"></code></pre></div> + </div> + </div> + <div id="copyright"> + <p>raylib quick reference card - Copyright (c) 2013-2022 Ramon Santamaria (<a href="https://www.twitter.com/raysan5">@raysan5</a>)</p> + </div> + </div> + + + <!-- Google Analytics tracking code --> + <script> + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + + ga('create', 'UA-45733555-1', 'raylib.com'); + ga('require', 'linkid', 'linkid.js'); + ga('send', 'pageview'); + </script> + </body> +</html> diff --git a/cheatsheet/zh/raylib_audio.c b/cheatsheet/zh/raylib_audio.c new file mode 100644 index 0000000..8fa1e52 --- /dev/null +++ b/cheatsheet/zh/raylib_audio.c @@ -0,0 +1,73 @@ + + //模块:raudio + //音频设备管理功能 + void InitAudioDevice(void); //初始化音频设备和上下文 + void CloseAudioDevice(void); //关闭音频设备和上下文 + bool IsAudioDeviceReady(void); //检查音频设备是否已成功初始化 + void SetMasterVolume(float体积); //设置主音量(侦听器) + + //Wave wave/Sound Load/卸载功能 + Wave LoadWave(const char *fileName); //从文件加载Wave wave数据 + Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int dataSize); //从内存缓冲区加载Wave, fileType引用扩展名:即'。瓦夫 + Sound LoadSound(const char *fileName); //从文件加载音频 + Sound LoadSoundFromWave(Wave wave); //从Wave数据加载音频 + void UpdateSound(Sound, constvoid *data, int sampleCount); //用新数据更新音频缓冲区 + void UnloadWave(Wave wave); //卸载Wave数据 + void UnloadSound(Sound); //卸载音频 + bool ExportWave(Wave, const char *fileName); //将波数据导出到文件, 成功时返回true + bool ExportWaveAsCode(Wave, const char *fileName); //将波样本数据导出到代码(.h), 成功时返回true + + //Wave/Sound管理功能 + void PlaySound(Sound sound); //播放音频 + void StopSound(Sound sound); //停止播放音频 + void PauseSound(Sound sound); //暂停音频 + void ResumeSound(Sound sound); //恢复暂停的音频 + void PlaySoundMulti(Sound sound); //播放音频(使用多通道缓冲池) + void StopSoundMulti(void); //停止任何音频播放(使用多通道缓冲池) + int GetSoundsPlaying(void); //获取多声道播放的音频数量 + bool IsSoundPlaying(Sound sound); //检查当前是否正在播放音频 + void SetSoundVolume(Sound sound, float音量); //设置音频音量(1.0为最大音量) + void SetSoundPitch(Sound sound, float音调); //设置音频的音调(1.0为基本音量) + void SetSoundPan(Sound sound, float浮盘); //为音频设置平移(0.5为中心) + Wave WaveCopy(Wave wave); //将波复制到新波 + void WaveCrop(Wave *Wave, int initSample, int finalSample); //将波裁剪到定义的采样范围 + void WaveFormat(Wave *Wave, int sampleRate, int sampleSize, int通道); //将波数据转换为所需格式 + float *LoadWaveSamples(Wave wave); //将波采样数据加载为32位float数据数组 + void UnloadWaveSamples(float *样本); //卸载使用加载WaveSamples()加载的样本数据 + + //Music管理功能 + Music LoadMusicStream(const char *fileName); //从文件加载音乐流 + Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); //从数据加载音乐流 + void UnloadMusicStream(Music music); //卸载音乐流 + void PlayMusicStream(Music music); //开始播放音乐 + bool IsMusicStreamPlaying(Music music); //检查是否正在播放音乐 + void UpdateMusicStream(Music music); //更新音乐流的缓冲区 + void StopMusicStream(Music music); //停止音乐播放 + void PauseMusicStream(Music music); //暂停音乐播放 + void ResumeMusicStream(Music music); //继续播放暂停的音乐 + void SeekMusicStream(Music music, float位置); //将音乐搜索到某个位置(以秒为单位) + void SetMusicVolume(Music music, float音量); //设置音乐音量(1.0为最大音量) + void SetMusicPitch(Music music, float音高); //设置音乐的音高(1.0为基本级别) + void SetMusicPan(Music music, 浮盘); //为音乐设置平移(0.5为中心) + float GetMusicTimeLength(Music music); //获取音乐时间长度(秒) + float GetMusicTimePlayed(Music music); //获取当前播放的音乐时间(秒) + + //AudioStream管理功能 + AudioStream LoadAudioStream(unsigned int sampleRate、unsigned int sampleSize、unsigned整型通道); //加载音频流(以流式传输原始音频pcm数据) + void UnloadAudioStream(AudioStream stream); //卸载音频流并释放内存 + void UpdateAudioStream(AudioStream音频流, const void *data, int frameCount); //使用数据更新音频流缓冲区 + bool IsAudioStreamProcessed(AudioStream音频流); //检查是否有音频流缓冲区需要重新填充 + void PlayAudioStream(AudioStream音频流); //播放音频流 + void PauseAudioStream(AudioStream音频流); //暂停音频流 + void ResumeAudioStream(AudioStream音频流); //恢复音频流 + bool IsAudioStreamPlaying(AudioStream音频流); //检查是否正在播放音频流 + void StopAudioStream(AudioStream音频流); //停止音频流 + void SetAudioStreamVolume(AudioStream音频流, float音量); //设置音频流的音量(1.0为最大音量) + void SetAudioStreamPitch(AudioStream音频流, float音调); //设置音频流的音调(1.0为基本级别) + void SetAudioStreamPan(AudioStream音频流, float平移); //设置音频流的平移(0.5居中) + void SetAudioStreamBufferSizeDefault(int大小); //新音频流的默认大小 + void SetAudioStreamCallback(AudioStream音频流, AudioCallback回调); //音频线程回调以请求新数据 + void AttachAudioStreamProcessor(AudioStream音频流、AudioCallback处理器); //将音频流处理器连接到流 + void DetachAudioStreamProcessor(AudioStream音频流、AudioCallback处理器); //从流中分离音频流处理器 + +
\ No newline at end of file diff --git a/cheatsheet/zh/raylib_colors.c b/cheatsheet/zh/raylib_colors.c new file mode 100644 index 0000000..e5450ad --- /dev/null +++ b/cheatsheet/zh/raylib_colors.c @@ -0,0 +1,31 @@ + + //颜色宏定义 + //自定义 raylib调色板, 打造令人惊叹的视觉效果 + #define LIGHTGRAY (Color){ 200, 200, 255 } //浅灰色 + #define GRAY (Color){ 130, 130, 130, 255 } //灰色 + #define DARKGRAY (Color){ 80, 80, 80, 255 } //深灰色 + #define YELLOW (Color){ 253, 249, 0, 255 } //黄色 + #define GOLD (Color){ 255, 203, 0, 255 } //金色 + #define ORANGE (Color){ 255, 161, 0, 255 } //橙色 + #define PINK (Color){ 255, 109, 194, 255 } //粉色 + #define RED (Color){ 230, 41, 55, 255 } //红色 + #define MAROON (Color){ 190, 33, 55, 255 } //褐红色 + #define GREEN (Color){ 0, 228, 48, 255 } //绿色 + #define LIME (Color){ 0, 158, 47, 255 } //石灰 + #define DARKGREEN (Color){ 0, 117, 44, 255 } //深绿色 + #define SKYBLUE (Color){ 102, 191, 255, 255 } //天空蓝 + #define BLUE (Color){ 0, 121, 241, 255 } //蓝色 + #define DARKBLUE (Color){ 0, 82, 172, 255 } //深蓝色 + #define PURPLE (Color){ 200, 122, 255, 255 } //紫色 + #define VIOLET (Color){ 135, 60, 190, 255 } //紫罗兰色 + #define DARKPURPLE (Color){ 112, 31, 126, 255 } //深紫色 + #define BEIGE (Color){ 211, 176, 131, 255 } //米色 + #define BROWN (Color){ 127, 106, 79, 255 } //棕色 + #define DARKBROWN (Color){ 76, 63, 47, 255 } //深棕色 + + #define WHITE (Color){ 255, 255, 255 } //白色 + #define BLACK (Color){ 0, 0, 0255 } //黑色 + #define BLANK (Color){ 0, 0, 0 } //透明 + #define MAGENTA (Color){ 255, 0, 255, 255 } //洋红色 + #define RAYWHITE (Color){ 245, 245, 245, 255 } //射线白, 作者送的颜色 + diff --git a/cheatsheet/zh/raylib_core.c b/cheatsheet/zh/raylib_core.c new file mode 100644 index 0000000..063ec76 --- /dev/null +++ b/cheatsheet/zh/raylib_core.c @@ -0,0 +1,238 @@ + + //窗口相关功能 + void InitWindow(int width, int height, const char *title); //初始化窗口和OpenGL上下文 + bool WindowShouldClose(void); //检查是否按下了KEY_ESCAPE或关闭图标 + void CloseWindow(void); //关闭窗口并卸载OpenGL上下文 + bool IsWindowReady(void); //检查窗口是否已成功初始化 + bool IsWindowFullscreen(void); //检查窗口当前是否为全屏 + bool IsWindowHidden(void); //检查窗口当前是否隐藏(仅PLATFORM_DESKTOP) + bool IsWindowMinimized(void); //检查窗口当前是否最小化(仅限PLATFORM_DESKTOP) + bool IsWindowMaximized(void); //检查窗口当前是否最大化(仅PLATFORM_DESKTOP) + bool IsWindowFocused(void); //检查窗口当前是否聚焦(仅PLATFORM_DESKTOP) + bool IsWindowResized(void); //检查窗口是否已调整最后一帧的大小 + bool IsWindowState(unsigned int flag); //检查是否启用了一个特定窗口标志 + void SetWindowState(unsigned int flag); //使用标志设置窗口配置状态(仅限PLATFORM_DESKTOP) + void ClearWindowState(unsigned int flag); //清除窗口配置状态标志 + void ToggleFullscreen(void); //切换窗口状态:全屏/窗口(仅PLATFORM_DESKTOP) + void MaximizeWindow(void); //设置窗口状态:最大化, 如果可调整大小(仅PLATFORM_DESKTOP) + void MinimizeWindow(void); //设置窗口状态:最小化, 如果可调整大小(仅PLATFORM_DESKTOP) + void RestoreWindow(void); //设置窗口状态:未最小化/最大化(仅PLATFORM_DESKTOP) + void SetWindowIcon(Image image); //设置窗口图标(仅PLATFORM_DESKTOP) + void SetWindowTitle(const char *title); //设置窗口标题(仅限PLATFORM_DESKTOP) + void SetWindowPosition(int x, int y); //在屏幕上设置窗口位置(仅限PLATFORM_DESKTOP) + void SetWindowMonitor(int monitor); //为当前窗口设置监视器(全屏模式) + void SetWindowMinSize(int width, int height); //设置窗口最小尺寸(对于FLAG_window_RESIZABLE) + void SetWindowSize(int width, int height); //设置窗口尺寸 + void SetWindowOpacity(float opacity); //设置窗口不透明度[0.0f..1.0f](仅限PLATFORM_DESKTOP) + void*GetWindowHandle(void); //获取本机窗口句柄 + int GetScreenWidth(void); //获取当前屏幕宽度 + int GetScreenHeight(void); //获取当前屏幕高度 + int GetRenderWidth(void); //获取当前渲染宽度(它考虑HiDPI) + int GetRenderHeight(void); //获取当前渲染高度(它考虑HiDPI) + int GetMonitorCount(void); //获取连接的监视器数量 + int GetCurrentMonitor(void); //获取当前连接的监视器 + Vector2 GetMonitorPosition(int monitor); //获取指定的监视器位置 + int GetMonitorWidth(int monitor); //获取指定的监视器宽度(监视器使用的当前视频模式) + int GetMonitorHeight(int monitor); //获取指定的监视器高度(监视器使用的当前视频模式) + int GetMonitorPhysicalWidth(int monitor); //获取指定的监视器物理宽度(毫米) + int GetMonitorPhysicalHeight(int monitor); //获取指定的监视器物理高度(毫米) + int GetMonitorRefreshRate(int monitor); //获取指定的监视器刷新率 + Vector2 GetWindowPosition(void); //获取监视器上的窗口位置XY + Vector2 GetWindowScaleDPI(void); //获取窗口比例DPI因子 + const char*GetMonitorName(int monitor); //获取主监视器的可读UTF-8编码名称 + void SetClipboardText(const char *text); //设置剪贴板文本内容 + const char*GetClipboardText(void); //获取剪贴板文本内容 + void EnableEventWaiting(void); //启用等待EndDrawing()上的事件, 无自动事件轮询 + void DisableEventWaiting(void); //禁用等待EndDrawing()上的事件, 自动事件轮询 + + //自定义框架控制功能 + //注:这些功能适用于希望完全控制帧处理的高级用户 + //默认情况下, EndDrawing()完成以下任务:绘制所有内容+SwapScreenBuffer()+管理帧计时+PollInputEvents() + //要避免这种行为并手动控制帧进程, 请在配置中启用。h:支持自定义框架控制 + void SwapScreenBuffer(void); //用前缓冲区交换后缓冲区(屏幕绘图) + void PollInputEvents(void); //注册所有输入事件 + void WaitTime(双秒); //等待一段时间(停止程序执行) + + //鼠标光标相关功能 + void ShowCursor(void); //显示鼠标光标 + void HideCursor(void); //隐藏鼠标光标 + bool IsCursorHidden(void); //检查鼠标光标是否不可见 + void EnableCursor(void); //启用鼠标光标(解锁鼠标光标) + void DisableCursor(void); //禁用鼠标光标(锁定鼠标光标) + bool IsCursorOnScreen(void); //检查鼠标光标是否在屏幕上 + + //绘图相关功能 + void ClearBackground(Color color); //设置背景色(帧缓冲区透明色) + void BeginDrawing(void); //设置画布(帧缓冲区)以开始绘制 + void EndDrawing(void); //结束画布绘制和交换缓冲区(双缓冲) + void BeginMode2D(Camera2D相机); //使用自定义相机开始2D模式(2D) + void EndMode2D(void); //使用自定义相机结束2D模式 + void BeginMode3D(Camera3D相机); //使用自定义相机开始3D模式(3D) + void EndMode3D(void); //结束三维模式并返回默认的二维正交模式 + void BeginTextureMode(RenderTexture2D目标); //开始绘制以渲染Texture + void EndTextureMode(void); //结束绘制以渲染Texture + void BeginShaderMode(Shader shader); //开始自定义着色器绘图 + void EndShaderMode(void); //结束自定义着色器绘图(使用默认着色器) + void BeginBlendMode(int模式); //开始混合模式(alpha、加法、乘法、减法、自定义) + void EndBlendMode(void); //结束混合模式(重置为默认值:alpha混合) + void BeginScissorMode(int x, int y, int width, int height); //开始剪式模式(定义下图的屏幕区域) + void EndScissorMode(void); //末端剪式模式 + void BeginVrStereoMode(VrStereoConfig config); //开始立体渲染(需要VR模拟器) + void EndVrStereoMode(void); //结束立体渲染(需要VR模拟器) + + //VR模拟器的VR立体配置功能 + VrStereoConfig LoadVrStereo Config(VrDeviceInfo device); //为VR模拟器设备参数加载VR立体声配置 + void UnloadVrStereoConfig(VrStereoConfig config); //卸载VR立体声配置 + + //着色器管理功能 + //注意:OpenGL 1.1上不提供着色器功能 + Shader LoadShader(const char *vsFileName, const char *fsFileName); //从文件加载着色器并绑定默认位置 + Shader LoadShaderFromMemory(const char *vsCode, const char *fsCode); //从代码字符串加载着色器并绑定默认位置 + int GetShaderLocation(Shader shader, const char *uniformName); //获取着色器统一位置 + int GetShaderLocationAttrib(Shader shader, const char *attribName); //获取着色器属性位置 + void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformType); //设置着色器统一值 + void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count); //设置着色器统一值向量 + void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat); //设置着色器统一值(矩阵4x4) + void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture); //为Texture设置着色器统一值(sampler2d) + void UnloadShader(Shader shader); //从GPU内存(VRAM)卸载着色器 + + //屏幕空间相关功能 + Ray GetMouseRay(Vector2 mousePosition, 相机相机); //从鼠标位置获取光线跟踪 + Matrix GetCameraMatrix(Camera camera); //获取相机变换矩阵(视图矩阵) + Matrix GetCameraMatrix2D(Camera2D相机); //获取相机二维变换矩阵 + Vector2 GetWorldToScreen(Vector3位置, 摄像机); //获取三维世界空间位置的屏幕空间位置 + Vector2 GetScreenToWorld2D(Vector2位置, Camera2D相机); //获取2d相机屏幕空间位置的世界空间位置 + Vector2 GetWorldToScreenEx(Vector3位置, 摄像机, int宽度, int高度); //获取三维世界空间位置的大小位置 + Vector2 GetWorldToScreen2D(Vector2位置, Camera2D相机); //获取2d相机世界空间位置的屏幕空间位置 + + //定时相关功能 + void SetTargetFPS(int fps);//设置目标FPS(最大值) + int GetFPS(void); //获取当前FPS + float GetFrameTime(void); //获取绘制的最后一帧的时间(以秒为单位)(增量时间) + double GetTime(void); //获取自InitWindow()以来的运行时间(秒) + + //其他。功能 + int GetRandomValue(int最小值, int最大值); //获取最小值和最大值之间的随机值(包括两者) + void SetRandomSeed(unsigned int种子); //设置随机数生成器的种子 + void TakeScreenshot(const char *fileName); //拍摄当前屏幕的屏幕截图(文件扩展名定义格式) + void SetConfigFlags(unsigned int flag); //设置初始化配置标志(查看flags) + void TraceLog(int logLevel, const char *text, …); //显示跟踪日志消息(log_DEBUG、log_INFO、log_WARNING、log_ERROR…) + void SetTraceLogLevel(int logLevel); //设置当前阈值(最小)日志级别 + void *MemAlloc(int size); //内部内存分配器 + void *MemRealloc(void *ptr, int size); //内部内存重新定位程序 + void MemFree(void *ptr); //内部内存可用 + void OpenURL(const char*url); //使用默认系统浏览器打开URL(如果可用) + + //设置自定义回调 + //警告:回调设置适用于高级用户 + void SetTraceLogCallback(TraceLogCallback回调); //设置自定义跟踪日志 + void SetLoadFileDataCallback(LoadFileData回调); //设置自定义文件二进制数据加载器 + void SetSaveFileDataCallback(SaveFileData回调); //设置自定义文件二进制数据保护程序 + void SetLoadFileTextCallback(LoadFileText回调); //设置自定义文件文本数据加载器 + void SetSaveFileTextCallback(SaveFileText回调); //设置自定义文件文本数据保护程序 + + //文件管理功能 + unsigned char*LoadFileData(const char *fileName, unsigned int *bytesRead); //将文件数据加载为字节数组(读取) + void UnloadFileData(unsigned char *data); //卸载LoadFileData()分配的文件数据 + bool SaveFileData(const char *fileName, void*data, unsigned int bytesToWrite); //将数据从字节数组保存到文件(写入), 成功时返回true + bool ExportDataAsCode(const char *data, unsigned int size, const char *fileName); //将数据导出到代码(.h), 成功时返回true + char*LoadFileText(constchar *fileName); //从文件加载文本数据(读取), 返回以“\0”结尾的字符串 + void UnloadFileText(char *text); //卸载LoadFileText()分配的文件文本数据 + bool SaveFileText(const char *fileName, char *text); //将文本数据保存到文件(写入), 字符串必须以“\0”结尾, 成功时返回true + bool FileExists(const char *fileName); //检查文件是否存在 + bool DirectoryExists(const char *dirPath); //检查目录路径是否存在 + bool IsFileExtension(const char *fileName, const char *ext); //检查文件扩展名(包括点:.png、.wav) + int GetFileLength(const char *fileName); //获取以字节为单位的文件长度(注意:GetFileSize()与windows冲突。小时) + const char*GetFileExtension(const char *fileName); //获取指向文件名字符串扩展名的指针(包括点:“.png”) + const char*GetFileName(const char *filePath); //获取路径字符串的文件名指针 + const char*GetFileNameWithoutExt(const char *filePath); //获取不带扩展名的文件名字符串(使用静态字符串) + const char*GetDirectoryPath(const char *filePath); //获取带有路径的给定fileName的完整路径(使用静态字符串) + const char*GetPrevDirectoryPath(const char *dirPath); //获取给定路径的上一个目录路径(使用静态字符串) + const char*GetWorkingDirectory(void); //获取当前工作目录(使用静态字符串) + const char*GetApplicationDirectory(void); //如果正在运行的应用程序(使用静态字符串), 则获取目录 + bool ChangeDirectory(const char *dir); //更改工作目录, 成功时返回true + bool IsPathFile(const char *path); //检查给定路径是文件还是目录 + FilePathList LoadDirectoryFiles(const char *dirPath); //加载目录文件路径 + FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdir); //使用扩展筛选和递归目录扫描加载目录文件路径 + void UnloadDirectoryFiles(FilePathList文件); //卸载文件路径 + bool IsFileDropped(void); //检查文件是否已放入窗口 + FilePathList LoadDroppedFiles(void); //加载删除的文件路径 + void UnloadDroppedFiles(FilePathList files); //卸载删除的文件路径 + long GetFileModTime(const char *fileName); //获取文件修改时间(上次写入时间) + + //压缩/编码功能 + unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); //压缩数据(DEFLATE算法), 内存必须为MemFree() + unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); //解压缩数据(DEFLATE算法), 内存必须为MemFree() + char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); //将数据编码为Base64字符串, 内存必须为MemFree() + unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); //解码Base64字符串数据, 内存必须为MemFree() + + //------------------------------------------------------------------------------------ + //输入处理功能(模块:核心) + //------------------------------------------------------------------------------------ + + //输入相关功能:键盘 + bool IsKeyPressed(int键); //检查是否按下了一次键 + bool IsKeyDown(int键); //检查是否按下了键 + bool IsKeyReleased(int key); //检查按键是否已释放一次 + bool IsKeyUp(int key); //检查是否未按下按键 + void SetExitKey(int key); //设置自定义键以退出程序(默认为ESC) + int GetKeyPressed(void); //按下按键(keycode), 对排队的按键多次调用, 当队列为空时返回0 + int GetCharPressed(void); //获取已按下的字符(unicode), 对已排队的字符多次调用, 当队列为空时返回0 + + //输入相关功能:Gamepads + bool IsGamepad可用(int gamepad); //检查游戏机是否可用 + const char*GetGamepadName(int gamepad); //获取游戏机内部名称id + bool IsGamepadButtonPressed(intGamepads, int按钮); //检查游戏机按钮是否已按下一次 + bool IsGamepadButtonDown(intGamepads, int按钮); //检查是否按下了游戏机按钮 + bool IsGamepadButtonReleased(intGamepads, int按钮); //检查游戏机按钮是否已释放一次 + bool IsGamepadButtonUp(intGamepads, int按钮); //检查是否未按下游戏机按钮 + int GetGamepadButtonPressed(void); //按下最后一个游戏机按钮 + int GetGamepadAxisCount(intGamepads); //获取游戏机的游戏机轴计数 + float GetGamepadAxisMovement(intGamepads, int轴); //获取游戏机轴的轴移动值 + int SetGamepadMappings(const char *映射); //设置内部游戏机映射(SDL_GameControllerDB) + + //输入相关功能:鼠标 + bool IsMouseButtonPressed(int按钮); //检查是否按下了一次鼠标按钮 + bool IsMouseButtonDown(int按钮); //检查是否按下了鼠标按钮 + bool IsMouseButtonRelease(int按钮); //检查鼠标按钮是否已释放一次 + bool IsMouseButtonUp(int按钮); //检查是否未按下鼠标按钮 + int GetMouseX(void); //获取鼠标位置X + int GetMouseY(void); //获取鼠标位置Y + Vector2 GetMousePosition(void); //获取鼠标位置XY + Vector2 GetMouseDelta(void); //获取帧之间的鼠标增量 + void SetMousePosition(int x, int y); //设置鼠标位置XY + void SetMouseOffset(int offsetX, int offsetY); //设置鼠标偏移 + void SetMouseScale(float scaleX,float scaleY); //设置鼠标缩放 + float GetMouseWheelMove(void); //获取X或Y的鼠标滚轮移动, 以较大者为准 + Vector2 GetMouseWheelMoveV(void); //获取X和Y方向的鼠标滚轮移动 + void SetMouseCursor(int鼠标光标); //设置鼠标光标(原文:Set Mouse Cursor) + + //输入相关功能:触摸 + int GetTouchX(void); //获取触摸点0的触摸位置X(相对于屏幕大小) + int GetTouchY(void); //获取触摸点0的触摸位置Y(相对于屏幕大小) + Vector2 GetTouchPosition(int index); //获取触摸点索引的触摸位置XY(相对于屏幕大小) + int GetTouchPointId(int index); //获取给定索引的接触点标识符 + int GetTouchPointCount(void); //获取接触点数量 + + //------------------------------------------------------------------------------------ + //手势和触摸处理功能(模块:手势) + //------------------------------------------------------------------------------------ + void SetGesturesEnabled(unsigned int flag); //使用标志启用一组手势 + bool IsGestureDetected(int手势); //检查是否检测到手势 + int GetGestureDetected(void); //获取最新检测到的手势 + float GetGestureHoldDuration(void); //获取手势保持时间(毫秒) + Vector2 GetGestureDragVector(void); //获取手势拖动矢量 + float GetGestureDragAngle(void); //获取手势拖动角度 + Vector2 GetGesturePinchVector(void); //获取手势捏三角 + float GetGesturePinchAngle(void); //获取手势捏角 + + //------------------------------------------------------------------------------------ + //摄像头系统功能(模块:rcamera) + //------------------------------------------------------------------------------------ + void SetCameraMode(Camera camera, int mode); //设置相机模式(多种相机模式可用) + void UpdateCamera(Camera*camera); //更新所选模式的相机位置 + void SetCameraPanControl(int keyPan); //设置相机平移键以与鼠标移动相结合(自由相机) + void SetCameraAltControl(int keyAlt); //设置相机alt键以与鼠标移动相结合(自由相机) + void SetCameraSmoothZoomControl(int keySmoothZoom); //设置相机平滑缩放键以与鼠标结合(自由相机) + void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int key Up, int keyDown); //设置摄像机移动控制(第一人称和第三人称摄像机) + diff --git a/cheatsheet/zh/raylib_models.c b/cheatsheet/zh/raylib_models.c new file mode 100644 index 0000000..c4eed24 --- /dev/null +++ b/cheatsheet/zh/raylib_models.c @@ -0,0 +1,93 @@ + + //模块:rmodels + //基本几何3D形状绘图功能 + void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); //在三维世界空间中绘制直线 + void DrawPoint3D(Vector3位置, Color color); //在三维空间中绘制一个点, 实际上是一条细线 + void DrawCircle3D(Vector3中心, float半径, Vector3旋转轴, float旋转角度, Color color); //在三维世界空间中绘制圆 + void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color); //绘制一个彩色填充三角形(顶点按逆时针顺序!) + void DrawTriangleStrip3D(Vector3 *点, int点计数, Color color); //绘制由点定义的三角形条带 + void DrawCube(Vector3位置, float宽度, float高度, float长度, Color color); //绘制立方体 + void DrawCubeV(Vector3位置, Vector3大小, Color color); //绘制立方体(矢量版本) + void DrawCubeWires(Vector3位置, float宽度, float高度, float长度, Color color); //绘制立方体线 + void DrawCubeWiresV(Vector3位置, Vector3大小, Color color); //绘制立方体线(矢量版本) + void DrawCubeTexture(Texture2D texture, Vector3位置, float宽度, float高度, float长度, Color color); //绘制立方体Texture + void DrawCubeTextureRec(Texture2D texture, Rectangle源, Vector3位置, float宽度, float高度, float长度, Color color); //使用Texture区域绘制立方体 + void DrawSphere(Vector3 centerPos, float半径, Color color); //绘制球体 + void DrawSphereEx(Vector3 centerPos, float半径, int rings,int slices, Color color); //使用扩展参数绘制球体 + void DrawSphereWires(Vector3 centerPos, float半径, int rings,int slices, Color color); //绘制球体导线 + void DrawCylinder(Vector3位置, float半径顶部, float半径底部, float高度, int slices, Color color); //绘制圆柱体/圆锥体 + void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color Color); //绘制底部位于startPos, 顶部位于endPos的圆柱体 + void DrawCylinderWires(Vector3位置, float半径顶部, float半径底部, float高度, int slices, Color color); //绘制圆柱体/圆锥体导线 + void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color Color); //绘制圆柱体导线, 底部位于startPos, 顶部位于endPos + void DrawPlane(Vector3 centerPos, Vector2大小, Color color); //绘制平面XZ + void DrawRay(Ray ray, Color color); //绘制光线线 + void DrawGrid(int slices, float间距); //绘制Mesh(以(0, 0, 0)为中心) + + //------------------------------------------------------------------------------------ + //Model 3d加载和绘图功能(模块:Model) + //------------------------------------------------------------------------------------ + + //Model管理功能 + Model LoadModel(const char *fileName); //从文件加载Model(Mesh和材质) + Model LoadModelFromMesh(Mesh mesh); //从生成的Mesh LoadModel(默认材质) + void UnloadModel(Model model); //从内存(RAM和/或VRAM)卸载Model(包括Mesh) + void UnloadModelKeepMeshes(Model model); //从内存(RAM和/或VRAM)卸载Model(但不卸载Mesh) + BoundingBox GetModelBoundingBox(Model model); //计算Model边界框限制(考虑所有Mesh) + + //Model绘图功能 + void DrawModel(Model Model, Vector3位置, float比例, Color color); //绘制Model(如果设置了Texture) + void DrawModelEx(Model Model, Vector3位置, Vector3旋转轴, float旋转角度, Vector3比例, Color color); //使用扩展参数绘制Model + void DrawModelWires(Model Model, Vector3位置, float比例, Color color); //绘制Model导线(如果设置了Texture) + void DrawModelWiresEx(Model Model, Vector3位置, Vector3旋转轴, float旋转角度, Vector3比例, Color color); //使用扩展参数绘制Model导线(如果设置了Texture) + void DrawBoundingBox(BoundingBox框, Color color); //绘制边界框(导线) + void DrawBillboard(摄影机, Texture2D texture, Vector3位置, float大小, Color color); //绘制广告牌Texture + void DrawBillboardRec(摄影机, Texture2D texture, Rectangle源, Vector3位置, Vector2大小, Color color); //绘制源定义的公告牌Texture + void DrawBillboardPro(摄影机, Texture2D texture, Rectangle源, Vector3位置, Vector3向上, Vector2大小, Vector2原点, float旋转, Color color); //绘制由源和旋转定义的公告牌Texture + + //Mesh管理功能 + void UploadMesh(Mesh *mesh, bool dynamic); //在GPU中上载Mesh顶点数据并提供VAO/VBO ID + void UpdateMeshBuffer(Mesh mesh, int索引, const void *data, int dataSize, int偏移量); //为特定缓冲区索引更新GPU中的Mesh顶点数据 + void UnloadMesh(Mesh mesh); //从CPU和GPU卸载Mesh数据 + void DrawMesh(Mesh mesh, Material material, Matrix transform); //使用材质和变换绘制三维网格 + void DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances); //使用材质和不同变换绘制多个Mesh实例 + bool ExportMesh(Mesh mesh, const char *fileName); //将Mesh数据导出到文件, 成功时返回true + BoundingBox GetMeshBoundingBox(Mesh mesh); //计算Mesh边界框限制 + void GenMeshTangents(Mesh *mesh); //计算Mesh切线 + + //Mesh生成函数 + Mesh GenMeshPoly(int sides, float radius); //生成多边形网格 + Mesh GenMeshPlane(float宽度, float长度, int resX, int resZ); //生成平面Mesh(带细分) + Mesh GenMeshCube(float宽度, float高度, float长度); //生成长方体网格 + Mesh GenMeshSphere(float半径, int rings,int slices); //生成球体Mesh(标准球体) + Mesh GenMeshHemiSphere(float半径, int rings,int slices); //生成半球形Mesh(无底帽) + Mesh GenMeshCylinder(float半径, float高度, int slices); //生成圆柱体网格 + Mesh GenMeshCone(float半径, float高度, int slices); //生成圆锥体/棱锥体网格 + Mesh GenMeshTorus(float半径, float大小, int radSeg, int边); //生成圆环体网格 + Mesh GenMeshKnot(float半径, float大小, int radSeg, int边); //生成三叶结网格 + Mesh GenMeshHeightmap(Image高度贴图, Vector3大小); //从图像数据生成高度图网格 + Mesh GenMeshCubicmap(Image立方体贴图, Vector3立方体大小); //从图像数据生成基于立方体的地图网格 + + //材料装载/卸载功能 + Material *加载Materials(const char *fileName, int *materialCount); //从Model文件加载材质 + Material LoadMaterialDefault(void); //加载默认材质(支持:DIFFUSE, SPECULAR, NORMAL贴图) + void UnloadMaterial(Material material); //从GPU内存(VRAM)卸载材料 + void SetMaterialTexture(Material *material, int mapType, Texture2D texture); //为材质贴图类型(material_map_DIFFUSE, material.map_SPECULAR…)设置Texture + void SetModelMeshMaterial(Model *Model, int meshId, int materialId); //设置Mesh的材质 + + //Model动画加载/卸载功能 + ModelAnimation *LoadModelAnimations(const char *fileName, unsigned int *animCount); //从文件加载Model动画 + void UpdateModelAnimation(Model Model, ModelAnimation动画, int帧); //更新Model动画姿势 + void UnloadModelAnimation(ModelAnimation动画); //卸载动画数据 + void UnloadModelAnimations(ModelAnimation *动画, unsigned int计数); //卸载动画阵列数据 + bool IsModelAnimationValid(Model Model, Model动画动画); //检查Model动画骨架匹配 + + //碰撞检测功能 + bool CheckCollisionSpheres(Vector3中心1, float半径1, Vector3中心2, float半径2); //检查两个球体之间的碰撞 + bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); //检查两个边界框之间的碰撞 + bool CheckCollisionBoxSphere(BoundingBox框, Vector3中心, float半径); //检查长方体和球体之间的碰撞 + RayCollision GetRayCollisionSphere(Ray ray, Vector3中心, float半径); //获取光线和球体之间的碰撞信息 + RayCollision GetRayCollisionBox(Ray ray, BoundingBox框); //获取光线和长方体之间的碰撞信息 + RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); //获取光线和Mesh之间的碰撞信息 + RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); //获取光线和三角形之间的碰撞信息 + RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); //获取光线和四边形之间的碰撞信息 + diff --git a/cheatsheet/zh/raylib_shapes.c b/cheatsheet/zh/raylib_shapes.c new file mode 100644 index 0000000..3c67ef6 --- /dev/null +++ b/cheatsheet/zh/raylib_shapes.c @@ -0,0 +1,58 @@ + + //模块:rshapes + //设置要用于形状绘图的Texture和Rectangle + //注意:当使用基本形状和单个Font时, + //定义 Font字符白色Rectangle将允许在一次绘制调用中绘制所有内容 + void SetShapesTexture(Texture2D texture, Rectangle source); //设置要用于形状绘图的Texture和Rectangle + + //基本形状绘图功能 + void DrawPixel(int posX, int posY, Color color); //绘制像素 + void DrawPixelV(Vector2位置, Color); //绘制像素(矢量版本) + void DrawLine(int 起始点X, int 起始端点Y, int 终止端点X, int 终止端点Y, Color color); //画一条线 + void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); //绘制直线(矢量版本) + void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color); //绘制定义厚度的线 + void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color Color); //使用三次贝塞尔曲线绘制直线 + void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color Color); //使用带有控制点的二次贝塞尔曲线绘制直线 + void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos、float thick、Color); //使用具有2个控制点的三次贝塞尔曲线绘制直线 + void DrawLineStrip(Vector2*点, int点计数, Color color); //绘制线序列 + void DrawCircle(int centerX, int centerY, float半径, Color color); //绘制颜色填充的圆 + void DrawCircleSector(Vector2中心, float半径, float startAngle, float endAngle, int段, Color color); //画一个圆 + void DrawCircleSectorLines(Vector2中心, float半径, float startAngle, float endAngle, int段, Color color); //绘制圆扇形轮廓 + void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); //绘制渐变填充圆 + void DrawCircleV(Vector2中心, float半径, Color color); //绘制颜色填充的圆(矢量版本) + void DrawCircleLines(int centerX, int centerY, float半径, Color color); //绘制圆轮廓 + void DrawEllipse(int centerX, int centerY, float半径H, float半径V, Color color); //绘制椭圆 + void DrawEllipseLines(int centerX, int centerY, float半径H, float半径V, Color color); //绘制椭圆轮廓 + void DrawRing(Vector2中心, float innerRadius, float outerRadius、float startAngle、float endAngle、int段、Color color); //牵引环 + void DrawRingLines(Vector2中心, float innerRadius, float outerRadius、float startAngle、float endAngle、int段、Color color); //绘制环形轮廓 + void DrawRectangle(int posX, int posY, int width, int height, Color Color); //绘制填充颜色的Rectangle + void DrawRectangle V(Vector2位置, Vector2大小, Color color); //绘制彩色填充Rectangle(矢量版) + void DrawRectangleRec(Rectangle rec, Color color); //绘制填充颜色的Rectangle + void DrawRectanglePro(Rectangle rec, Vector2原点, float旋转, Color color); //用pro参数绘制一个填充颜色的Rectangle + void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2); //绘制垂直渐变填充Rectangle + void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2); //绘制水平渐变填充Rectangle + void DrawRectangleGradientEx(Rectangle rec, 颜色col1, 颜色col2, 颜色col3, 颜色col4); //使用自定义顶点颜色绘制渐变填充Rectangle + void DrawRectangleLines(int posX, int posY, int width, int height, Color Color); //绘制Rectangle轮廓 + void DrawRectangleLinesEx(Rectangle rec, float lineThick, Color color); //使用扩展参数绘制Rectangle轮廓 + void DrawRectangleRounded(Rectangle rec, float圆度, int段, Color color); //绘制圆角Rectangle + void DrawRectangleRoundedLines(Rectangle rec, float圆度, int段, float线厚, Color color); //绘制带有圆角边缘轮廓的Rectangle + void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); //绘制一个彩色填充三角形(顶点按逆时针顺序!) + void DrawTriangleLines(Vector2 v1、Vector2 v2、Vector2 v3、Color color); //绘制三角形轮廓(顶点按逆时针顺序!) + void DrawTriangleFan(Vector2*点, int点计数, Color color); //绘制由点定义的三角形扇形(第一个顶点是中心) + void DrawTriangleStrip(Vector2*点, int点计数, Color color); //绘制由点定义的三角形条带 + void DrawPoly(Vector2中心, int边, float半径, float旋转, Color color); //绘制正多边形(矢量版本) + void DrawPolyLines(Vector2中心、int边、float半径、float旋转、Color color); //绘制n条边的多边形轮廓 + void DrawPolyLinesEx(Vector2中心, int边, float半径, float旋转, float线厚, Color color); //使用扩展参数绘制n条边的多边形轮廓 + + //基本形状碰撞检测功能 + bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); //检查两个Rectangle之间的碰撞 + bool CheckCollisionCircles(Vector2中心1, float半径1, Vector2中心2, float半径2); //检查两个圆之间的碰撞 + bool CheckCollisionCircleRec(Vector2中心, float半径, Rectangle rec); //检查圆和Rectangle之间的碰撞 + bool CheckCollisionPointRec(Vector2点, Rectangle rec); //检查点是否在Rectangle内 + bool CheckCollisionPointCircle(Vector2点, Vector2中心, float半径); //检查点是否在圆内 + bool CheckCollisionPointTriangle(Vector2点, Vector2 p1, Vector2 p2, Vector2 p3); //检查点是否在三角形内 + bool CheckCollisionLines(Vector2 startPos1、Vector2 endPos1、向量2 startPos2、Vector2 endPos2、向量2*碰撞点); //检查由每个两点定义的两条直线之间的碰撞, 通过引用返回碰撞点 + bool CheckCollisionPointLine(Vector2点, Vector2 p1, Vector2 p2, int阈值); //检查点是否属于两点[p1]和[p2]之间创建的线, 并以像素为单位定义了边距[threshold] + Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); //获取两个Rectangle碰撞的碰撞Rectangle + +
\ No newline at end of file diff --git a/cheatsheet/zh/raylib_structs.c b/cheatsheet/zh/raylib_structs.c new file mode 100644 index 0000000..6b3662c --- /dev/null +++ b/cheatsheet/zh/raylib_structs.c @@ -0,0 +1,43 @@ + + //结构体 + struct Vector2; //Vector2类型 + struct Vector3; //Vector3类型 + struct Vector4; //Vector4类型 + struct Quaternion; //四元数类型 + struct Matrix; //矩阵类型(OpenGL风格4x4) + struct Color; //颜色类型,RGBA(32位) + struct Rectangle; //Rectangle类型(矩阵类型) + + struct Image; //图像类型(支持多种像素格式) + //注:数据存储在CPU内存(RAM)中 + struct Texture; //Texture类型(支持多种内部格式) + //注:存储在GPU内存(VRAM)中的数据,可以直接被绘制到屏幕上 + struct RenderTexture; //RenderTexture型,用于Texture渲染 + struct NPatchInfo; //N-补丁布局信息 + struct GlyphInfo; //字体字符字形信息 + struct Font; //字体类型,包括Texture和字符数据 + + struct Camera; //相机类型,定义三维相机位置/方向 + struct Camera2D; //Camera2D类型,定义 2d相机 + struct Mesh; //定义 Mesh的顶点数据 + struct Shader; //着色器类型(常规着色器) + struct MaterialMap; //材质Texture贴图 + struct Material; //材料类型 + struct Model; //基本三维Model类型 + struct Transform; //变换(用于骨骼) + struct BoneInfo; //骨骼信息 + struct ModelAnimation; //Model动画数据(骨骼和帧) + struct Ray; //光线类型(用于光线投射) + struct RayCollision; //光线投射命中信息 + struct BoundingBox; //三维Mesh的边界框类型 + + struct Wave; //Wave类型,定义音频Wave数据 + struct Sound; //基本声源和缓冲区 + struct Music; //音乐类型(来自内存的文件流) + struct AudioStream; //原始音频流类型 + + struct VrDeviceInfo; //VR设备参数 + struct VrStereoConfig; //模拟器的VR立体渲染配置 + + struct FilePathList; //文件路径列表 + diff --git a/cheatsheet/zh/raylib_text.c b/cheatsheet/zh/raylib_text.c new file mode 100644 index 0000000..cd4bf66 --- /dev/null +++ b/cheatsheet/zh/raylib_text.c @@ -0,0 +1,55 @@ + + //模块:rtext + //字体 Load/卸载功能 + Font GetFontDefault(void); //获取默认字体 + Font LoadFont(const char *fileName); //将字体从文件加载到GPU内存(VRAM) + Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount); //使用扩展参数从文件中LoadFont, fontChars使用NULL, glyphCount使用0来加载默认字符集 + Font LoadFontFromImage(Image Image, Color key, int firstChar); //从图像 LoadFont(XNA样式) + Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); //从内存缓冲区LoadFont, fileType引用扩展名:即'。ttf' + GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount, int type); //LoadFont数据以供进一步使用 + Image GenImageFontAtlas(const GlyphInfo *char, Rectangle **recs, int glyphCount, int fontSize, int padding, int packMethod); //使用字符信息生成图像 字体图集 + void UnloadFontData(GlyphInfo *字符, int glyphCount); //卸载字体字符信息数据(RAM) + void UnloadFont(Font 字体); //从GPU内存(VRAM)卸载字体 + bool ExportFontAsCode(Font, const char *fileName); //将字体导出为代码文件, 成功时返回true + + //文本绘图功能 + void DrawFPS(int posX, int posY); //绘制当前FPS + void DrawText(const char *text, int posX, int posY, int fontSize, Color Color); //绘制文本(使用默认字体) + void DrawTextEx(Font Font、const char *文本、Vector2位置、float Font大小、float间距、Color Color); //使用Font和其他参数绘制文本 + void DrawTextPro(Font Font、const char *文本、Vector2位置、Vector2原点、float旋转、float Font大小、float间距、Color Color); //使用字体和pro参数绘制文本(旋转) + void DrawTextCodepoint(Font Font, int代码点, Vector2位置, float Font大小, Color Color); //绘制一个字符(代码点) + void DrawTextCodepoints(Font Font, constint *代码点, int计数, Vector2位置, float Font大小, float间距, Color Color); //绘制多个字符(代码点) + + //文本字体信息功能 + int MeasureText(const char *text, int fontSize); //测量默认字体font的字符串宽度 + Vector2 MeasureTextEx(Font、const char *文本、float Font大小、float间距); //测量字体的字符串大小 + int GetGlyphIndex(Font, int代码点); //获取代码点(unicode字符)Font中的字形索引位置, 回退到“?”如果未找到 + GlyphInfo GetGlyphInfo(Font, int码点); //获取代码点(unicode字符)的字形字体信息数据, 回退到“?”如果未找到 + Rectangle GetGlyphAtlasRec(Font, int代码点); //获取代码点(unicode字符)字体图集中的字形Rectangle, 回退到“?”如果未找到 + + //文本代码点管理功能(unicode字符) + int *LoadCodepoints(const char *text, int *count); //从UTF-8文本字符串加载所有代码点, 参数返回代码点计数 + void UnloadCodepoints(int *代码点); //从内存中卸载代码点数据 + int GetCodepointCount(const char *text); //获取UTF-8编码字符串中的代码点总数 + int GetCodepoint(const char *text, int *bytesProcessed); //获取UTF-8编码字符串中的下一个代码点, 失败时返回0x3f(“?”) + const char *CodepointToUTF8(int码点, int *字节大小); //将一个代码点编码为UTF-8字节数组(数组长度作为参数返回) + char *TextCodepointsToUTF8(constint *码点, int长度); //将文本作为代码点数组编码为UTF-8文本字符串(警告:必须释放内存!) + + //文本字符串管理功能(没有UTF-8字符串, 只有字节字符) + //注意:有些字符串在内部为返回的字符串分配内存, 请小心! + int TextCopy(char *dst, const char *src); //将一个字符串复制到另一个字符串, 返回复制的字节 + bool TextIsEqual(const char *text1, const char *text2); //检查两个文本字符串是否相等 + unsigned int TextLength(const char *text); //获取文本长度, 检查“\0”结尾 + const char *TextFormat(const char *text, …); //带变量的文本格式(sprintf()样式) + const char *TextSubtext(const char *text, int位置, int长度); //获取一段文本字符串 + char *TextReplace(char *文本, constchar *替换, constchar *by); //替换文本字符串(警告:必须释放内存!) + char *TextInsert(const char *文本, const char *insert, int位置); //在某个位置插入文本(警告:必须释放内存!) + const char *TextJoin(const char * *textList, int count, const char *分隔符); //使用分隔符连接文本字符串 + const char * *TextSplit(const char *文本, 字符分隔符, int *计数); //将文本拆分为多个字符串 + void TextAppend(char *text, const char *append, int *position); //在特定位置附加文本并移动鼠标光标! + int TextFindIndex(const char *text, const char *find); //查找字符串中出现的第一个文本 + const char *TextToUpper(const char *text); //获取所提供字符串的大写版本 + const char *TextToLower(const char *text); //获取所提供字符串的小写版本 + const char *TextToPascal(const char *文本); //获取所提供字符串的Pascal大小写符号版本 + int TextToInteger(const char *文本); //从文本中获取整数值(不支持负值) + diff --git a/cheatsheet/zh/raylib_textures.c b/cheatsheet/zh/raylib_textures.c new file mode 100644 index 0000000..bb49500 --- /dev/null +++ b/cheatsheet/zh/raylib_textures.c @@ -0,0 +1,116 @@ + + //模块:rtextures + //Image加载功能 + //注意:此功能不需要GPU访问 + Image LoadImage(const char *fileName); //将图像从文件加载到CPU内存(RAM) + Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); //从RAW文件数据加载图像 + Image LoadImageAnim(const char *fileName, int *frames); //从文件加载图像序列(附加到图像.data的帧) + Image LoadImageFromMemory(const char *fileType, const unsigned char*fileData, int dataSize); //从内存缓冲区加载图像, fileType引用扩展名:即'。png' + Image LoadImageFromTexture(Texture2D texture); //从GPUTexture数据加载图像 + Image LoadImageFromScreen(void); //从屏幕缓冲区加载图像(屏幕截图) + void UnLoadImage(Image Image); //从CPU内存(RAM)卸载图像 + bool ExportImage(Image Image, const char*fileName); //将图像数据导出到文件, 成功时返回true + bool ExportImageAsCode(Image Image, constchar*fileName); //将图像导出为定义字节数组的代码文件, 成功时返回true + + //Image生成功能 + Image GenImageColor(int width, int height, Color Color); //生成图像:纯色 + Image GenImageGradientV(int width, int height, Color top, Color bottom); //生成图像:垂直渐变 + Image GenImageGradientH(int width, int height, Color left, Color right); //生成图像:水平渐变 + Image GenImageGradientRadial(int width, int height, float density, Color inner, Color outer); //生成图像:径向渐变 + Image GenImageChecked(int width, int height, int checksX, int checks Y, Color col1, Color col2); //生成图像:选中 + Image GenImageWhiteNoise(int width, int height, float factor); //生成图像:白噪声 + Image GenImageCellular(int width, int height, int tileSize); //生成图像:细胞算法, 更大的tileSize意味着更大的细胞 + + //Image处理功能 + Image ImageCopy(Image Image); //创建图像副本(用于变换) + Image ImageFrom图像(Image Image, Rectangle记录); //从其他图像片段创建图像 + Image ImageText(const char *text, int fontSize, Color Color); //从文本创建图像(默认字体) + Image ImageTextEx(Font、const char *文本、float Font大小、float间距、颜色色调); //从文本创建图像(自定义精灵字体) + void ImageFormat(Image *Image, int newFormat); //将图像数据转换为所需格式 + void ImageToPOT(Image *Image, 颜色填充); //将图像转换为POT(2的幂) + void ImageCrop(Image *Image, Rectangle裁剪); //将图像裁剪为定义的Rectangle + void ImageAlphaCrop(Image *Image, float阈值); //根据alpha值裁剪图像 + void ImageAlphaClear(Image *Image, Color color, float阈值); //将alpha通道清除为所需颜色 + void ImageAlphaMask(Image *Image, Image alphaMask); //对图像应用alpha遮罩 + void ImageAlphaPremultiply(Image *Image); //预乘alpha通道 + void ImageResize(Image *Image, int newWidth, int newHeight); //调整图像大小(双三次缩放算法) + void ImageResizeNN(Image *Image, int newWidth, int newHeight); //调整图像大小(最近邻缩放算法) + void ImageResizeCanvas(Image *Image, int newWidth, int newHeight, int offsetX, int offset Y, 颜色填充); //调整画布大小并填充颜色 + void ImageMipmaps(Image *Image); //计算所提供图像的所有mipmap级别 + void ImageDither(Image *Image, int rBpp, int gBpp, intbBpp, IntaBpp); //抖动图像数据至16bpp或更低(Floyd Steinberg抖动) + void ImageFlipVertical(Image *Image); //垂直翻转图像 + void ImageFlipHorizontal(Image *Image); //水平翻转图像 + void ImageRotateCW(Image *Image); //顺时针旋转图像 90度 + void ImageRotateCW(Image *Image); //逆时针旋转图像 90度 + void ImageColorTint(Image *Image, Color color); //修改图像颜色:色调 + void ImageColorInvert(Image *Image); //修改图像颜色:反转 + void ImageColorGrayscale(Image *Image); //修改图像颜色:灰度 + void ImageColorContrast(Image *Image, float对比度); //修改图像颜色:对比度(-100到100) + void ImageColorBrightness(Image *Image, int亮度); //修改图像颜色:亮度(-255到255) + void ImageColorReplace(Image *Image, Color color, Color replace); //修改图像颜色:替换颜色 + Color *LoadImageColors(Image Image); //将图像中的颜色数据加载为颜色阵列(RGBA-32位) + Color *LoadImagePalette(Image Image, int maxPaletteSize, int *colorCount); //从图像 Load调色板作为颜色阵列(RGBA-32位) + void UnloadImageColors(Color *colors); //卸载用加载图像Colors()加载的颜色数据 + void UnloadImagePalette(Color *colors); //卸载用加载图像Palette()加载的调色板 + Rectangle GetImageAlphaBorder(Image Image, float阈值); //获取图像 alpha边框Rectangle + Color GetImageColor(Image Image, int x, int y); //获取(x, y)位置的图像像素颜色 + + //Image绘制功能 + //注:Image软件渲染功能(CPU) + void ImageClearBackground(Image *dst, Color color); //具有给定颜色的清晰图像背景 + void ImageDrawPixel(Image *dst, int posX, int posY, Color color); //在图像中绘制像素 + void ImageDrawPixelV(Image *dst, Vector2位置, Color color); //在图像中绘制像素(矢量版本) + void ImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, intendPosY, Color color); //在图像中绘制线条 + void ImageDrawLineV(Image *dst, Vector2开始, Vector2结束, Color color); //在图像中绘制线条(矢量版本) + void ImageDrawCircle(Image *dst, int centerX, int center Y, int radius, Color color); //在图像中绘制圆 + void ImageDrawCircleV(Image *dst, Vector2中心, int半径, Color color); //在图像中绘制圆(矢量版本) + void ImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color Color); //在图像中绘制Rectangle + void ImageDrawRectangleV(Image *dst, Vector2位置, Vector2大小, Color color); //在图像中绘制Rectangle(矢量版本) + void ImageDrawRectangleRec(Image *dst, Rectangle记录, Color color); //在图像中绘制Rectangle + void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); //在图像中绘制Rectangle线 + void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color color); //在目标图像中绘制源图像(应用于源的色调) + void ImageDrawText(Image *dst, constchar *text, int posX, int posY, int fontSize, Color color); //在图像(目标)中绘制文本(使用默认字体) + void ImageDrawTextEx(Image *dst, Font, const char *文本, Vector2位置, float Font大小, float间距, Color color); //在图像(目标)中绘制文本(自定义精灵字体) + + //Texture加载功能 + //注意:这些功能需要GPU访问 + Texture2D LoadTexture(const char *fileName); //将Texture从文件加载到GPU内存(VRAM) + Texture2D LoadTextureFrom图像(Image Image); //从图像数据加载Texture + TextureCubemap LoadTextureCubemap(Image Image, int布局); //从图像 Load立方体贴图, 支持多个图像立方体贴图布局 + RenderTexture2D LoadRenderTexture(int宽度, int高度); //加载用于渲染的Texture(帧缓冲区) + void UnloadTexture(Texture2D texture); //从GPU内存(VRAM)卸载Texture + void UnloadRenderTexture(RenderTexture2D目标); //从GPU内存(VRAM)卸载渲染Texture + void UpdateTexture(Texture2D texture, const void *像素); //使用新数据更新GPUTexture + void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *像素); //使用新数据更新GPUTextureRectangle + + //Texture配置功能 + void GenTextureMipmaps(Texture2D *texture); //为Texture生成GPU mipmap + void SetTextureFilter(Texture2D texture, int过滤器); //设置Texture缩放过滤器模式 + void SetTextureWrap(Texture2D texture, int wrap); //设置Texture包裹模式 + + //Texture绘制功能 + void DrawTexture(Texture2D texture, int posX, int posY, Color tint); //绘制Texture2D + void DrawTextureV(Texture2D texture, Vector2位置, Color tint); //绘制位置定义为Vector2的Texture2D + void DrawTextureEx(Texture2D texture、Vector2位置、float旋转、float比例、Color tint); //使用扩展参数绘制Texture2D + void DrawTextureRec(Texture2D texture, Rectangle源, Vector2位置, Color tint); //绘制由Rectangle 定义的Texture的一部分 + void DrawTextureQuad(Texture2D texture、Vector2平铺、Vector2偏移、Rectangle四边形、Color tint); //使用平铺和偏移参数绘制Texture四边形 + void DrawTextureTiled(Texture2D texture、Rectangle源、Rectangle目标、Vector2原点、float旋转、float比例、Color tint); //绘制Texture的一部分(由Rectangle 定义), 旋转并缩放平铺到dest。 + void DrawTexturePro(Texture2D texture、Rectangle源、Rectangle目标、Vector2原点、float旋转、Color tint); //使用“pro”参数绘制由Rectangle 定义的Texture的一部分 + void DrawTextureNPatch(Texture2D texture, NPatchInfo NPatchInfo, Rectangle目标, Vector2原点, float旋转, Color tint); //绘制可以很好地拉伸或收缩的Texture(或其一部分) + void DrawTexturePoly(Texture2D texture, Vector2中心, Vector2 *点, Vector2 *Texture坐标, int pointCount, Color tint); //绘制Texture多边形 + + //颜色/像素相关功能 + Color Fade(颜色, float alpha); //使用alpha获取颜色, alpha从0.0f变为1.0f + int ColorToInt(Color color); //获取颜色的十六进制值 + Vector4 ColorNormalize(Color color); //获取标准化为float的颜色[0..1] + Color ColorFromNormalized(Vector4规格化); //从规格化值[0..1]获取颜色 + Vector3 ColorToHSV(Color color); //获取颜色、色调[0..360]、饱和度/值[0..1]的HSV值 + Color ColorFromHSV(float色调、float饱和度、float值); //从HSV值、色调[0..360]、饱和度/值[0..1]获取颜色 + Color ColorAlpha(Color color, float alpha); //使用alpha获取颜色, alpha从0.0f变为1.0f + Color AlphaBlend(Color dst、Color src、Color tint); //将src alpha混合到带有色调的dst颜色中 + Color GetColor(unsigned int hexValue); //从十六进制值获取颜色struct + Color GetPixelColor(void *srcPtr, int格式); //从特定格式的源像素指针获取颜色 + void SetPixelColor(void *dstPtr, Color coloe, int格式); //设置格式化为目标像素指针的颜色 + int GetPixelDataSize(int宽度、int高度、int格式); //获取特定格式的像素数据大小(字节) + +
\ No newline at end of file |
