colourpicker

Simple Colour Picker written in C
git clone anongit@rnpnr.xyz:colourpicker.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: d2e606f937e0c7ce309a679ffc0b5f55dc84ddce
Parent: 37eaaf084fae255ef00009696ca78fcb7db3b6ae
Author: Randy Palamar
Date:   Fri,  9 Aug 2024 18:20:15 -0600

add release.yml and a proper builtin icon for win32

For future reference the icon is made with imagemagick:
convert assets/icon.svg -define icon:auto-resize=256,128,48,32,16 assets/colour_picker.ico

Diffstat:
A.github/workflows/release.yml | 38++++++++++++++++++++++++++++++++++++++
M.gitignore | 1+
Aassets/colour_picker.ico | 0
Aassets/colourpicker.rc | 22++++++++++++++++++++++
Aassets/icon.svg | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbuild.sh | 3++-
Mmain.c | 6+++---
7 files changed, 140 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + push: + tags: ["v*.*"] + +env: + CFLAGS: "-march=x86-64-v2 -O3" + +jobs: + github: + name: Build Windows Release + runs-on: windows-latest + permissions: + contents: write + env: + CC: clang + defaults: + run: + shell: msys2 {0} + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: clang64 + update: true + install: git mingw-w64-clang-x86_64-clang + pacboy: ninja:p cmake:p + - uses: actions/checkout@v4 + + - name: Build + run: ./build.sh + + - name: Upload Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: 'Colour Picker.exe' + diff --git a/.gitignore b/.gitignore @@ -1,3 +1,4 @@ +*.o *.so colourpicker config.h diff --git a/assets/colour_picker.ico b/assets/colour_picker.ico Binary files differ. diff --git a/assets/colourpicker.rc b/assets/colourpicker.rc @@ -0,0 +1,22 @@ +CAFE ICON "colour_picker.ico" + +1 VERSIONINFO +FILEVERSION 0,0,0,0 +PRODUCTVERSION 0,0,0,0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" // English US + BEGIN + VALUE "FileDescription", "Colour Picker" + VALUE "FileVersion", "0.0.0" + VALUE "InternalName", "Colour Picker" + VALUE "ProductName", "Colour Picker" + VALUE "ProductVersion", "0.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 // English US + END +END diff --git a/assets/icon.svg b/assets/icon.svg @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="256mm" + height="255.99998mm" + viewBox="0 0 256 255.99998" + version="1.1" + id="namedview1" + xml:space="preserve" + sodipodi:docname="icon.svg" + pagecolor="#505050" + bordercolor="#eeeeee" + borderopacity="1" + showguides="false" + inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"><defs + id="defs2"><linearGradient + id="linearGradient2" + inkscape:collect="always"><stop + style="stop-color:#205dcc;stop-opacity:1;" + offset="0" + id="stop2" /><stop + style="stop-color:#3235e3;stop-opacity:0.10470515;" + offset="1" + id="stop3" /></linearGradient><radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2" + id="radialGradient3" + cx="128" + cy="128" + fx="128" + fy="128" + r="97.5" + gradientUnits="userSpaceOnUse" /></defs><sodipodi:namedview + id="namedview2" + pagecolor="#505050" + bordercolor="#eeeeee" + borderopacity="1" + inkscape:showpageshadow="0" + inkscape:pageopacity="0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#505050" + inkscape:document-units="mm" + inkscape:zoom="1.0004558" + inkscape:cx="25.488383" + inkscape:cy="641.70752" + inkscape:window-width="3836" + inkscape:window-height="2121" + inkscape:window-x="1440" + inkscape:window-y="35" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" + inkscape:export-bgcolor="#00000000" /><g + inkscape:groupmode="layer" + id="layer1" + inkscape:label="Layer 1"><rect + style="opacity:0.9;fill:#2c2428;stroke:#000000;stroke-width:0;stroke-linecap:square;stroke-miterlimit:6;stroke-dasharray:none;stroke-opacity:0.8;fill-opacity:1" + id="rect2" + width="256" + height="255.99998" + x="0" + y="0" + inkscape:label="bg" /><circle + style="opacity:0.9;fill:url(#radialGradient3);fill-opacity:1;stroke:#000000;stroke-width:3;stroke-linecap:square;stroke-miterlimit:6;stroke-dasharray:none;stroke-opacity:0.8" + id="path2" + cx="128" + cy="128" + r="96" + inkscape:label="circle" /></g></svg> diff --git a/build.sh b/build.sh @@ -17,7 +17,8 @@ system_raylib=${USE_SYSTEM_RAYLIB:-$debug} case $(uname -s) in MINGW64*) output="Colour Picker" - ldflags="$ldflags -mwindows -lgdi32 -lwinmm" + windres assets/colourpicker.rc assets/colourpicker.rc.o + ldflags="assets/colourpicker.rc.o $ldflags -mwindows -lgdi32 -lwinmm" ;; esac diff --git a/main.c b/main.c @@ -161,12 +161,12 @@ main(i32 argc, char *argv[]) { Image icon; - RenderTexture icon_texture = LoadRenderTexture(48, 48); + RenderTexture icon_texture = LoadRenderTexture(128, 128); BeginDrawing(); BeginTextureMode(icon_texture); ClearBackground(ctx.bg); - DrawCircleGradient(24, 24, 16, colour_from_normalized(hsv_to_rgb(ctx.colour)), ctx.bg); - DrawRing((Vector2){24, 24}, 13, 16, 0, 360, 32, BLACK); + DrawCircleGradient(64, 64, 48, colour_from_normalized(hsv_to_rgb(ctx.colour)), ctx.bg); + DrawRing((Vector2){64, 64}, 45, 48, 0, 360, 128, SELECTOR_BORDER_COLOUR); EndTextureMode(); EndDrawing(); icon = LoadImageFromTexture(icon_texture.texture);