前言
我们在开发过程中经常会遇到需要对图片进行取色的情况
如果你也嫌弃下载取色软件麻烦
那么有一些顺手的工具可以满足我们的取色需求
使用Android Studio自带取色工具
在VCS版本管理关卡页面, 有一个取色工具


使用Chorme浏览器自带取色工具
进入控制台, 随便点击一个色块, 会弹出取色工具


本文为作者原创转载时请注明出处 谢谢

乱码三千 – 码出一个新世界
当前素材库中只有一张小草地图片, 如下:

如何将其铺满整个背景, 得到如下效果:

我们可能第一时间会想到使用Tilemap, 不过手动绘制相对来说有些费时间, 在Godot中我们有更好的方法可以实现
使用Sprite+图片repeat的方式实现
首先创建一个Sprite节点
将草地图片添加至该节点的Texture属性上

启用Region属性

在纹理区域框选需要进行repeat的区域

选中草地文件 然后在导入面板开启重复功能, 最后点击重新导入

此时我们在纹理区域拉伸选框, 则可以对草地小图片进行重复并铺满整个背景

使用TextureRect+Tile实现
创建TextureRect节点
将图片拖拽至该节点的Texture属性上

Stretch Mode属性选择Tile

此时拉伸图片则自动重复

本文为作者原创转载时请注明出处 谢谢

xmake 是一个基于 Lua 的轻量级跨平台构建工具,使用 xmake.lua维护项目构建, 相当于是cmake的增强版, 其优点如下:
Make/Ninja 那样可以直接编译项目CMake/Meson 那样生成工程文件C/C++依赖库的集成使用问题C/C++进行混合编译Ninja持平编译宿主平台: MAC
交叉编译目标平台: Linux, Windows, IOS, Android ….
下载xmake
1 | bash <(curl -fsSL https://xmake.io/shget.text -k) |
测试c代码准备 文件取名为main
1 | #include <stdio.h> |
在源码目录下新建xmake.lua文件
并加入以下配置
1 | add_rules("mode.debug", "mode.release") |
编译前的环境准备好了,那接下来 咱们挨个来实现目标平台的可执行文件生成
下载xcode
直接应用市场下载
给xmake指定编译目标平台
1 | xmake f -p iphoneos |
编译程序
1 | xmake build main |
编译成功后 可以在build目录中找到对应的可执行文件

给xmake指定编译目标平台
1 | xmake f -p macosx |
编译程序
1 | xmake build main |
编译成功后 可以在build目录中找到对应的可执行文件

执行程序
由于编译宿主平台刚好是Mac 所以我们可以直接执行程序
1 | xmake run main |

下载mingw-w64
1 | brew install mingw-w64 |
给xmake指定编译目标平台
1 | xmake f -p mingw |
或者使用图形化界面配置
1 | xmake f --menu |

配置完后 我们查看xmake的配置显示当前平台为mingw:

编译程序
1 | xmake build main |
编译成功后 我们可以在build目录下找到生成的exe可执行文件:
关于mingw内部编译器
我们打印编译信息会发现mingw内部采用的是gcc编译工具

下载NDK
给xmake指定编译目标平台
1 | xmake f -p android --ndk=ndk路径 |
此时我们查看xmake配置显示当前编译平台为android:

编译程序
1 | xmake build main |
编译成功后 可以在编译目录查看到生成的可执行文件

重置配置
1 | xmake f -c |
指定交叉编译工具
1 | xmake f --toolchain=clang |
查看当前工程信息和xmake信息
1 | xmake show |
编译过程中查看完整的编译选项
1 | xmake -rv |
查看当前配置
1 | xmake config -v |

卸载xmake
1 | xmake update --uninstall |
交叉编译报错 unknown platform for xcode!
解决方案: 卸载xmake重装
本文为作者原创转载时请注明出处 谢谢

目前主流的平台有:
当C/C++程序写好后 如何快速在当前平台编译出各个平台的可执行文件
现在比较成熟的方案有:
docker容器编译cmake构建交叉编译环境docker容器编译基于GCC套件, 可实现对Android, Linux, Windows, Web平台的交叉编译, 详细介绍如下:
dockcross/base
Base image for other toolchain images. From Debian Jessie with GCC, make, autotools, CMake, Ninja, Git, and Python.
dockcross/android-arm
The Android NDK standalone toolchain for the arm architecture.
dockcross/android-arm64
The Android NDK standalone toolchain for the arm64 architecture.
dockcross/linux-arm64
Cross compiler for the 64-bit ARM platform on Linux, also known as AArch64.
dockcross/linux-armv5
Linux armv5 cross compiler toolchain for legacy devices like the Parrot AR Drone.
dockcross/linux-armv5-musl
Linux armv5 cross compiler toolchain using musl as base “libc”.
dockcross/linux-armv6
Linux ARMv6 cross compiler toolchain for the Raspberry Pi, etc.
dockcross/linux-armv7
Generic Linux armv7 cross compiler toolchain.
dockcross/linux-armv7a
Toolchain configured for ARMv7-A used in Beaglebone Black single board PC with TI SoC AM3358 on board, Cortex-A8.
dockcross/linux-mipsel
Linux mipsel cross compiler toolchain for little endian MIPS GNU systems.
dockcross/linux-mips
Linux mips cross compiler toolchain for big endian 32-bit hard float MIPS GNU systems.
dockcross/linux-s390x
Linux s390x cross compiler toolchain for S390X GNU systems.
dockcross/linux-ppc64le
Linux PowerPC 64 little endian cross compiler toolchain for the POWER8, etc. Important: Due to Issue #430, automatic build of newer images has been disabled.
dockcross/linux-x64
Linux x86_64 / amd64 compiler. Since the Docker image is natively x86_64, this is not actually a cross compiler.
dockcross/linux-x86
Linux i686 cross compiler.
dockcross/manylinux2014-x64
Docker manylinux2014 image for building Linux x86_64 / amd64 Python wheel packages. It includes Python 3.5, 3.6, 3.7, 3.8, and 3.9. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX2014 to “TRUE” in the toolchain.
dockcross/manylinux2014-x86
Docker manylinux2014 image for building Linux i686 Python wheel packages. It includes Python 3.5, 3.6, 3.7, 3.8, and 3.9. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX2014 to “TRUE” in the toolchain.
dockcross/manylinux2014-aarch64
Docker manylinux2014 image for building Linux aarch64 / arm64 Python wheel packages. It includes Python 3.5, 3.6, 3.7, 3.8, and 3.9. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX2014 to “TRUE” in the toolchain.
dockcross/manylinux2010-x64
Docker manylinux2010 image for building Linux x86_64 / amd64 Python wheel packages. It includes Python 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX2010 to “TRUE” in the toolchain.
dockcross/manylinux2010-x86
Docker manylinux2010 image for building Linux i686 Python wheel packages. It includes Python 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX2010 to “TRUE” in the toolchain.
dockcross/manylinux1-x64
Docker manylinux1 image for building Linux x86_64 / amd64 Python wheel packages. It includes Python 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8. Also has support for the dockcross script, and it has installations of CMake, Ninja, and scikit-build. For CMake, it sets MANYLINUX1 to “TRUE” in the toolchain.
dockcross/manylinux1-x86
Docker manylinux1 image for building Linux i686 Python wheel packages. It includes Python 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8. Also has support for the dockcross script, and it has installations of CMake, Ninja, and [ scikit-build](http:// scikit-build.org/). For CMake, it sets MANYLINUX1 to “TRUE” in the toolchain.
dockcross/web-wasm
The Emscripten WebAssembly/asm.js/JavaScript cross compiler.
dockcross/windows-static-x64
64-bit Windows cross-compiler based on MXE/MinGW-w64 with win32 threads and static linking.
dockcross/windows-static-x64-posix
64-bit Windows cross-compiler based on MXE/MinGW-w64 with posix threads and static linking.
dockcross/windows-static-x86
32-bit Windows cross-compiler based on MXE/MinGW-w64 with win32 threads and static linking.
dockcross/windows-shared-x64
64-bit Windows cross-compiler based on MXE/MinGW-w64 with win32 threads and dynamic linking.
dockcross/windows-shared-x64-posix
64-bit Windows cross-compiler based on MXE/MinGW-w64 with posix threads and dynamic linking.
dockcross/windows-shared-x86
32-bit Windows cross-compiler based on MXE/MinGW-w64 with win32 threads and dynamic linking.
具体使用可参见Github
cmake构建交叉编译环境首先我们需要下载cmake构建工具
然后下载用于交叉编译的套件
以Mac平台为例, 如果我需要编译各个平台的可执行文件, 那么首先需要下载能在Mac平台运行的目标平台编译包, 比如:
android平台:下载 Mac平台可运行的NDK (基于clang)
ios平台: 下载iphoneos SDK, xcode自带 我们只需下载xcode即可 (基于clang)
windows平台:下载MinGW 或者 MXE/MinGW-w64 (基于GCC)
Linux平台:如 arm/x86-Linux-gnueabi套件(基于GCC)
本文为作者原创转载时请注明出处 谢谢

在c/c++语言编译时 我们经常能碰到关于静态库(static)和动态库(shared)的链接
那它们有什么区别呢
静态库(static)是程序在编译期间进行链接的, 它会被打包进可执行程序当中
动态库(shared)也叫共享库, 它是在程序运行是进行链接的, 以独立的文件存在, 不会被打包进可执行程序中, 但是程序在执行时需要能找到这个库的具体位置, 否则程序可能出错
| 系统 | 动态库后缀 | 静态库后缀 |
|---|---|---|
| Linux | .so | .a |
| Mac | .dylib | .a |
| Windows | .dll | .lib |
优势:
劣势:
优势:
bug, 只需修复并重新编译库即可劣势:
静态库和动态库, 没有孰优孰劣一说, 具体看实际的应用场景, 每种库都有它的用武之地
本文为作者原创转载时请注明出处 谢谢

下载时提示SSL certificate problem:
1 | curl: (60) SSL certificate problem: certificate has expired |
原因:
这是证书认证缺失导致,可以在请求时关闭ssl证书认证
解决方案:
命令行中加上-k即可, 如:
1 | curl -fsSL https://xmake.io/shget.text -k |
本文为作者原创转载时请注明出处 谢谢
