├── .clang-format ├── .editorconfig ├── .gitattibutes ├── .gitignore ├── .gitmodules ├── .travis.yml ├── .vscode ├── .gitignore ├── c_cpp_properties.json ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── CMakeLists.txt ├── COPYING.GPL ├── COPYING.GRX ├── COPYING.LGPL ├── COPYING.UNICODE ├── README.md ├── addons └── bmp │ ├── bmp.c │ ├── bmp.hlp │ ├── bmptest.c │ └── grxbmp.h ├── bindings └── vala │ └── grx-3.0.vapi ├── data └── unicode │ ├── Blocks.txt │ └── PropertyValueAliases.txt ├── doc ├── CMakeLists.txt ├── grx2 │ ├── README.md │ ├── changes.txt │ └── credits.doc ├── gtkdoc │ ├── CMakeLists.txt │ └── grx-docs.xml.in ├── man │ ├── CMakeLists.txt │ └── grx-calibrate-touch.rst ├── sphinx │ ├── .gitignore │ ├── api_docs.rst │ ├── conf.py │ ├── gjs_tutorial.rst │ ├── index.rst │ ├── make.bat │ ├── python_tutorial.rst │ └── vala_tutorial.rst ├── valadoc │ └── CMakeLists.txt └── yelp │ └── CMakeLists.txt ├── docker ├── armel.dockerfile ├── armhf.dockerfile └── setup.sh ├── example ├── CMakeLists.txt ├── javascript │ ├── CMakeLists.txt │ ├── boxes.js │ ├── circles.js │ ├── demo.js │ ├── ellipses.js │ ├── fonts.js │ ├── intl.js │ ├── life.js │ ├── lines.js │ └── pixels.js ├── python │ ├── .gitignore │ ├── CMakeLists.txt │ ├── boxes.py │ ├── circles.py │ ├── demo.py │ ├── ellipses.py │ ├── fonts.py │ ├── input.py │ ├── intl.py │ ├── life.py │ ├── lines.py │ ├── paint.py │ └── pixels.py └── vala │ ├── CMakeLists.txt │ ├── boxes.vala │ ├── circles.vala │ ├── demo.vala │ ├── ellipses.vala │ ├── life.vala │ ├── lines.vala │ └── pixels.vala ├── grx-3.0Config.cmake.in ├── include ├── grdriver.h ├── grx-3.0.h └── grx │ ├── application.h │ ├── color.h │ ├── common.h │ ├── context.h │ ├── device.h │ ├── device_manager.h │ ├── draw.h │ ├── draw_nc.h │ ├── error.h │ ├── events.h │ ├── extents.h │ ├── frame_mode.h │ ├── gformats.h │ ├── mode.h │ ├── mouse.h │ ├── pixmap.h │ ├── text.h │ ├── user.h │ ├── utils.h │ └── wideline.h ├── plugins ├── CMakeLists.txt └── video_driver │ ├── CMakeLists.txt │ ├── gtk3 │ ├── CMakeLists.txt │ ├── gtk3_device.c │ ├── gtk3_device.h │ ├── gtk3_device_manager.c │ ├── gtk3_device_manager.h │ └── vd_gtk3.c │ ├── linuxfb │ ├── CMakeLists.txt │ ├── libinput_device.c │ ├── libinput_device.h │ ├── libinput_device_manager.c │ ├── libinput_device_manager.h │ └── vd_lnxfb.c │ └── memory │ ├── CMakeLists.txt │ └── vd_mem.c ├── scripts ├── format.sh ├── keysyms_codegen.py ├── unicode_codegen.py └── update-doc.sh ├── setup.cmake ├── src ├── CMakeLists.txt ├── application │ └── application.c ├── draw │ ├── bitblt.c │ ├── bitblt1b.c │ ├── bitbltnc.c │ ├── box.c │ ├── boxnc.c │ ├── clearclp.c │ ├── clearctx.c │ ├── clearscr.c │ ├── drwinlne.c │ ├── fillbox.c │ ├── fillboxn.c │ ├── flodspil.c │ ├── frambox.c │ ├── framboxn.c │ ├── getscl.c │ ├── line.c │ ├── linenc.c │ ├── majorln1.c │ ├── majorln2.c │ ├── majorln3.c │ ├── majorln4.c │ ├── pixel.c │ ├── pixelc.c │ ├── plot.c │ ├── putscl.c │ └── roundbox.c ├── events │ └── events.c ├── fdrivers │ ├── dotab8.c │ ├── driver16.h │ ├── driver24.h │ ├── driver32.h │ ├── driver8.h │ ├── genblit.c │ ├── generic │ │ ├── bitblt.c │ │ ├── bitmap.c │ │ ├── block.c │ │ ├── getiscl.c │ │ ├── hline.c │ │ ├── line.c │ │ ├── pattern.c │ │ ├── putscl.c │ │ └── vline.c │ ├── gengiscl.c │ ├── genptscl.c │ ├── genstrch.c │ ├── pblitr2r.c │ ├── ram1.c │ ├── ram16.c │ ├── ram2.c │ ├── ram24.c │ ├── ram32h.c │ ├── ram32l.c │ ├── ram8.c │ ├── rblit_14.c │ └── rblit_14.h ├── fonts.conf ├── gformats │ ├── ctx2jpg.c │ ├── ctx2png.c │ ├── ctx2pnm.c │ ├── dummyjpg.c │ ├── dummypng.c │ ├── jpg2ctx.c │ ├── png2ctx.c │ └── pnm2ctx.c ├── grx.pc.in ├── image │ ├── ialloc.c │ ├── ifbox.c │ ├── ihline.c │ ├── iinverse.c │ ├── image.h │ ├── iplot.c │ └── istretch.c ├── include │ ├── access24.h │ ├── arith.h │ ├── clipping.h │ ├── colors.h │ ├── docolor.h │ ├── gcc │ │ ├── arith.h │ │ ├── asmsupp.h │ │ ├── highlow.h │ │ ├── memcopy.h │ │ ├── memfill.h │ │ └── mempeek.h │ ├── globals.h │ ├── grxdebug.h │ ├── highlow.h │ ├── libgrx.h │ ├── memcopy.h │ ├── memfill.h │ ├── mempeek.h │ ├── mouse.h │ ├── scanline_buf.h │ ├── shapes.h │ ├── usercord.h │ ├── usrscale.h │ └── util.h ├── input │ ├── device.c │ └── device_manager.c ├── marshal.list ├── mouse │ ├── bldcurs.c │ ├── drawcurs.c │ ├── input.h │ ├── mouinfo.c │ ├── mouinlne.c │ └── mscursor.c ├── pattern │ ├── fillpatt.c │ ├── makepat.c │ ├── patfbits.c │ ├── patfbox.c │ ├── patfcvxp.c │ ├── patfline.c │ ├── patfplot.c │ ├── patfpoly.c │ ├── patternf.c │ ├── pattfldf.c │ ├── pattline.c │ ├── pattpoly.c │ ├── pfcirc.c │ ├── pfcirca.c │ ├── pfelli.c │ ├── pfellia.c │ ├── ptcirc.c │ ├── ptcirca.c │ ├── ptelli.c │ └── ptellia.c ├── setup │ ├── clip.c │ ├── clrinfo.c │ ├── clrinlne.c │ ├── colorbw.c │ ├── colorega.c │ ├── colors.c │ ├── context.c │ ├── cxtinfo.c │ ├── cxtinlne.c │ ├── dpi.c │ ├── drvinfo.c │ ├── drvinlne.c │ ├── fframe.c │ ├── fgeom.c │ ├── modewalk.c │ ├── setdrvr.c │ ├── setmode.c │ └── viewport.c ├── shape │ ├── circle1.c │ ├── circle2.c │ ├── circle3.c │ ├── circle4.c │ ├── drawpoly.c │ ├── fillcir1.c │ ├── fillcir2.c │ ├── fillcnvx.c │ ├── fillell1.c │ ├── fillell2.c │ ├── fillpoly.c │ ├── flood.c │ ├── floodfil.c │ ├── genellip.c │ ├── genpoints.c │ ├── polyedge.h │ ├── polygon.c │ ├── polyline.c │ ├── scancnvx.c │ ├── scanellp.c │ ├── scanpoly.c │ └── solidfil.c ├── text │ ├── drawtext.c │ ├── dumpfont.c │ ├── error.c │ ├── loadfont.c │ ├── options.c │ ├── propwdt.c │ ├── text.h │ └── type.c ├── user │ ├── ubox.c │ ├── ucbox.c │ ├── uccirc.c │ ├── uccirca.c │ ├── ucelli.c │ ├── ucellia.c │ ├── ucirc.c │ ├── ucirca.c │ ├── ucircf.c │ ├── ucircfa.c │ ├── ucline.c │ ├── ucpolyg.c │ ├── ucpolyl.c │ ├── uelli.c │ ├── uellia.c │ ├── uellif.c │ ├── uellifa.c │ ├── ufcpolyg.c │ ├── ufillbox.c │ ├── uflood.c │ ├── ufpolyg.c │ ├── uframbox.c │ ├── ugetwin.c │ ├── uhline.c │ ├── uline.c │ ├── upbox.c │ ├── upcirc.c │ ├── upcirca.c │ ├── upelli.c │ ├── upellia.c │ ├── upfbox.c │ ├── upfcirc.c │ ├── upfcirca.c │ ├── upfcpoly.c │ ├── upfelli.c │ ├── upfellia.c │ ├── upfflood.c │ ├── upfline.c │ ├── upfplot.c │ ├── upfpolyg.c │ ├── upixel.c │ ├── upixelc.c │ ├── upline.c │ ├── uplot.c │ ├── upolygon.c │ ├── upolylin.c │ ├── uppolyg.c │ ├── uppolyl.c │ ├── usercord.c │ ├── usetwin.c │ ├── utextxy.c │ └── uvline.c ├── utilprog │ ├── bin2c.c │ ├── modetest.c │ └── vesainfo.c ├── utils │ ├── dbgprint.c │ ├── error.c │ ├── resize.c │ ├── scanline_buf.c │ └── shiftscl.c └── wideline │ ├── ccirc.c │ ├── ccirca.c │ ├── celli.c │ ├── cellia.c │ ├── custbox.c │ ├── custline.c │ ├── custplne.c │ ├── custpoly.c │ └── drwcpoly.c ├── test ├── CMakeLists.txt ├── arctest.c ├── arctest.dat ├── bb1test.c ├── blittest.c ├── circtest.c ├── cliptest.c ├── colorops.c ├── curstest.c ├── demogrx.c ├── drawing.h ├── fswwtest.c ├── gfaz.c ├── gfaz.h ├── imgtest.c ├── jpeg1.jpg ├── jpeg2.jpg ├── jpgtest.c ├── keys.c ├── life.c ├── linetest.c ├── loop.h ├── memtest.c ├── pcirctst.c ├── pngcompo.png ├── pngowl.png ├── pngred.png ├── pngtest.c ├── pnmtest.c ├── pnmtest.pbm ├── pnmtest.ppm ├── pnmtest2.ppm ├── polytest.c ├── polytest.dat ├── rand.h ├── rgbtest.c ├── sbctest.c ├── scroltst.c ├── speedtst.c ├── test.h ├── winclip.c └── wintest.c └── tools ├── CMakeLists.txt └── calibrate-touch.vala /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | 7 | [*.{py,js,c,h,md,txt}] 8 | indent_style = space 9 | indent_size = 4 10 | -------------------------------------------------------------------------------- /.gitattibutes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.jpg binary 4 | *.pbm binary 5 | *.png binary 6 | *.ppm binary 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | /aclocal.m4 4 | /autom4te.cache/ 5 | /build 6 | /build-* 7 | /config.* 8 | /configure 9 | /depcomp 10 | /install-sh 11 | /libtool 12 | /ltmain.sh 13 | /m4 14 | /missing 15 | /stamp-h? 16 | .deps/ 17 | .dirstamp 18 | .libs/ 19 | *.l[ao] 20 | *.o 21 | *.pc 22 | *.gir 23 | *.typelib 24 | Grx_3_0_gir 25 | *~ 26 | *.orig 27 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cmake"] 2 | path = cmake 3 | url = https://github.com/dlech/vala-cmake-modules 4 | [submodule "doc/sphinx/_html_extra"] 5 | path = doc/sphinx/_html_extra 6 | url = https://github.com/ev3dev/grx 7 | branch = html-extra 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: bash 2 | sudo: required 3 | dist: focal 4 | env: 5 | - OS=ubuntu ARCH=amd64 DIST=focal 6 | - OS=debian ARCH=amd64 DIST=bullseye 7 | - OS=debian ARCH=armhf DIST=bullseye QEMU=qemu-user-static 8 | - OS=debian ARCH=armel DIST=bullseye QEMU=qemu-user-static 9 | cache: 10 | directories: 11 | - "$HOME/cache" 12 | before_install: 13 | - sudo apt-add-repository --yes ppa:ev3dev/tools 14 | - sudo apt-get update 15 | - sudo apt-get install --yes debhelper pbuilder-ev3dev gobject-introspection clang-format $QEMU 16 | - if [ -n "$QEMU" ]; then 17 | wget https://github.com/multiarch/qemu-user-static/releases/download/v5.0.0-2/qemu-arm-static; 18 | chmod +x qemu-arm-static; 19 | sudo mv qemu-arm-static /usr/bin/; 20 | fi 21 | before_script: 22 | - pbuilder-ev3dev base 23 | - git checkout -B ev3dev-$DIST 24 | - curl -L https://github.com/ev3dev/grx/archive/ev3dev-$DIST.tar.gz | tar --strip-components=1 -xz grx-ev3dev-$DIST/debian 25 | script: 26 | - scripts/format.sh 27 | - pbuilder-ev3dev dev-build 28 | -------------------------------------------------------------------------------- /.vscode/.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp 6 | "ms-vscode.cpptools", 7 | "ms-python.python", 8 | "thiagoabreu.vala", 9 | "twxs.cmake", 10 | "xaver.clang-format" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[c]": { 3 | "editor.defaultFormatter": "xaver.clang-format", 4 | "editor.formatOnSave": true 5 | }, 6 | "files.associations": { 7 | "*.h": "c" 8 | }, 9 | "search.exclude": { 10 | "build": true, 11 | "doc/sphinx/_build": true, 12 | "doc/sphinx/_html_extra": true 13 | }, 14 | "editor.tabSize": 4, 15 | "editor.insertSpaces": true, 16 | "C_Cpp.intelliSenseEngine": "Default" 17 | } 18 | -------------------------------------------------------------------------------- /addons/bmp/bmptest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "bmp.c" 4 | 5 | int main(void) 6 | { 7 | GrBmpImage *bmp256, *bmp; 8 | GrxPixmap *p256, *p; 9 | GError error = NULL; 10 | if (!grx_set_mode( 11 | GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_COLOR, &error, 800, 600, 256)) { 12 | g_error("%s", error->message); 13 | } 14 | bmp256 = GrLoadBmpImage("mysha256.bmp"); 15 | bmp = GrLoadBmpImage("some1.bmp"); 16 | GrAllocBmpImageColors(bmp, NULL); 17 | GrAllocBmpImageColors(bmp256, NULL); 18 | p256 = GrConvertBmpImageToPattern(bmp256); 19 | p = GrConvertBmpImageToPattern(bmp); 20 | if (p) { 21 | grx_draw_pixmap(0, 0, p); 22 | getkey(); 23 | } 24 | if (p256) { 25 | grx_draw_pixmap(300, 300, p256); 26 | getkey(); 27 | } 28 | if (p) 29 | grx_pixmap_free(p); 30 | if (p256) 31 | grx_pixmap_free(p256); 32 | GrSaveBmpImage("save.bmp", NULL, 0, 0, 400, 400); 33 | GrUnloadBmpImage(bmp); 34 | GrUnloadBmpImage(bmp256); 35 | return 0; 36 | }; 37 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | if (GRX_ENABLE_DOC) 3 | 4 | add_custom_target (doc ALL) 5 | 6 | add_subdirectory (gtkdoc) 7 | add_subdirectory (man) 8 | add_subdirectory (valadoc) 9 | add_subdirectory (yelp) 10 | 11 | endif () -------------------------------------------------------------------------------- /doc/grx2/README.md: -------------------------------------------------------------------------------- 1 | This directory contains some historical files from GRX 2.x 2 | -------------------------------------------------------------------------------- /doc/grx2/changes.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/doc/grx2/changes.txt -------------------------------------------------------------------------------- /doc/gtkdoc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package (GtkDoc REQUIRED) 3 | 4 | file (GLOB internalHeaders 5 | ${CMAKE_SOURCE_DIR}/src/*/*.h 6 | ${CMAKE_SOURCE_DIR}/src/*/*/*.h 7 | ) 8 | 9 | configure_file (grx-docs.xml.in grx-docs.xml @ONLY) 10 | 11 | gtk_doc_add_module (grx 12 | XML 13 | ${CMAKE_CURRENT_BINARY_DIR}/grx-docs.xml 14 | SOURCE 15 | ${CMAKE_SOURCE_DIR}/src 16 | ${CMAKE_SOURCE_DIR}/include/grx 17 | ${CMAKE_BINARY_DIR}/src/include/grx 18 | SUFFIXES 19 | "h" 20 | "c" 21 | IGNOREHEADERS 22 | ${internalHeaders} 23 | IGNOREFILES 24 | ${internalHeaders} 25 | LIBRARIES 26 | ${SHARED_LIBRARY_TARGET} 27 | ) 28 | 29 | add_dependencies (doc doc-grx) 30 | 31 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/grx/html 32 | DESTINATION ${CMAKE_INSTALL_DOCDIR}) 33 | -------------------------------------------------------------------------------- /doc/man/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package (Pandoc REQUIRED) 3 | 4 | add_man_page (grx-calibrate-touch.1 5 | SECTION 1 6 | HEADER "User's Manual" 7 | FOOTER "${PROJECT_VERSION}" 8 | grx-calibrate-touch.rst 9 | ) 10 | list (APPEND MAN_PAGES ${CMAKE_CURRENT_BINARY_DIR}/grx-calibrate-touch.1) 11 | 12 | install (FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_DOCDIR}/man) 13 | 14 | add_custom_target (doc-man-pages DEPENDS ${MAN_PAGES}) 15 | add_dependencies (doc doc-man-pages) 16 | -------------------------------------------------------------------------------- /doc/man/grx-calibrate-touch.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | grx-calibrate-touch 3 | =================== 4 | 5 | :Author: David Lechner 6 | :Date: March 2017 7 | 8 | 9 | NAME 10 | ==== 11 | 12 | grx-calibrate-touch - Touch screen calibration tool for GRX graphics library 13 | 14 | 15 | SYNOPSIS 16 | ======== 17 | 18 | grx-calibrate-touch 19 | 20 | 21 | DESCRIPTION 22 | =========== 23 | 24 | This tool uses an interactive calibration procedure to generate a udev rule 25 | that contains calibration information for a touch screen input device. 26 | -------------------------------------------------------------------------------- /doc/sphinx/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | _extra/ 3 | -------------------------------------------------------------------------------- /doc/sphinx/api_docs.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | API Documentation 3 | ================= 4 | 5 | The following API docs are available: 6 | 7 | * `C API `_ 8 | * `JavaScript (Gjs) API `_ 9 | * `Python API `_ 10 | * `Vala API `_ 11 | 12 | .. note:: The C API docs are organized nicely and have additional notes, so even if you 13 | are using another programming language, you may find it useful to refer to the 14 | C API docs as well. 15 | -------------------------------------------------------------------------------- /doc/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to GRX3's documentation! 2 | ================================ 3 | 4 | GRX3 is a graphics and input library for (Linux) embedded systems with small 5 | screens. 6 | 7 | Features 8 | ======== 9 | 10 | * Can be used with many `programming languages`_ via `GObject Introspection`_. 11 | * Supported languages are Python, JavaScript (via `gjs`_ engine) and Vala. 12 | * Works with monochome screens. 13 | * Keyboard, mouse and touchscreen input. 14 | * Also runs in a windowed desktop environment (useful for faster development). 15 | * There is a (work-in-progress) widget toolkit for small screens. 16 | 17 | .. _`programming languages`: https://wiki.gnome.org/Projects/GObjectIntrospection/Users 18 | .. _`GObject Introspection`: https://wiki.gnome.org/Projects/GObjectIntrospection 19 | .. _`gjs`: https://wiki.gnome.org/Projects/Gjs 20 | 21 | 22 | Table of Contents 23 | ================= 24 | 25 | .. toctree:: 26 | :maxdepth: 1 27 | :caption: Installation 28 | 29 | linux_installation 30 | mac_installation 31 | rpi_installation 32 | 33 | .. toctree:: 34 | :maxdepth: 1 35 | :caption: Tutorials 36 | 37 | python_tutorial 38 | gjs_tutorial 39 | vala_tutorial 40 | 41 | .. toctree:: 42 | :maxdepth: 1 43 | :caption: Reference 44 | 45 | api_docs 46 | -------------------------------------------------------------------------------- /doc/sphinx/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | set SPHINXPROJ=GRX3 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /doc/valadoc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package (ValaDoc REQUIRED) 3 | 4 | add_valadoc (doc-vala 5 | PACKAGES 6 | glib-2.0 7 | gio-2.0 8 | PACKAGE_NAME 9 | ${PACKAGE_NAME} 10 | PACKAGE_VERSION 11 | ${PACKAGE_VERSION} 12 | SOURCE_FILES 13 | ${CMAKE_SOURCE_DIR}/bindings/vala/grx-3.0.vapi 14 | IMPORTS 15 | ${GIR_TARGET} 16 | ) 17 | add_dependencies (doc doc-vala) 18 | install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/valadoc DESTINATION ${CMAKE_INSTALL_DOCDIR}/vala) 19 | -------------------------------------------------------------------------------- /doc/yelp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package (GirDocTool REQUIRED) 3 | 4 | macro (add_yelp_doc LANGUAGE) 5 | add_gir_doc (doc-yelp-${LANGUAGE} ${LANGUAGE} 6 | GIR_TARGET ${GIR_TARGET} 7 | DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGE}) 8 | 9 | add_dependencies(doc doc-yelp-${LANGUAGE}) 10 | 11 | install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LANGUAGE} DESTINATION ${CMAKE_INSTALL_DOCDIR}/yelp) 12 | endmacro () 13 | 14 | add_yelp_doc (gjs) 15 | add_yelp_doc (python) 16 | -------------------------------------------------------------------------------- /docker/armel.dockerfile: -------------------------------------------------------------------------------- 1 | FROM ev3dev/debian-buster-armel-cross 2 | 3 | RUN sudo apt-get update && \ 4 | DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --no-install-recommends \ 5 | cmake \ 6 | gir1.2-glib-2.0 \ 7 | gobject-introspection \ 8 | libfontconfig1-dev \ 9 | libfreetype6-dev \ 10 | libgirepository1.0-dev \ 11 | libglib2.0-dev \ 12 | libgudev-1.0-dev \ 13 | libinput-dev \ 14 | libjpeg-dev \ 15 | libpng-dev \ 16 | libudev-dev \ 17 | libxkbcommon-dev \ 18 | pkg-config \ 19 | valac 20 | -------------------------------------------------------------------------------- /docker/armhf.dockerfile: -------------------------------------------------------------------------------- 1 | FROM ev3dev/debian-buster-armhf-cross 2 | 3 | RUN sudo apt-get update && \ 4 | DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes --no-install-recommends \ 5 | cmake \ 6 | gir1.2-glib-2.0 \ 7 | gobject-introspection \ 8 | libfontconfig1-dev \ 9 | libfreetype6-dev \ 10 | libgirepository1.0-dev \ 11 | libglib2.0-dev \ 12 | libgudev-1.0-dev \ 13 | libinput-dev \ 14 | libjpeg-dev \ 15 | libpng-dev \ 16 | libudev-dev \ 17 | libxkbcommon-dev \ 18 | pkg-config \ 19 | valac 20 | -------------------------------------------------------------------------------- /docker/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | project="grx" 6 | 7 | script_dir=$(dirname $(readlink -f "${0}")) 8 | 9 | case ${1} in 10 | armel|armhf) 11 | arch=${1} 12 | ;; 13 | *) 14 | echo "Error: Must specify 'armel' or 'armhf'" 15 | exit 1 16 | ;; 17 | esac 18 | 19 | if ! which docker >/dev/null; then 20 | echo "Error: Docker is not installed" 21 | exit 1 22 | fi 23 | 24 | build_dir=build-${arch} 25 | image_name="${project}-${arch}" 26 | container_name="${project}_${arch}" 27 | 28 | mkdir -p ${build_dir} 29 | 30 | docker build \ 31 | --tag ${image_name} \ 32 | --no-cache \ 33 | --file "${script_dir}/${arch}.dockerfile" \ 34 | "${script_dir}/" 35 | 36 | docker rm --force ${container_name} >/dev/null 2>&1 || true 37 | docker run \ 38 | --volume "$(readlink -f ${build_dir}):/build" \ 39 | --volume "$(pwd):/src" \ 40 | --workdir /build \ 41 | --name ${container_name} \ 42 | --env "TERM=${TERM}" \ 43 | --env "DESTDIR=/build/dist" \ 44 | --tty \ 45 | --detach \ 46 | ${image_name} tail 47 | 48 | docker exec --tty ${container_name} cmake /src \ 49 | -DCMAKE_BUILD_TYPE=Debug \ 50 | -DGRX_PLUGIN_GTK3=No \ 51 | -DGRX_ENABLE_DOC=No 52 | 53 | echo "Done. You can now compile by running 'docker exec --tty ${container_name} make'" 54 | -------------------------------------------------------------------------------- /example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory (javascript) 2 | add_subdirectory (python) 3 | add_subdirectory (vala) 4 | -------------------------------------------------------------------------------- /example/javascript/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set (PROGRAMS 3 | boxes.js 4 | circles.js 5 | ellipses.js 6 | fonts.js 7 | intl.js 8 | life.js 9 | lines.js 10 | pixels.js 11 | ) 12 | 13 | foreach (FILE_NAME ${PROGRAMS}) 14 | get_filename_component(TARGET_SUFFIX ${FILE_NAME} NAME_WE) 15 | add_custom_target (run-javascript-${TARGET_SUFFIX} 16 | ${CMAKE_COMMAND} -E env 17 | GRX_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins 18 | LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src 19 | GI_TYPELIB_PATH=${CMAKE_BINARY_DIR}/src 20 | FONTCONFIG_PATH=${CMAKE_SOURCE_DIR}/src 21 | GJS_PATH=${CMAKE_CURRENT_SOURCE_DIR} 22 | ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_NAME} 23 | DEPENDS 24 | ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_NAME} 25 | ${SHARED_LIBRARY_TARGET} 26 | ${TYPELIB_TARGET} 27 | plugins 28 | ) 29 | install (PROGRAMS ${FILE_NAME} DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}/examples/javascript) 30 | endforeach (FILE_NAME ${PROGRAMS}) 31 | 32 | set (MODULES 33 | demo.js 34 | ) 35 | 36 | install (FILES ${MODULES} DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}/examples/javascript) 37 | -------------------------------------------------------------------------------- /example/python/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .idea/ 3 | 4 | -------------------------------------------------------------------------------- /example/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set (PROGRAMS 3 | boxes.py 4 | circles.py 5 | ellipses.py 6 | fonts.py 7 | input.py 8 | intl.py 9 | life.py 10 | lines.py 11 | paint.py 12 | pixels.py 13 | ) 14 | 15 | foreach (FILE_NAME ${PROGRAMS}) 16 | get_filename_component(TARGET_SUFFIX ${FILE_NAME} NAME_WE) 17 | add_custom_target (run-python-${TARGET_SUFFIX} 18 | ${CMAKE_COMMAND} -E env 19 | GRX_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins 20 | LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src 21 | GI_TYPELIB_PATH=${CMAKE_BINARY_DIR}/src 22 | FONTCONFIG_PATH=${CMAKE_SOURCE_DIR}/src 23 | ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_NAME} 24 | DEPENDS 25 | ${CMAKE_CURRENT_SOURCE_DIR}/${FILE_NAME} 26 | ${SHARED_LIBRARY_TARGET} 27 | ${TYPELIB_TARGET} 28 | plugins 29 | ) 30 | install(PROGRAMS ${FILE_NAME} DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}/examples/python) 31 | endforeach (FILE_NAME ${PROGRAMS}) 32 | 33 | set (MODULES 34 | demo.py 35 | ) 36 | 37 | install (FILES ${MODULES} DESTINATION ${CMAKE_INSTALL_PKGLIBDIR}/examples/python) 38 | -------------------------------------------------------------------------------- /grx-3.0Config.cmake.in: -------------------------------------------------------------------------------- 1 | set(@PACKAGE_NAME@_INCLUDEDIR @CMAKE_CURRENT_SOURCE_DIR@/include;@CMAKE_CURRENT_BINARY_DIR@/src/include) 2 | set(@PACKAGE_NAME@_VAPIDIR @CMAKE_CURRENT_SOURCE_DIR@/bindings/vala) 3 | set(@PACKAGE_NAME@_GIRDIR @CMAKE_CURRENT_BINARY_DIR@/src) 4 | set(@PACKAGE_NAME@_PLUGINDIR @CMAKE_CURRENT_BINARY_DIR@/plugins) 5 | set(@PACKAGE_NAME@_FONTCONFIG_PATH @CMAKE_CURRENT_SOURCE_DIR@/src) 6 | -------------------------------------------------------------------------------- /include/grx-3.0.h: -------------------------------------------------------------------------------- 1 | /* 2 | * grx-3.0.h ---- GRX 3.x API functions and data structure declarations 3 | * 4 | * Copyright (c) 2015 David Lechner 5 | * 6 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 7 | * [e-mail: csaba@vuse.vanderbilt.edu] 8 | * 9 | * This file is part of the GRX graphics library. 10 | * 11 | * The GRX graphics library is free software; you can redistribute it 12 | * and/or modify it under some conditions; see the "copying.grx" file 13 | * for details. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | */ 19 | 20 | #ifndef __GRX_3_0_H_INCLUDED__ 21 | #define __GRX_3_0_H_INCLUDED__ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #endif /* __GRX_3_0_H_INCLUDED__ */ 45 | -------------------------------------------------------------------------------- /include/grx/common.h: -------------------------------------------------------------------------------- 1 | #ifndef __GRX_COMMON_H__ 2 | #define __GRX_COMMON_H__ 3 | 4 | /* context.h */ 5 | typedef struct _GrxFrame GrxFrame; 6 | typedef struct _GrxContext GrxContext; 7 | /* draw.h */ 8 | typedef struct _GrxFramedBoxColors GrxFramedBoxColors; 9 | typedef struct _GrxPoint GrxPoint; 10 | /* device_manager.h */ 11 | typedef struct _GrxDeviceManager GrxDeviceManager; 12 | /* events.h */ 13 | typedef union _GrxEvent GrxEvent; 14 | /* mode.h */ 15 | typedef struct _GrxFrameDriver GrxFrameDriver; 16 | typedef struct _GrxVideoDriver GrxVideoDriver; 17 | typedef struct _GrxVideoMode GrxVideoMode; 18 | typedef struct _GrxVideoModeExt GrxVideoModeExt; 19 | /* pixmap.h */ 20 | typedef struct _GrxPixmap GrxPixmap; 21 | /* wideline.h */ 22 | typedef struct _GrxLineOptions GrxLineOptions; 23 | 24 | #endif /* __GRX_COMMON_H__ */ 25 | -------------------------------------------------------------------------------- /include/grx/device_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * device_manager.h 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * This file is part of the GRX graphics library. 6 | * 7 | * The GRX graphics library is free software; you can redistribute it 8 | * and/or modify it under some conditions; see the "copying.grx" file 9 | * for details. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | #ifndef __GRX_DEVICE_MANAGER_H__ 17 | #define __GRX_DEVICE_MANAGER_H__ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | /** 27 | * SECTION:device_manager 28 | * @short_description: Device manager for input devices 29 | * @title: Input Device Manager 30 | * @section_id: device_manager 31 | * @include: grx-3.0.h 32 | * 33 | * TODO 34 | */ 35 | 36 | /** 37 | * GrxDeviceManager: 38 | * 39 | * Base class for device managers. 40 | */ 41 | #define GRX_TYPE_DEVICE_MANAGER grx_device_manager_get_type() 42 | G_DECLARE_DERIVABLE_TYPE( 43 | GrxDeviceManager, grx_device_manager, GRX, DEVICE_MANAGER, GObject) 44 | 45 | /** 46 | * GrxDeviceManagerClass: 47 | * @parent_class: the parent class struct 48 | * @reserved: for future use 49 | * 50 | * The class type struct for #GrxDeviceManager. 51 | */ 52 | struct _GrxDeviceManagerClass { 53 | GObjectClass parent_class; 54 | gpointer reserved[6]; 55 | }; 56 | 57 | #endif /* __GRX_DEVICE_MANAGER_H__ */ 58 | -------------------------------------------------------------------------------- /include/grx/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * utils.h 3 | * 4 | * Copyright (c) 2015 David Lechner 5 | * 6 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 7 | * [e-mail: csaba@vuse.vanderbilt.edu] 8 | * 9 | * This file is part of the GRX graphics library. 10 | * 11 | * The GRX graphics library is free software; you can redistribute it 12 | * and/or modify it under some conditions; see the "copying.grx" file 13 | * for details. 14 | * 15 | * This library is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | */ 19 | 20 | #ifndef __GRX_UTILS_H__ 21 | #define __GRX_UTILS_H__ 22 | 23 | /* ================================================================== */ 24 | /* MISCELLANEOUS UTILITIY FUNCTIONS */ 25 | /* ================================================================== */ 26 | 27 | void grx_resize_gray_map(unsigned char *map, int pitch, int ow, int oh, int nw, int nh); 28 | 29 | #endif /* __GRX_UTILS_H__ */ 30 | -------------------------------------------------------------------------------- /plugins/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target (plugins COMMENT "common target to build all enabled plugins") 2 | 3 | add_subdirectory (video_driver) 4 | -------------------------------------------------------------------------------- /plugins/video_driver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (GRX_PLUGIN_GTK3) 2 | add_subdirectory (gtk3) 3 | endif () 4 | 5 | if (GRX_PLUGIN_LINUXFB) 6 | add_subdirectory (linuxfb) 7 | endif () 8 | 9 | add_subdirectory (memory) 10 | -------------------------------------------------------------------------------- /plugins/video_driver/gtk3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set (GTK3_SOURCE_FILES 3 | gtk3_device.c 4 | gtk3_device_manager.c 5 | vd_gtk3.c 6 | ) 7 | 8 | set (GTK3_MODULES 9 | gmodule-export-2.0 10 | gtk+-3.0 11 | ) 12 | pkg_check_modules (GTK3_DEPS REQUIRED ${GTK3_MODULES}) 13 | 14 | string (REPLACE ";" " " link_flags "${GTK3_DEPS_LDFLAGS}") 15 | 16 | add_library (plugin-gtk3 MODULE ${GTK3_SOURCE_FILES}) 17 | target_compile_options (plugin-gtk3 PRIVATE "-Wall" "-Werror") 18 | target_compile_definitions (plugin-gtk3 PRIVATE 19 | "GRX_FONTCONFIG_PATH=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PKGDATADIR}/fonts\"") 20 | target_include_directories (plugin-gtk3 21 | PUBLIC 22 | ${CMAKE_SOURCE_DIR}/include 23 | ${CMAKE_BINARY_DIR}/src/include 24 | PRIVATE 25 | ${CMAKE_SOURCE_DIR}/src/include 26 | ${CMAKE_CURRENT_SOURCE_DIR} 27 | ${GTK3_DEPS_INCLUDE_DIRS} 28 | ) 29 | target_link_libraries (plugin-gtk3 ${GTK3_DEPS_LIBRARIES} ${SHARED_LIBRARY_TARGET}) 30 | set_target_properties (plugin-gtk3 PROPERTIES 31 | OUTPUT_NAME ${PACKAGE_NAME}-vdriver-gtk3 32 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins" 33 | LINK_FLAGS "${link_flags}" 34 | ) 35 | add_dependencies (plugins plugin-gtk3) 36 | install (TARGETS plugin-gtk3 LIBRARY DESTINATION ${CMAKE_INSTALL_PKGPLUGINDIR}) 37 | -------------------------------------------------------------------------------- /plugins/video_driver/gtk3/gtk3_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gtk3_device.h 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * This file is part of the GRX graphics library. 6 | * 7 | * The GRX graphics library is free software; you can redistribute it 8 | * and/or modify it under some conditions; see the "copying.grx" file 9 | * for details. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | #ifndef __GRX_GTK3_DEVICE_H__ 17 | #define __GRX_GTK3_DEVICE_H__ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #define GRX_TYPE_GTK3_DEVICE grx_gtk3_device_get_type() 27 | G_DECLARE_FINAL_TYPE(GrxGtk3Device, grx_gtk3_device, GRX, GTK3_DEVICE, GrxDevice) 28 | 29 | /* internal */ 30 | 31 | #include "gtk3_device_manager.h" 32 | 33 | GrxGtk3Device *grx_gtk3_device_new(GdkDevice *device); 34 | GrxGtk3Device *grx_gtk3_device_lookup(GrxGtk3DeviceManager *manager, GdkDevice *device); 35 | 36 | #endif /* __GRX_GTK3_DEVICE_H__ */ 37 | -------------------------------------------------------------------------------- /plugins/video_driver/gtk3/gtk3_device_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gtk3_device_manager.h 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * This file is part of the GRX graphics library. 6 | * 7 | * The GRX graphics library is free software; you can redistribute it 8 | * and/or modify it under some conditions; see the "copying.grx" file 9 | * for details. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | #ifndef __GRX_GTK3_DEVICE_MANAGER_H__ 17 | #define __GRX_GTK3_DEVICE_MANAGER_H__ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #define GRX_TYPE_GTK3_DEVICE_MANAGER grx_gtk3_device_manager_get_type() 27 | G_DECLARE_FINAL_TYPE(GrxGtk3DeviceManager, grx_gtk3_device_manager, GRX, 28 | GTK3_DEVICE_MANAGER, GrxDeviceManager) 29 | 30 | #endif /* __GRX_GTK3_DEVICE_MANAGER_H__ */ 31 | -------------------------------------------------------------------------------- /plugins/video_driver/linuxfb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set (LINUXFB_SOURCE_FILES 3 | libinput_device.c 4 | libinput_device_manager.c 5 | vd_lnxfb.c 6 | ) 7 | 8 | set (LINUXFB_MODULES 9 | gobject-2.0 10 | gmodule-export-2.0 11 | libudev 12 | libinput 13 | xkbcommon 14 | ) 15 | pkg_check_modules (LINUXFB_DEPS REQUIRED ${LINUXFB_MODULES}) 16 | 17 | string (REPLACE ";" " " link_flags "${LINUXFB_DEPS_LDFLAGS}") 18 | 19 | add_library (plugin-linuxfb MODULE ${LINUXFB_SOURCE_FILES}) 20 | target_compile_options (plugin-linuxfb PRIVATE "-Wall" "-Werror") 21 | target_include_directories (plugin-linuxfb 22 | PUBLIC 23 | ${CMAKE_SOURCE_DIR}/include 24 | ${CMAKE_BINARY_DIR}/src/include 25 | PRIVATE 26 | ${CMAKE_SOURCE_DIR}/src/include 27 | ${CMAKE_CURRENT_SOURCE_DIR} 28 | ${LINUXFB_DEPS_INCLUDE_DIRS} 29 | ) 30 | target_link_libraries (plugin-linuxfb ${LINUXFB_DEPS_LIBRARIES} ${SHARED_LIBRARY_TARGET}) 31 | set_target_properties (plugin-linuxfb PROPERTIES 32 | OUTPUT_NAME ${PACKAGE_NAME}-vdriver-linuxfb 33 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins" 34 | LINK_FLAGS "${link_flags}" 35 | ) 36 | add_dependencies (plugins plugin-linuxfb) 37 | install (TARGETS plugin-linuxfb LIBRARY DESTINATION ${CMAKE_INSTALL_PKGPLUGINDIR}) 38 | -------------------------------------------------------------------------------- /plugins/video_driver/linuxfb/libinput_device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libinput_device.h 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * This file is part of the GRX graphics library. 6 | * 7 | * The GRX graphics library is free software; you can redistribute it 8 | * and/or modify it under some conditions; see the "copying.grx" file 9 | * for details. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | #ifndef __GRX_LIBINPUT_DEVICE_H__ 17 | #define __GRX_LIBINPUT_DEVICE_H__ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #define GRX_TYPE_LIBINPUT_DEVICE grx_libinput_device_get_type() 24 | G_DECLARE_FINAL_TYPE( 25 | GrxLibinputDevice, grx_libinput_device, GRX, LIBINPUT_DEVICE, GrxDevice) 26 | 27 | /* internal */ 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | GrxLibinputDevice *grx_libinput_device_new( 35 | struct libinput_device *device, struct xkb_keymap *keymap); 36 | void grx_libinput_device_update_state(GrxLibinputDevice *device, xkb_keycode_t keycode, 37 | enum xkb_key_direction direction, xkb_keysym_t *keysym, gunichar *unichar); 38 | GrxModifierFlags grx_libinput_device_get_modifier_flags(GrxLibinputDevice *device); 39 | 40 | #endif /* __GRX_LIBINPUT_DEVICE_H__ */ 41 | -------------------------------------------------------------------------------- /plugins/video_driver/linuxfb/libinput_device_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libinput_device_manager.h 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * This file is part of the GRX graphics library. 6 | * 7 | * The GRX graphics library is free software; you can redistribute it 8 | * and/or modify it under some conditions; see the "copying.grx" file 9 | * for details. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | #ifndef __GRX_LIBINPUT_DEVICE_MANAGER_H__ 17 | #define __GRX_LIBINPUT_DEVICE_MANAGER_H__ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #define GRX_TYPE_LIBINPUT_DEVICE_MANAGER grx_libinput_device_manager_get_type() 27 | G_DECLARE_FINAL_TYPE(GrxLibinputDeviceManager, grx_libinput_device_manager, GRX, 28 | LIBINPUT_DEVICE_MANAGER, GrxDeviceManager) 29 | 30 | /** 31 | * GrxLibinputDeviceManagerSource: 32 | * 33 | * The #GrxLibinputDeviceManagerSource struct is an opaque data type representing a 34 | * #GrxLibinputDeviceManager event source. 35 | */ 36 | typedef struct { 37 | /**/ 38 | GSource source; 39 | GrxLibinputDeviceManager *instance; 40 | guint last_button; 41 | guint last_button_time; 42 | } GrxLibinputDeviceManagerSource; 43 | 44 | GSource *grx_libinput_device_manager_source_new(GrxLibinputDeviceManager *context); 45 | guint grx_libinput_device_manager_event_add(GrxLibinputDeviceManager *context); 46 | 47 | #endif /* __GRX_LIBINPUT_DEVICE_MANAGER_H__ */ 48 | -------------------------------------------------------------------------------- /plugins/video_driver/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set (MEMORY_SOURCE_FILES 3 | vd_mem.c 4 | ) 5 | 6 | set (MEMORY_MODULES 7 | gmodule-export-2.0 8 | ) 9 | pkg_check_modules (MEMORY_DEPS REQUIRED ${MEMORY_MODULES}) 10 | 11 | string (REPLACE ";" " " link_flags "${MEMORY_DEPS_LDFLAGS}") 12 | 13 | add_library (grx_memory MODULE ${MEMORY_SOURCE_FILES}) 14 | target_compile_options (grx_memory PRIVATE "-Wall" "-Werror") 15 | target_include_directories (grx_memory 16 | PUBLIC 17 | ${CMAKE_SOURCE_DIR}/include 18 | ${CMAKE_BINARY_DIR}/src/include 19 | PRIVATE 20 | ${CMAKE_SOURCE_DIR}/src/include 21 | ${CMAKE_CURRENT_SOURCE_DIR} 22 | ${MEMORY_DEPS_INCLUDE_DIRS} 23 | ) 24 | target_link_libraries (grx_memory ${MEMORY_DEPS_LIBRARIES} ${SHARED_LIBRARY_TARGET}) 25 | set_target_properties (grx_memory PROPERTIES 26 | OUTPUT_NAME ${PACKAGE_NAME}-vdriver-memory 27 | LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins" 28 | LINK_FLAGS "${link_flags}" 29 | ) 30 | add_dependencies (plugins grx_memory) 31 | install (TARGETS grx_memory LIBRARY DESTINATION ${CMAKE_INSTALL_PKGPLUGINDIR}) 32 | -------------------------------------------------------------------------------- /scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | shopt -s globstar 4 | 5 | if [ "$CI" == "true" ]; then 6 | export PATH=/usr/bin:$PATH 7 | clang-format --version 8 | OPTIONS="--dry-run --Werror --verbose" 9 | else 10 | OPTIONS="-i" 11 | fi 12 | 13 | GLOBIGNORE="./build/**" 14 | exec clang-format ./**/*.{c,h} $OPTIONS 15 | -------------------------------------------------------------------------------- /scripts/update-doc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Maintainer script to build and push documentation 4 | 5 | set -e 6 | 7 | base_dir=$(dirname $(readlink -f $0)) 8 | build_dir=${base_dir}/doc-build 9 | html_extra_dir=${base_dir}/doc/sphinx/_html_extra 10 | 11 | rm -rf ${html_extra_dir}/c-api 12 | rm -rf ${html_extra_dir}/gjs-api 13 | rm -rf ${html_extra_dir}/python-api 14 | rm -rf ${html_extra_dir}/vala-api 15 | 16 | mkdir -p ${html_extra_dir}/c-api 17 | mkdir -p ${html_extra_dir}/gjs-api 18 | mkdir -p ${html_extra_dir}/python-api 19 | mkdir -p ${html_extra_dir}/vala-api 20 | 21 | rm -rf ${build_dir} 22 | cmake -D CMAKE_BUILD_TYPE=Release -D GTKDOC_REBASE_ONLINE=Yes -B${build_dir} -H${base_dir} 23 | make -s -C ${build_dir} doc 24 | 25 | cp -R ${build_dir}/doc/gtkdoc/grx/html/* ${html_extra_dir}/c-api 26 | yelp-build html -o ${html_extra_dir}/gjs-api ${build_dir}/doc/yelp/gjs 27 | yelp-build html -o ${html_extra_dir}/python-api ${build_dir}/doc/yelp/python 28 | cp -R ${build_dir}/doc/valadoc/valadoc/* ${html_extra_dir}/vala-api 29 | 30 | rm -rf ${build_dir} 31 | -------------------------------------------------------------------------------- /setup.cmake: -------------------------------------------------------------------------------- 1 | # Create the build directory and initalize it 2 | 3 | execute_process ( 4 | COMMAND ${CMAKE_COMMAND} -E make_directory build 5 | ) 6 | 7 | if (APPLE) 8 | set(appleOptions "-DGRX_ENABLE_DOC=No") 9 | endif () 10 | 11 | execute_process ( 12 | COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${appleOptions} .. 13 | WORKING_DIRECTORY build 14 | ) 15 | -------------------------------------------------------------------------------- /src/draw/clearclp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * clearclp.c ---- clear clipbox 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | 23 | /** 24 | * grx_clear_clip_box: 25 | * @bg: the background color 26 | * 27 | * Clears the current clip box using the specified background color. 28 | * 29 | * Thanks to the special #GrxColor definition, you can do more than simple clear 30 | * with this functions, by example with: 31 | * |[ 32 | * grx_clear_clip_box (grx_color_to_xor_mode (grx_color_get_white ())); 33 | * ]| 34 | * the clip box is negativized, do it again and the clip box is restored. 35 | */ 36 | void grx_clear_clip_box(GrxColor bg) 37 | { 38 | grx_draw_filled_box(0, 0, CURC->x_max, CURC->y_max, bg); 39 | } 40 | -------------------------------------------------------------------------------- /src/draw/clearscr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * clearscr.c ---- clear screen 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | 23 | /** 24 | * grx_clear_screen: 25 | * @bg: the background color 26 | * 27 | * Clears the screen using the specified background color. 28 | * 29 | * Thanks to the special #GrxColor definition, you can do more than simple clear 30 | * with this functions, by example with: 31 | * |[ 32 | * grx_clear_screen (grx_color_to_xor_mode (grx_color_get_white ())); 33 | * ]| 34 | * the screen is negativized, do it again and the screen is restored. 35 | */ 36 | void grx_clear_screen(GrxColor bg) 37 | { 38 | GrxContext save; 39 | grx_save_current_context(&save); 40 | grx_set_current_context(SCRN); 41 | grx_clear_context(bg); 42 | grx_set_current_context(&save); 43 | } 44 | -------------------------------------------------------------------------------- /src/draw/fillbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillbox.c ---- draw a filled rectangle 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "mouse.h" 22 | 23 | /** 24 | * grx_draw_filled_box: 25 | * @x1: the left X coordinate 26 | * @y1: the top Y coordinate 27 | * @x2: the right X coordinate 28 | * @y2: the bottom Y coordinate 29 | * @c: the color 30 | * 31 | * Draws a filled rectangle on the current context using the specified 32 | * coordinates and color. 33 | */ 34 | void grx_draw_filled_box(int x1, int y1, int x2, int y2, GrxColor c) 35 | { 36 | clip_box(CURC, x1, y1, x2, y2); 37 | mouse_block(CURC, x1, y1, x2, y2); 38 | (*FDRV->drawblock)( 39 | x1 + CURC->x_offset, y1 + CURC->y_offset, x2 - x1 + 1, y2 - y1 + 1, c); 40 | mouse_unblock(); 41 | } 42 | -------------------------------------------------------------------------------- /src/draw/fillboxn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillboxn.c ---- draw a filled rectangle (no clip) 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_fast_draw_filled_box: 24 | * @x1: the left X coordinate 25 | * @y1: the top Y coordinate 26 | * @x2: the right X coordinate 27 | * @y2: the bottom Y coordinate 28 | * @c: the color 29 | * 30 | * Draws a filled rectangle on the current context using the specified 31 | * coordinates and color. 32 | * 33 | * This function does not perform clipping. If you cannot ensure that the 34 | * box is within the bounds of the current context, then use 35 | * grx_draw_filled_box() instead. 36 | */ 37 | void grx_fast_draw_filled_box(int x1, int y1, int x2, int y2, GrxColor c) 38 | { 39 | (*FDRV->drawblock)( 40 | x1 + CURC->x_offset, y1 + CURC->y_offset, x2 - x1 + 1, y2 - y1 + 1, c); 41 | } 42 | -------------------------------------------------------------------------------- /src/draw/line.c: -------------------------------------------------------------------------------- 1 | /* 2 | * LINE.C ---- line drawing 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "mouse.h" 22 | 23 | /** 24 | * grx_draw_line: 25 | * @x1: starting X coordinate 26 | * @y1: starting Y coordinate 27 | * @x2: ending X coordinate 28 | * @y2: ending Y coordinate 29 | * @c: the color 30 | * 31 | * Draws a line on the current context from the starting coordinates to the 32 | * ending coordinates using the specified color. 33 | * 34 | * For horizontal and vertical lines, see grx_draw_hline() and grx_draw_vline(). 35 | */ 36 | void grx_draw_line(int x1, int y1, int x2, int y2, GrxColor c) 37 | { 38 | clip_line(CURC, x1, y1, x2, y2); 39 | mouse_block(CURC, x1, y1, x2, y2); 40 | (*FDRV->drawline)(x1 + CURC->x_offset, y1 + CURC->y_offset, x2 - x1, y2 - y1, c); 41 | mouse_unblock(); 42 | } 43 | -------------------------------------------------------------------------------- /src/draw/linenc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * linenc.c ---- line drawing (no clip) 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_fast_draw_line: 24 | * @x1: starting X coordinate 25 | * @y1: starting Y coordinate 26 | * @x2: ending X coordinate 27 | * @y2: ending Y coordinate 28 | * @c: the color 29 | * 30 | * Draws a line on the current context from the starting coordinates to the 31 | * ending coordinates using the specified color. 32 | * 33 | * For horizontal and vertical lines, see grx_fast_draw_hline() and 34 | * grx_fast_draw_vline(). 35 | * 36 | * This function does not perform clipping. If you cannot ensure that the 37 | * endpoints are within the bounds of the current context, then use 38 | * grx_draw_line() instead. 39 | */ 40 | void grx_fast_draw_line(int x1, int y1, int x2, int y2, GrxColor c) 41 | { 42 | (*FDRV->drawline)(x1 + CURC->x_offset, y1 + CURC->y_offset, x2 - x1, y2 - y1, c); 43 | } 44 | -------------------------------------------------------------------------------- /src/draw/majorln1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * majorln1.c ---- lines parallel with the X axis 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "mouse.h" 22 | 23 | /** 24 | * grx_draw_hline: 25 | * @x1: starting X coordinate 26 | * @x2: ending X coordinate 27 | * @y: Y coordinate 28 | * @c: the color 29 | * 30 | * Draws a horizontal line on the current context from the starting coordinates 31 | * to the ending coordinates using the specified color. 32 | * 33 | * This is more efficient that using grx_draw_line(). 34 | */ 35 | void grx_draw_hline(int x1, int x2, int yy, GrxColor c) 36 | { 37 | clip_hline(CURC, x1, x2, yy); 38 | mouse_block(CURC, x1, yy, x2, yy); 39 | (*FDRV->drawhline)(x1 + CURC->x_offset, yy + CURC->y_offset, x2 - x1 + 1, c); 40 | mouse_unblock(); 41 | } 42 | -------------------------------------------------------------------------------- /src/draw/majorln2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * majorln2.c ---- lines parallel with the Y axis 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "mouse.h" 22 | 23 | /** 24 | * grx_draw_vline: 25 | * @x: X coordinate 26 | * @y1: starting Y coordinate 27 | * @y2: ending Y coordinate 28 | * @c: the color 29 | * 30 | * Draws a vertical line on the current context from the starting coordinates 31 | * to the ending coordinates using the specified color. 32 | * 33 | * This is more efficient that using grx_draw_line(). 34 | */ 35 | void grx_draw_vline(int xx, int y1, int y2, GrxColor c) 36 | { 37 | clip_vline(CURC, xx, y1, y2); 38 | mouse_block(CURC, xx, y1, xx, y2); 39 | (*FDRV->drawvline)(xx + CURC->x_offset, y1 + CURC->y_offset, y2 - y1 + 1, c); 40 | mouse_unblock(); 41 | } 42 | -------------------------------------------------------------------------------- /src/draw/majorln3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * majorln3.c---- lines parallel with the X axis (no clip) 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_fast_draw_hline: 24 | * @x1: starting X coordinate 25 | * @x2: ending X coordinate 26 | * @y: Y coordinate 27 | * @c: the color 28 | * 29 | * Draws a horizontal line on the current context from the starting coordinates 30 | * to the ending coordinates using the specified color. 31 | * 32 | * This is more efficient that using grx_fast_draw_line(). 33 | * 34 | * This function does not perform clipping. If you cannot ensure that the 35 | * endpoints are within the bounds of the current context, then use 36 | * grx_draw_hline() instead. 37 | */ 38 | void grx_fast_draw_hline(int x1, int x2, int yy, GrxColor c) 39 | { 40 | isort(x1, x2); 41 | (*FDRV->drawhline)(x1 + CURC->x_offset, yy + CURC->y_offset, x2 - x1 + 1, c); 42 | } 43 | -------------------------------------------------------------------------------- /src/draw/majorln4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * majorln4.c ---- lines parallel with the Y axis (no clip) 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_fast_draw_vline: 24 | * @x: X coordinate 25 | * @y1: starting Y coordinate 26 | * @y2: ending Y coordinate 27 | * @c: the color 28 | * 29 | * Draws a vertical line on the current context from the starting coordinates 30 | * to the ending coordinates using the specified color. 31 | * 32 | * This is more efficient that using grx_fast_draw_line(). 33 | * 34 | * This function does not perform clipping. If you cannot ensure that the 35 | * endpoints are within the bounds of the current context, then use 36 | * grx_draw_hline() instead. 37 | */ 38 | void grx_fast_draw_vline(int xx, int y1, int y2, GrxColor c) 39 | { 40 | isort(y1, y2); 41 | (*FDRV->drawvline)(xx + CURC->x_offset, y1 + CURC->y_offset, y2 - y1 + 1, c); 42 | } 43 | -------------------------------------------------------------------------------- /src/draw/pixel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * PIXEL.C ---- pixel read routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "mouse.h" 22 | 23 | /** 24 | * grx_get_pixel_at: 25 | * @x: the X coordinate 26 | * @y: the Y coordinate 27 | * 28 | * Gets the color value of the pixel in the current context at the specified 29 | * coordinates. 30 | */ 31 | GrxColor grx_get_pixel_at(int x, int y) 32 | { 33 | GrxColor retval; 34 | cxclip_dot_(CURC, x, y, return GRX_COLOR_NONE); 35 | mouse_block(CURC, x, y, x, y); 36 | retval = (*FDRV->readpixel)(&CURC->frame, x + CURC->x_offset, y + CURC->y_offset); 37 | mouse_unblock(); 38 | return retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/draw/pixelc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pixelc.c ---- pixel read from context 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "libgrx.h" 20 | #include "mouse.h" 21 | 22 | /** 23 | * grx_context_get_pixel_at: 24 | * @context: the context 25 | * @x: the X coordinate 26 | * @y: the Y coordinate 27 | * 28 | * Gets the color value of the pixel in the context at the specified 29 | * coordinates. 30 | * 31 | * Also see grx_get_pixel_at() for operating on the current context. 32 | */ 33 | GrxColor grx_context_get_pixel_at(GrxContext *c, int x, int y) 34 | { 35 | GrxColor retval; 36 | cxclip_dot_(c, x, y, return GRX_COLOR_NONE); 37 | mouse_block(c, x, y, x, y); 38 | retval = (*c->gc_driver->readpixel)(&c->frame, x + c->x_offset, y + c->y_offset); 39 | mouse_unblock(); 40 | return retval; 41 | } 42 | -------------------------------------------------------------------------------- /src/draw/plot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * plot.c ---- pixel draw routines 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "arith.h" 19 | #include "clipping.h" 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "mouse.h" 23 | 24 | /** 25 | * grx_draw_pixel: 26 | * @x: the X coordinate 27 | * @y: the Y coordinate 28 | * @c: the color (can include #GrxColorMode) 29 | * 30 | * Draw a single pixel on the current context at the specified coordinates. 31 | */ 32 | void grx_draw_pixel(int x, int y, GrxColor c) 33 | { 34 | clip_dot(CURC, x, y); 35 | mouse_block(CURC, x, y, x, y); 36 | (*FDRV->drawpixel)(x + CURC->x_offset, y + CURC->y_offset, c); 37 | mouse_unblock(); 38 | } 39 | -------------------------------------------------------------------------------- /src/draw/putscl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * putscl.c ---- put scanline pixels 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include "clipping.h" 18 | #include "globals.h" 19 | #include "libgrx.h" 20 | #include "mouse.h" 21 | 22 | /** 23 | * grx_put_scanline: 24 | * @x1: the starting X coordinate 25 | * @x2: the ending X coordinate 26 | * @y: the Y coordinate 27 | * @scanline: (array): the data to write 28 | * @op: the color operation 29 | * 30 | * Writes @scanline to the current context using the @op operation. 31 | * 32 | * Data values in @scanline must fit #GRX_COLOR_VALUE_MASK otherwise the 33 | * results are implementation dependent. So you can't supply operation code 34 | * with the pixel data! 35 | */ 36 | void grx_put_scanline(int x1, int x2, int yy, const GrxColor *c, GrxColor op) 37 | { 38 | int xs; 39 | isort(x1, x2); 40 | xs = x1; 41 | clip_hline(CURC, x1, x2, yy); 42 | mouse_block(CURC, x1, yy, x2, yy); 43 | (*FDRV->putscanline)(x1 + CURC->x_offset, yy + CURC->y_offset, x2 - x1 + 1, 44 | &c[x1 - xs], /* adjust pixel pointer when clipped */ 45 | op); 46 | mouse_unblock(); 47 | } 48 | -------------------------------------------------------------------------------- /src/fdrivers/dotab8.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dotab8.c ---- 256 color mode operation check table 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Contributions by: (See "doc/credits.doc" for details) 18 | * Hartmut Schirmer (hsc@techfak.uni-kiel.de) 19 | */ 20 | 21 | #include "docolor.h" 22 | #include "libgrx.h" 23 | 24 | unsigned int _GrFDdotable8[] = { 0xffffU, 0, 0, 0xffU }; 25 | -------------------------------------------------------------------------------- /src/fdrivers/generic/bitmap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/bitmap.c ---- generic (=slow) font or bitmap draw routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawbitmap(int x, int y, int w, int h, unsigned char *bmp, int pitch, 23 | int start, GrxColor fg, GrxColor bg) 24 | { 25 | GRX_ENTER(); 26 | w += x; 27 | h += y; 28 | bmp += (unsigned int)start >> 3; 29 | start &= 7; 30 | do { 31 | unsigned char *bitp = bmp; 32 | unsigned char bits = *bitp; 33 | unsigned char mask = 0x80 >> start; 34 | int xx = x; 35 | do { 36 | drawpixel(xx, y, (bits & mask) ? fg : bg); 37 | if ((mask >>= 1) == 0) 38 | bits = *++bitp, mask = 0x80; 39 | } while (++xx != w); 40 | bmp += pitch; 41 | } while (++y != h); 42 | GRX_LEAVE(); 43 | } 44 | -------------------------------------------------------------------------------- /src/fdrivers/generic/block.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/block.c ---- generic (=slow) rectangle fill routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawblock(int x, int y, int w, int h, GrxColor c) 23 | { 24 | GRX_ENTER(); 25 | h += y; 26 | do { 27 | drawhline(x, y, w, c); 28 | } while (++y != h); 29 | GRX_LEAVE(); 30 | } 31 | -------------------------------------------------------------------------------- /src/fdrivers/generic/getiscl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/getiscl.c ---- generic getindexscanline routine 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "scanline_buf.h" 22 | 23 | static GrxColor *getindexedscanline(const GrxFrame *c, int x, int y, int w, int *indx) 24 | { 25 | GrxColor *pixels; 26 | GrxColor *p; 27 | GRX_ENTER(); 28 | 29 | p = pixels = _grx_get_scanline_buf(w); 30 | 31 | if (indx) { 32 | int i, oldx = -1; 33 | GrxColor col = 0; 34 | 35 | for (i = 0; i < w; ++i) { 36 | int xx = x + indx[i]; 37 | 38 | if (oldx != xx) { 39 | oldx = xx; 40 | col = readpixel(c, xx, y); 41 | } 42 | 43 | *(p++) = col; 44 | } 45 | } 46 | else { 47 | for (; w > 0; --w) { 48 | *(p++) = readpixel(c, x++, y); 49 | } 50 | } 51 | 52 | GRX_RETURN(pixels); 53 | } 54 | /* will return an array of pixel values pv[] read from frame */ 55 | /* if indx == NULL: pv[i=0..w-1] = readpixel(x+i,y) */ 56 | /* else pv[i=0..w-1] = readpixel(x+indx[i],y) */ 57 | -------------------------------------------------------------------------------- /src/fdrivers/generic/hline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/hline.c ---- generic (=slow) scan line fill routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawhline(int x, int y, int w, GrxColor c) 23 | { 24 | GRX_ENTER(); 25 | w += x; 26 | do { 27 | drawpixel(x, y, c); 28 | } while (++x != w); 29 | GRX_LEAVE(); 30 | } 31 | -------------------------------------------------------------------------------- /src/fdrivers/generic/line.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/line.c ---- generic (=slow) line draw routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawline(int x, int y, int dx, int dy, GrxColor c) 23 | { 24 | int cnt, err, yoff; 25 | GRX_ENTER(); 26 | yoff = 1; 27 | if (dx < 0) { 28 | x += dx; 29 | dx = (-dx); 30 | y += dy; 31 | dy = (-dy); 32 | } 33 | if (dy < 0) { 34 | yoff = (-1); 35 | dy = (-dy); 36 | } 37 | if (dx > dy) { 38 | err = (cnt = dx) >> 1; 39 | do { 40 | drawpixel(x, y, c); 41 | if ((err -= dy) < 0) 42 | err += dx, y += yoff; 43 | x++; 44 | } while (--cnt >= 0); 45 | } 46 | else { 47 | err = (cnt = dy) >> 1; 48 | do { 49 | drawpixel(x, y, c); 50 | if ((err -= dx) < 0) 51 | err += dy, x++; 52 | y += yoff; 53 | } while (--cnt >= 0); 54 | } 55 | GRX_LEAVE(); 56 | } 57 | -------------------------------------------------------------------------------- /src/fdrivers/generic/pattern.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/pattern.c ---- generic (=slow) patterned scan line fill routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawpattern( 23 | int x, int y, int w, unsigned char patt, GrxColor fg, GrxColor bg) 24 | { 25 | GR_int8u mask; 26 | GRX_ENTER(); 27 | mask = 0x80; 28 | w += x; 29 | do { 30 | drawpixel(x, y, (patt & mask) ? fg : bg); 31 | if ((mask >>= 1) == 0) 32 | mask = 0x80; 33 | } while (++x != w); 34 | GRX_LEAVE(); 35 | } 36 | -------------------------------------------------------------------------------- /src/fdrivers/generic/putscl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/putscl.c ---- generic putscanline routine 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include "libgrx.h" 20 | 21 | static void putscanline(int x, int y, int w, const GrxColor *scl, GrxColor op) 22 | { 23 | GrxColor skipc; 24 | GRX_ENTER(); 25 | skipc = op ^ GRX_COLOR_MODE_IMAGE; 26 | op &= GRX_COLOR_MODE_MASK; 27 | for (w += x; x < w; ++x) { 28 | GrxColor c = *(scl++); 29 | if (c != skipc) 30 | drawpixel(x, y, (c | op)); 31 | } 32 | GRX_LEAVE(); 33 | } 34 | -------------------------------------------------------------------------------- /src/fdrivers/generic/vline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * generic/bitblt.c ---- generic (=slow) vertical line draw routine 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu]. 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | 22 | static void drawvline(int x, int y, int h, GrxColor c) 23 | { 24 | GRX_ENTER(); 25 | h += y; 26 | do { 27 | drawpixel(x, y, c); 28 | } while (++y != h); 29 | GRX_LEAVE(); 30 | } 31 | -------------------------------------------------------------------------------- /src/fdrivers/genptscl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * genptscl.c ---- generic, VERY SLOW putscanline routine 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include "globals.h" 18 | #include "grdriver.h" 19 | #include "libgrx.h" 20 | 21 | /* will draw array of pixel values to current context */ 22 | 23 | void _GrFrDrvGenericPutScanline(int x, int y, int w, const GrxColor *scl, GrxColor op) 24 | { 25 | GrxColor skipc; 26 | _GR_drawPix drawpixel; 27 | GRX_ENTER(); 28 | drawpixel = CURC->gc_driver->drawpixel; 29 | DBGPRINTF(DBG_DRIVER, ("x=%d, y=%d, w=%d, op=%lx\n", x, y, w, op)); 30 | skipc = op ^ GRX_COLOR_MODE_IMAGE; 31 | op &= GRX_COLOR_MODE_MASK; 32 | for (w += x; x < w; ++x) { 33 | GrxColor c = *(scl++); 34 | if (c != skipc) 35 | (*drawpixel)(x, y, (c | op)); 36 | } 37 | GRX_LEAVE(); 38 | } 39 | -------------------------------------------------------------------------------- /src/fdrivers/rblit_14.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rblit_14.h ---- ram to ram blit support functions for 1bpp and 3 | * 4x1bpp RAM frame drivers 4 | * 5 | * Copyright (c) 1998 Hartmut Schirmer 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | G_GNUC_INTERNAL void _GR_rblit_14(const GrxFrame *dst, gint dx, gint dy, 26 | const GrxFrame *src, gint x, gint y, gint w, gint h, GrxColor op, 27 | _GR_blitFunc bitblt, gboolean invert); 28 | -------------------------------------------------------------------------------- /src/fonts.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /usr/share/fonts 7 | /usr/local/share/fonts 8 | fonts 9 | 10 | /var/cache/grx/fontconfig 11 | grx/fontconfig 12 | 13 | 14 | 15 | 16 | 17 | false 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/gformats/dummyjpg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dummyjpg.c ---- dummy jpeg funtions if not JPEG support in the library 3 | * 4 | * Copyright (C) 2001 Mariano Alvarez Fernandez 5 | * [e-mail: malfer@teleline.es] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | /* 24 | ** grx_context_save_to_jpeg - Returns error 25 | */ 26 | 27 | int grx_context_save_to_jpeg(GrxContext *grc, char *jpegfn, int quality) 28 | { 29 | return -1; 30 | } 31 | 32 | /* 33 | ** grx_context_save_to_jpeg_grayscale - Returns error 34 | */ 35 | 36 | int grx_context_save_to_jpeg_grayscale(GrxContext *grc, char *jpegfn, int quality) 37 | { 38 | return -1; 39 | } 40 | 41 | /* 42 | ** grx_context_load_from_jpeg - Returns error 43 | */ 44 | 45 | int grx_context_load_from_jpeg(GrxContext *grc, char *jpegfn, int scale) 46 | { 47 | return -1; 48 | } 49 | 50 | /* 51 | ** grx_query_jpeg_file - Returns error 52 | */ 53 | 54 | int grx_query_jpeg_file(char *jpegfn, int *width, int *height) 55 | { 56 | return -1; 57 | } 58 | -------------------------------------------------------------------------------- /src/gformats/dummypng.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dummypng.c ---- dummy png funtions if not PNG support in the library 3 | * 4 | * Copyright (C) 2001 Mariano Alvarez Fernandez 5 | * [e-mail: malfer@teleline.es] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | /* 24 | ** grx_context_save_to_png - Returns error 25 | */ 26 | 27 | int grx_context_save_to_png(GrxContext *grc, char *pngfn) 28 | { 29 | return -1; 30 | } 31 | 32 | /* 33 | ** grx_context_load_from_png - Returns error 34 | */ 35 | 36 | int grx_context_load_from_png(GrxContext *grc, char *pngfn, int use_alpha) 37 | { 38 | return -1; 39 | } 40 | 41 | /* 42 | ** grx_query_pnm_file - Returns error 43 | */ 44 | 45 | int grx_query_png_file(char *pngfn, int *width, int *height) 46 | { 47 | return -1; 48 | } 49 | -------------------------------------------------------------------------------- /src/grx.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | datarootdir=${prefix}/@CMAKE_INSTALL_DATAROOTDIR@ 6 | datadir=${datarootdir} 7 | pkgdatadir=${prefix}/@CMAKE_INSTALL_PKGDATADIR@ 8 | 9 | Name: GRX 10 | Description: 2D graphics library 11 | Version: @PROJECT_VERSION@ 12 | Requires: @PKGCONFIG_PUBLIC_DEPS@ 13 | Requires.private: @PKGCONFIG_PUBLIC_DEPS@, @PKGCONFIG_PRIVATE_DEPS@ 14 | Cflags: -I${includedir} 15 | Libs: -L${libdir} -l@PROJECT_NAME@-@GIR_VERSION@ 16 | -------------------------------------------------------------------------------- /src/image/ialloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ialloc.c ---- Source Image Utility 3 | * 4 | * by Michal Stencl Copyright (c) 1998 5 | * - [stenclpmd@ba.telecom.sk] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * modifications by Hartmut Schirmer Copyright (c) 1998 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "image.h" 25 | #include "libgrx.h" 26 | 27 | int _GrImageTestSize(int wdt, int hgt) 28 | { 29 | int total; 30 | GRX_ENTER(); 31 | total = grx_screen_get_context_size(wdt, hgt); 32 | GRX_RETURN(total); 33 | } 34 | 35 | GrxPixmap *_GrImageAllocate(GrxContext *ctx, int nwidth, int nheight) 36 | { 37 | GrxPixmap *img; 38 | 39 | GRX_ENTER(); 40 | img = NULL; 41 | if (_GrImageTestSize(nwidth, nheight) <= 0) 42 | goto done; 43 | if (!grx_context_new(nwidth, nheight, NULL, ctx)) 44 | goto done; 45 | img = malloc(sizeof(GrxPixmap)); 46 | if (!img) { 47 | grx_context_unref(ctx); 48 | goto done; 49 | } 50 | img->is_pixmap = 1; 51 | img->width = nwidth; 52 | img->height = nheight; 53 | img->mode = 0; 54 | img->source = ctx->frame; 55 | img->source.memory_flags = 3; /* MY_CONTEXT & MY_MEMORY */ 56 | img->context = NULL; 57 | done: 58 | GRX_RETURN(img); 59 | } 60 | -------------------------------------------------------------------------------- /src/image/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * image.h ---- Source Image Utility 3 | * 4 | * by Michal Stencl Copyright (c) 1998 5 | * - [stenclpmd@ba.telecom.sk] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * modifications by Hartmut Schirmer (c) 1998 18 | */ 19 | 20 | #ifndef __IMAGE_H_INCLUDED__ 21 | #define __IMAGE_H_INCLUDED__ 22 | 23 | #include 24 | 25 | #include 26 | 27 | G_GNUC_INTERNAL int _GrImageTestSize(gint wdt, gint hgt); 28 | G_GNUC_INTERNAL GrxPixmap *_GrImageAllocate(GrxContext *ctx, gint nwidth, gint nheight); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/image/istretch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * istretch.c ---- Source Image Utility 3 | * 4 | * Copyright (c) 1998 by Michal Stencl and Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include "clipping.h" 21 | #include "grdriver.h" 22 | #include "image.h" 23 | #include "libgrx.h" 24 | 25 | /** 26 | * grx_pixmap_stretch: 27 | * @pixmap: the source pixmap 28 | * @new_width: the new width 29 | * @new_height: the new height 30 | * 31 | * Creates a new pixmap stretching @pixmap to @new_width by @new_height. 32 | * 33 | * Returns: (transfer full): the new pixmap 34 | */ 35 | GrxPixmap *grx_pixmap_stretch(GrxPixmap *p, gint nwidth, gint nheight) 36 | { 37 | GrxContext ctx; 38 | GrxPixmap *img; 39 | 40 | GRX_ENTER(); 41 | img = _GrImageAllocate(&ctx, nwidth, nheight); 42 | if (img) 43 | _GrFrDrvGenericStretchBlt(&ctx.frame, 0, 0, nwidth, nheight, &p->source, 0, 0, 44 | p->width, p->height, p->mode); 45 | GRX_RETURN(img); 46 | } 47 | -------------------------------------------------------------------------------- /src/include/access24.h: -------------------------------------------------------------------------------- 1 | /* 2 | * access24.h ---- 16M color (24bit) access macros 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Contributions by: (See "doc/credits.doc" for details) 18 | * Hartmut Schirmer (hsc@techfak.uni-kiel.de) 19 | */ 20 | 21 | #ifndef __ACCESS24_H_INCLUDED__ 22 | #define __ACCESS24_H_INCLUDED__ 23 | 24 | #ifndef __LIBGRX_H_INCLUDED__ 25 | #include "libgrx.h" 26 | #endif 27 | 28 | #ifndef __MEMPEEK_H_INCLUDED__ 29 | #include "mempeek.h" 30 | #endif 31 | 32 | #if G_BYTE_ORDER == G_LITTLE_ENDIAN 33 | /* read color component from 32bit variable */ 34 | #define RD24BYTE(p, idx) peek_b(((GR_int8u *)(&p)) + idx) 35 | /* write color componet to 32bit variable */ 36 | #define WR24BYTE(p, idx, cc) poke_b(((GR_int8u *)(&p)) + idx, cc) 37 | #else 38 | /* read color component from 32bit variable */ 39 | #define RD24BYTE(p, idx) peek_b(((GR_int8u *)(&p)) + idx + 1) 40 | /* write color componet to 32bit variable */ 41 | #define WR24BYTE(p, idx, cc) poke_b(((GR_int8u *)(&p)) + idx + 1, cc) 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/include/colors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * colors.h ---- GRX library private include file 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #ifndef __INCLUDE_COLORS_H__ 19 | #define __INCLUDE_COLORS_H__ 20 | 21 | #include 22 | 23 | #include 24 | 25 | /* 26 | * color stuff 27 | */ 28 | G_GNUC_INTERNAL extern int 29 | _GR_firstFreeColor; /* can't access all colors on all systems */ 30 | G_GNUC_INTERNAL extern int 31 | _GR_lastFreeColor; /* eg. X11 and other windowing systems */ 32 | G_GNUC_INTERNAL int _GrResetColors( 33 | void); /* like grx_color_info_reset_colors but return true on success */ 34 | 35 | #ifndef C_OPER 36 | #define C_OPER(color) (unsigned int)(((GrxColor)(color) >> 24) & 15) 37 | #endif 38 | #define C_WRITE (int)(GRX_COLOR_MODE_WRITE >> 24) 39 | #define C_XOR (int)(GRX_COLOR_MODE_XOR >> 24) 40 | #define C_OR (int)(GRX_COLOR_MODE_OR >> 24) 41 | #define C_AND (int)(GRX_COLOR_MODE_AND >> 24) 42 | #define C_IMAGE (int)(GRX_COLOR_MODE_IMAGE >> 24) 43 | #define C_COLOR GRX_COLOR_VALUE_MASK 44 | 45 | #endif /* __INCLUDE_COLOR_H__ */ 46 | -------------------------------------------------------------------------------- /src/include/docolor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * docolor.h ---- color mode operation check table 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Contributions by: (See "doc/credits.doc" for details) 18 | * Hartmut Schirmer (hsc@techfak.uni-kiel.de) 19 | */ 20 | 21 | #ifndef DOCOLOR_H 22 | #define DOCOLOR_H 23 | 24 | #include 25 | 26 | G_GNUC_INTERNAL extern unsigned int _GrFDdotable8[]; 27 | 28 | #define DOCOLOR8(c, op) (_GrFDdotable8[(op)] ^ (unsigned int)(unsigned char)(c)) 29 | 30 | #endif /* DOCOLOR_H */ 31 | -------------------------------------------------------------------------------- /src/include/gcc/asmsupp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Define assembler memonics for asm code creation 3 | * and memonic extensions for different operand sizes 4 | */ 5 | 6 | #define MOV_INS mov 7 | #define XOR_INS xor 8 | #define OR_INS or 9 | #define AND_INS and 10 | 11 | #define OP8b b 12 | #define OP16b w 13 | #define OP32b l 14 | -------------------------------------------------------------------------------- /src/include/globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * globals.h ---- GRX library private include file 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #ifndef __INCLUDE_GLOBALS_H__ 19 | #define __INCLUDE_GLOBALS_H__ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | /* 29 | * global library data structures 30 | */ 31 | extern struct _GR_driverInfo _GrDriverInfo; 32 | extern struct _GR_contextInfo _GrContextInfo; 33 | extern struct _GR_colorInfo _GrColorInfo; 34 | extern struct _GR_mouseInfo _GrMouseInfo; 35 | 36 | #define GrDriverInfo (&_GrDriverInfo) 37 | #define GrContextInfo (&_GrContextInfo) 38 | #define GrColorInfo (&_GrColorInfo) 39 | #define GrMouseInfo (&_GrMouseInfo) 40 | 41 | #define DRVINFO (&_GrDriverInfo) 42 | #define CXTINFO (&_GrContextInfo) 43 | #define CLRINFO (&_GrColorInfo) 44 | #define MOUINFO (&_GrMouseInfo) 45 | 46 | #define CURC (&(CXTINFO->current)) 47 | #define SCRN (&(CXTINFO->screen)) 48 | #define FDRV (&(DRVINFO->fdriver)) 49 | #define SDRV (&(DRVINFO->sdriver)) 50 | #define VDRV ((DRVINFO->vdriver)) 51 | 52 | #endif /* __INCLUDE_GLOBALS_H__ */ 53 | -------------------------------------------------------------------------------- /src/include/highlow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * highlow.h ---- combining two BYTES into one WORD 3 | * 4 | * Copyright (c) 1997 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | /* combine two bytes into one word: generic version */ 18 | #define __highlow__(hi, lo) ((((GR_int16u)(hi)) << 8) | ((GR_int8u)(lo))) 19 | 20 | #ifdef __GNUC__ 21 | #include "gcc/highlow.h" 22 | #endif 23 | 24 | #ifndef highlow 25 | #define highlow(hi, lo) __highlow__((hi), (lo)) 26 | #endif 27 | 28 | #ifndef highlowP 29 | #define highlowP(p) highlow(*((GR_int8u *)(p)), *(((GR_int8u *)(p)) + 1)) 30 | #endif 31 | -------------------------------------------------------------------------------- /src/include/scanline_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * scanline_buf.h ---- common scan line buffer 3 | * 4 | * Copyright (c) 2020 David Lechner 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | G_GNUC_INTERNAL GrxColor *_grx_get_scanline_buf(gint n_colors); 22 | -------------------------------------------------------------------------------- /src/include/usercord.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usercord.h 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "usrscale.h" 22 | 23 | #define U2SX(x, c) SCALE(x, ((x) - (c)->user_x_base), (c)->x_max, (c)->user_width) 24 | #define U2SY(y, c) SCALE(y, ((y) - (c)->user_y_base), (c)->y_max, (c)->user_height) 25 | 26 | #define S2UX(x, c) \ 27 | do { \ 28 | SCALE(x, x, (c)->user_width, (c)->x_max); \ 29 | (x) += (c)->user_x_base; \ 30 | } while (0) 31 | 32 | #define S2UY(y, c) \ 33 | do { \ 34 | SCALE(y, y, (c)->user_height, (c)->y_max); \ 35 | (y) += (c)->user_y_base; \ 36 | } while (0) 37 | -------------------------------------------------------------------------------- /src/include/usrscale.h: -------------------------------------------------------------------------------- 1 | /* 2 | * usrscale.h 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #ifndef _SCALE_H_ 20 | #define _SCALE_H_ 21 | 22 | #include "arith.h" 23 | 24 | #define SCALE(var, arg, nom, den) \ 25 | do { \ 26 | (var) = iscale((arg), (nom), (den)); \ 27 | } while (0) 28 | 29 | #define USCALE(var, arg, nom, den) \ 30 | do { \ 31 | (var) = uscale((arg), (nom), (den)); \ 32 | } while (0) 33 | 34 | #endif /* whole file */ 35 | -------------------------------------------------------------------------------- /src/include/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * util.h ---- GRX library private include file 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #ifndef __INCLUDE_UTIL_H__ 19 | #define __INCLUDE_UTIL_H__ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | /* 27 | * internal utility functions 28 | */ 29 | G_GNUC_INTERNAL const GrxFrameDriver *_GrFindFrameDriver(GrxFrameMode mode); 30 | G_GNUC_INTERNAL const GrxFrameDriver *_GrFindRAMframeDriver(GrxFrameMode mode); 31 | 32 | G_GNUC_INTERNAL void _GrCloseVideoDriver(void); 33 | G_GNUC_INTERNAL void _GrDummyFunction(void); 34 | 35 | #endif /* __INCLUDE_UTIL_H__ */ 36 | -------------------------------------------------------------------------------- /src/marshal.list: -------------------------------------------------------------------------------- 1 | # see glib-genmarshal(1) for a detailed description of the file format 2 | 3 | BOOLEAN:BOXED 4 | -------------------------------------------------------------------------------- /src/mouse/input.h: -------------------------------------------------------------------------------- 1 | /* 2 | * input.h ---- declarations and code pieces for input processing 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "mouse.h" 19 | 20 | #define test_unblock(flag) \ 21 | do { \ 22 | static int checkcnt = 1000; \ 23 | (flag) = FALSE; \ 24 | if (--checkcnt <= 0) { \ 25 | checkcnt = 1000; \ 26 | flag = (TRUE); \ 27 | } \ 28 | } while (0) 29 | 30 | #define COMPATIBLE(c) ((c)->work.gc_driver->mode == SDRV->rmode) 31 | 32 | void _GrInitMouseCursor(void); 33 | int _GrCheckKeyboardHit(void); 34 | int _GrReadCharFromKeyboard(void); 35 | -------------------------------------------------------------------------------- /src/mouse/mouinfo.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mouinfo.c ---- the mouse info data structure 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "mouse.h" 20 | #undef GrMouseInfo 21 | 22 | const struct _GR_mouseInfo *const GrMouseInfo = &_GrMouseInfo; 23 | struct _GR_mouseInfo _GrMouseInfo = { 0 }; 24 | -------------------------------------------------------------------------------- /src/pattern/patfpoly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * patfpoly.c 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * Copyright (C) 1992, Csaba Biegl 8 | * 820 Stirrup Dr, Nashville, TN, 37221 9 | * csaba@vuse.vanderbilt.edu 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include "libgrx.h" 23 | #include "shapes.h" 24 | 25 | /** 26 | * grx_draw_filled_polygon_with_pixmap: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @p: the pixmap 30 | * 31 | * Draw a filled polygon on the current context that connects each point in 32 | * the @points array using the specified pixmap. 33 | * 34 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 35 | * It will be automatically appended to the list if it is missing. 36 | */ 37 | void grx_draw_filled_polygon_with_pixmap(int n, const GrxPoint *pt, GrxPixmap *p) 38 | { 39 | GrFillArg fa; 40 | 41 | fa.p = p; 42 | if (n <= 3) 43 | _GrScanConvexPoly(n, pt, &_GrPatternFiller, fa); 44 | else 45 | _GrScanPolygon(n, pt, &_GrPatternFiller, fa); 46 | } 47 | -------------------------------------------------------------------------------- /src/pattern/patternf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * patternf.c ---- data structure for standard pattern filler 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include "libgrx.h" 18 | #include "shapes.h" 19 | 20 | GrFiller _GrPatternFiller = { _GrDrawPatternedPixel, _GrDrawPatternedLine, 21 | _GrFillPatternedScanLine }; 22 | -------------------------------------------------------------------------------- /src/pattern/pattfldf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pattfldf.c ---- fill an arbitrary area with a pattern 3 | * 4 | * Copyright (c) 1997 Hartmut Schirmer 5 | * [e-mail: hsc@techfak.uni-kiel.de] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "clipping.h" 19 | #include "libgrx.h" 20 | #include "shapes.h" 21 | 22 | /** 23 | * grx_flood_fill_with_pixmap: 24 | * @x: the starting X coordinate 25 | * @y: the starting Y coordinate 26 | * @border: the color of the border that contains the fill 27 | * @p: the pixmap of the fill 28 | * 29 | * Flood-fills the area of the current context bounded by the color @border 30 | * using @x, @y as the starting point. 31 | */ 32 | void grx_flood_fill_with_pixmap(int x, int y, GrxColor border, GrxPixmap *p) 33 | { 34 | GrFillArg fval; 35 | 36 | fval.p = p; 37 | _GrFloodFill(x, y, border, &_GrPatternFiller, fval); 38 | } 39 | -------------------------------------------------------------------------------- /src/pattern/pattline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pattline.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [e-mail : goffioul@emic.ucl.ac.be] 6 | * 7 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 8 | * [e-mail: csaba@vuse.vanderbilt.edu] 9 | * 10 | * Copyright (C) 1992, Csaba Biegl 11 | * 820 Stirrup Dr, Nashville, TN, 37221 12 | * csaba@vuse.vanderbilt.edu 13 | * 14 | * This file is part of the GRX graphics library. 15 | * 16 | * The GRX graphics library is free software; you can redistribute it 17 | * and/or modify it under some conditions; see the "copying.grx" file 18 | * for details. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | */ 24 | 25 | #include 26 | 27 | #include "libgrx.h" 28 | #include "shapes.h" 29 | 30 | /** 31 | * grx_draw_line_with_pixmap: 32 | * @x1: starting X coordinate 33 | * @y1: starting Y coordinate 34 | * @x2: ending X coordinate 35 | * @y2: ending Y coordinate 36 | * @o: the line options 37 | * @p: the pixmap 38 | * 39 | * Draws a line on the current context from the starting coordinates to the 40 | * ending coordinates using the specified line options and pixmap. 41 | */ 42 | void grx_draw_line_with_pixmap( 43 | int x1, int y1, int x2, int y2, const GrxLineOptions *o, GrxPixmap *p) 44 | { 45 | GrFillArg fval; 46 | GrxPoint points[2]; 47 | 48 | points[0].x = x1; 49 | points[0].y = y1; 50 | points[1].x = x2; 51 | points[1].y = y2; 52 | fval.p = p; 53 | _GrDrawCustomPolygon(2, points, o, &_GrPatternFiller, fval, FALSE, FALSE); 54 | } 55 | -------------------------------------------------------------------------------- /src/pattern/pfcirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pfcirc.c 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * Copyright (C) 1992, Csaba Biegl 8 | * 820 Stirrup Dr, Nashville, TN, 37221 9 | * csaba@vuse.vanderbilt.edu 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | 24 | #include "libgrx.h" 25 | 26 | /** 27 | * grx_draw_filled_circle_with_pixmap: 28 | * @xc: the X coordinate of the center of the circle 29 | * @yc: the Y coordinate of the center of the circle 30 | * @r: the radius of the circle 31 | * @p: the pixmap 32 | * 33 | * Draws a filled circle on the current context centered at the specified 34 | * coordinates with the specified radius and pixmap. 35 | */ 36 | void grx_draw_filled_circle_with_pixmap(int xc, int yc, int r, GrxPixmap *p) 37 | { 38 | grx_draw_filled_ellipse_with_pixmap(xc, yc, r, r, p); 39 | } 40 | -------------------------------------------------------------------------------- /src/pattern/pfcirca.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pfcirca.c 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * Copyright (C) 1992, Csaba Biegl 8 | * 820 Stirrup Dr, Nashville, TN, 37221 9 | * csaba@vuse.vanderbilt.edu 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "libgrx.h" 26 | 27 | /** 28 | * grx_draw_filled_circle_arc_with_pixmap: 29 | * @xc: the X coordinate of the center of the arc 30 | * @yc: the Y coordinate of the center of the arc 31 | * @r: the radius of the arc 32 | * @start: the starting angle in 1/10ths of degrees 33 | * @end: the ending angle in 1/10ths of degrees 34 | * @style: the arc style 35 | * @p: the pixmap 36 | * 37 | * Draws a filled arc on the current context centered at the specified 38 | * coordinates from the starting angle to the ending angle with the specified 39 | * radius, arc style and pixmap. 40 | */ 41 | void grx_draw_filled_circle_arc_with_pixmap( 42 | int xc, int yc, int r, int start, int end, GrxArcStyle style, GrxPixmap *p) 43 | { 44 | grx_draw_filled_ellipse_arc_with_pixmap(xc, yc, r, r, start, end, style, p); 45 | } 46 | -------------------------------------------------------------------------------- /src/pattern/pfelli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pfelli.c 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * Copyright (C) 1992, Csaba Biegl 8 | * 820 Stirrup Dr, Nashville, TN, 37221 9 | * csaba@vuse.vanderbilt.edu 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include "libgrx.h" 23 | #include "shapes.h" 24 | 25 | /** 26 | * grx_draw_filled_ellipse_with_pixmap: 27 | * @xc: the X coordinate of the center of the ellipse 28 | * @yc: the Y coordinate of the center of the ellipse 29 | * @rx: the radius in the X direction 30 | * @ry: the radius in the Y direction 31 | * @p: the pixmap 32 | * 33 | * Draws a filled ellipse on the current context using the specified pixmap. 34 | * 35 | * The ellipse can only draw ellipses with its major axis parallel with either 36 | * the X or Y coordinate axis 37 | */ 38 | void grx_draw_filled_ellipse_with_pixmap(int xc, int yc, int rx, int ry, GrxPixmap *p) 39 | { 40 | GrFillArg fa; 41 | 42 | fa.p = p; 43 | _GrScanEllipse(xc, yc, rx, ry, &_GrPatternFiller, fa, TRUE); 44 | } 45 | -------------------------------------------------------------------------------- /src/pattern/ptcirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ptcirc.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [e-mail : goffioul@emic.ucl.ac.be] 6 | * 7 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 8 | * [e-mail: csaba@vuse.vanderbilt.edu] 9 | * 10 | * Copyright (C) 1992, Csaba Biegl 11 | * 820 Stirrup Dr, Nashville, TN, 37221 12 | * csaba@vuse.vanderbilt.edu 13 | * 14 | * This file is part of the GRX graphics library. 15 | * 16 | * The GRX graphics library is free software; you can redistribute it 17 | * and/or modify it under some conditions; see the "copying.grx" file 18 | * for details. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | */ 24 | 25 | #include 26 | 27 | #include "libgrx.h" 28 | 29 | /** 30 | * grx_draw_circle_with_pixmap: 31 | * @xc: the X coordinate of the center of the circle 32 | * @yc: the Y coordinate of the center of the circle 33 | * @r: the radius of the circle 34 | * @o: the line options 35 | * @p: the pixmap 36 | * 37 | * Draws a circle on the current context centered at the specified coordinates 38 | * with the specified radius and line options and pixmap. 39 | */ 40 | void grx_draw_circle_with_pixmap( 41 | int xc, int yc, int r, const GrxLineOptions *o, GrxPixmap *p) 42 | { 43 | grx_draw_ellipse_with_pixmap(xc, yc, r, r, o, p); 44 | } 45 | -------------------------------------------------------------------------------- /src/pattern/ptcirca.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ptcirca.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [e-mail : goffioul@emic.ucl.ac.be] 6 | * 7 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 8 | * [e-mail: csaba@vuse.vanderbilt.edu] 9 | * 10 | * Copyright (C) 1992, Csaba Biegl 11 | * 820 Stirrup Dr, Nashville, TN, 37221 12 | * csaba@vuse.vanderbilt.edu 13 | * 14 | * This file is part of the GRX graphics library. 15 | * 16 | * The GRX graphics library is free software; you can redistribute it 17 | * and/or modify it under some conditions; see the "copying.grx" file 18 | * for details. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include "libgrx.h" 29 | 30 | /** 31 | * grx_draw_circle_arc_with_pixmap: 32 | * @xc: the X coordinate of the center of the arc 33 | * @yc: the Y coordinate of the center of the arc 34 | * @r: the radius of the arc 35 | * @start: the starting angle in 1/10ths of degrees 36 | * @end: the ending angle in 1/10ths of degrees 37 | * @style: the arc style 38 | * @o: the line options 39 | * @p: the pixmap 40 | * 41 | * Draws an arc on the current context centered at the specified coordinates 42 | * from the starting angle to the ending angle with the specified radius, 43 | * arc style and line options and pixmap. 44 | */ 45 | void grx_draw_circle_arc_with_pixmap(int xc, int yc, int r, int start, int end, 46 | GrxArcStyle style, const GrxLineOptions *o, GrxPixmap *p) 47 | { 48 | grx_draw_ellipse_arc_with_pixmap(xc, yc, r, r, start, end, style, o, p); 49 | } 50 | -------------------------------------------------------------------------------- /src/setup/colorbw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * colorbw.c ---- standard colors: black and white 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 6 | * [e-mail: csaba@vuse.vanderbilt.edu] 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_color_get_black: 24 | * 25 | * Gets the color value for black. 26 | * 27 | * This is guaranteed to be 0. In C code, you can use #GRX_COLOR_BLACK for short. 28 | * 29 | * Returns: the color value. 30 | */ 31 | #ifdef grx_color_get_black 32 | #undef grx_color_get_black 33 | #endif 34 | GrxColor grx_color_get_black(void) 35 | { 36 | GRX_ENTER(); 37 | if (CLRINFO->black == GRX_COLOR_NONE) 38 | CLRINFO->black = grx_color_get(0, 0, 0); 39 | GRX_RETURN(CLRINFO->black); 40 | } 41 | 42 | /** 43 | * grx_color_get_white: 44 | * 45 | * Gets the color value for white. 46 | * 47 | * In C code, you can use #GRX_COLOR_WHITE for short. 48 | * 49 | * Returns: the color value. 50 | */ 51 | #ifdef grx_color_get_white 52 | #undef grx_color_get_white 53 | #endif 54 | GrxColor grx_color_get_white(void) 55 | { 56 | GRX_ENTER(); 57 | if (CLRINFO->white == GRX_COLOR_NONE) 58 | CLRINFO->white = grx_color_get(255, 255, 255); 59 | GRX_RETURN(CLRINFO->white); 60 | } 61 | -------------------------------------------------------------------------------- /src/setup/cxtinfo.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cxtinfo.c ---- the context info data structure 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "globals.h" 19 | #include "libgrx.h" 20 | 21 | #undef GrContextInfo 22 | 23 | const struct _GR_contextInfo *const GrContextInfo = &_GrContextInfo; 24 | struct _GR_contextInfo _GrContextInfo = { 25 | .current = { 26 | .frame = { 27 | .base_address = NULL, 28 | .selector = 0, 29 | .is_on_screen = TRUE, 30 | .memory_flags = 0, 31 | .line_offset = 0, 32 | .driver = &DRVINFO->tdriver, 33 | }, 34 | .root = NULL, 35 | }, 36 | .screen = { 37 | .frame = { 38 | .base_address = NULL, 39 | .selector = 0, 40 | .is_on_screen = TRUE, 41 | .memory_flags = 0, 42 | .line_offset = 0, 43 | .driver = &DRVINFO->tdriver, 44 | }, 45 | .root = NULL, 46 | }, 47 | }; 48 | -------------------------------------------------------------------------------- /src/setup/dpi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dpi.c - display resolution information 3 | * 4 | * Copyright (c) 2017 David Lechner 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | /** 22 | * grx_get_dpi: 23 | * 24 | * Gets the display resolution of the current graphics mode or #GRX_DEFAULT_DPI 25 | * if the current driver does not support getting the resolution. 26 | * 27 | * The display resolution can also be manually specified using grx_set_driver() 28 | * or the GRX_DRIVER environment variable. 29 | * 30 | * Returns: the resolution in dots per inch 31 | */ 32 | guint grx_get_dpi(void) 33 | { 34 | if (GrDriverInfo->dpi) { 35 | return GrDriverInfo->dpi; 36 | } 37 | 38 | if (!GrDriverInfo->vdriver || !GrDriverInfo->vdriver->get_dpi) { 39 | return GRX_DEFAULT_DPI; 40 | } 41 | 42 | return GrDriverInfo->vdriver->get_dpi(GrDriverInfo->vdriver); 43 | } 44 | -------------------------------------------------------------------------------- /src/shape/circle1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * circle1.c ---- draw ellipse 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | /** 22 | * grx_draw_ellipse: 23 | * @xc: the X coordinate of the center of the ellipse 24 | * @yc: the Y coordinate of the center of the ellipse 25 | * @rx: the radius in the X direction 26 | * @ry: the radius in the Y direction 27 | * @c: the color 28 | * 29 | * Draws an ellipse on the current context using the specified color. 30 | * 31 | * The ellipse can only draw ellipses with its major axis parallel with either 32 | * the X or Y coordinate axis 33 | */ 34 | void grx_draw_ellipse(int xc, int yc, int rx, int ry, GrxColor c) 35 | { 36 | GrFillArg fval; 37 | fval.color = c; 38 | _GrScanEllipse(xc, yc, rx, ry, &_GrSolidFiller, fval, FALSE); 39 | } 40 | -------------------------------------------------------------------------------- /src/shape/circle3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * circle3.c ---- draw circle 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_circle: 25 | * @xc: the X coordinate of the center of the circle 26 | * @yc: the Y coordinate of the center of the circle 27 | * @r: the radius of the circle 28 | * @c: the color 29 | * 30 | * Draws a circle on the current context centered at the specified coordinates 31 | * with the specified radius and color. 32 | */ 33 | void grx_draw_circle(int xc, int yc, int r, GrxColor c) 34 | { 35 | grx_draw_ellipse(xc, yc, r, r, c); 36 | } 37 | -------------------------------------------------------------------------------- /src/shape/circle4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * circle4.c ---- draw circle arc 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_circle_arc: 25 | * @xc: the X coordinate of the center of the arc 26 | * @yc: the Y coordinate of the center of the arc 27 | * @r: the radius of the arc 28 | * @start: the starting angle in 1/10ths of degrees 29 | * @end: the ending angle in 1/10ths of degrees 30 | * @style: the arc style 31 | * @c: the color 32 | * 33 | * Draws an arc on the current context centered at the specified coordinates 34 | * from the starting angle to the ending angle with the specified radius, 35 | * arc style and color. 36 | */ 37 | void grx_draw_circle_arc( 38 | int xc, int yc, int r, int start, int end, GrxArcStyle style, GrxColor c) 39 | { 40 | grx_draw_ellipse_arc(xc, yc, r, r, start, end, style, c); 41 | } 42 | -------------------------------------------------------------------------------- /src/shape/fillcir1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillcir1.c ---- filled circle 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_filled_circle: 25 | * @xc: the X coordinate of the center of the circle 26 | * @yc: the Y coordinate of the center of the circle 27 | * @r: the radius of the circle 28 | * @c: the color 29 | * 30 | * Draws a filled circle on the current context centered at the specified 31 | * coordinates with the specified radius and color. 32 | */ 33 | void grx_draw_filled_circle(int xc, int yc, int r, GrxColor c) 34 | { 35 | grx_draw_filled_ellipse(xc, yc, r, r, c); 36 | } 37 | -------------------------------------------------------------------------------- /src/shape/fillcir2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillcir2.c ---- filled circle arc 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_filled_circle_arc: 25 | * @xc: the X coordinate of the center of the arc 26 | * @yc: the Y coordinate of the center of the arc 27 | * @r: the radius of the arc 28 | * @start: the starting angle in 1/10ths of degrees 29 | * @end: the ending angle in 1/10ths of degrees 30 | * @style: the arc style 31 | * @c: the color 32 | * 33 | * Draws a filled arc on the current context centered at the specified 34 | * coordinates from the starting angle to the ending angle with the specified 35 | * radius, arc style and color. 36 | */ 37 | void grx_draw_filled_circle_arc( 38 | int xc, int yc, int r, int start, int end, GrxArcStyle style, GrxColor c) 39 | { 40 | grx_draw_filled_ellipse_arc(xc, yc, r, r, start, end, style, c); 41 | } 42 | -------------------------------------------------------------------------------- /src/shape/fillcnvx.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillcnvx.c ---- fill a convex polygon with a solid color 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | /** 22 | * grx_draw_filled_convex_polygon: 23 | * @n_points: the number of points in @points 24 | * @points: (array length=n_points): an array of #GrxPoint 25 | * @c: the color 26 | * 27 | * Draw a filled polygon on the current context that connects each point in 28 | * the @points array using the specified color. 29 | * 30 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 31 | * It will be automatically appended to the list if it is missing. 32 | * 33 | * This version is slightly more efficient that grx_draw_filled_polygon() but 34 | * requires that the polygon is convex. It can also be used to fill some concave 35 | * polygons whose boundaries do not intersect any horizontal scan line more than 36 | * twice. It can also be used to fill several disjoint nonoverlapping polygons 37 | * in a single operation. 38 | */ 39 | void grx_draw_filled_convex_polygon(int n, const GrxPoint *pt, GrxColor c) 40 | { 41 | GrFillArg fval; 42 | fval.color = c; 43 | _GrScanConvexPoly(n, pt, &_GrSolidFiller, fval); 44 | } 45 | -------------------------------------------------------------------------------- /src/shape/fillell1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillell1.c ---- filled ellipse 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | /** 22 | * grx_draw_filled_ellipse: 23 | * @xc: the X coordinate of the center of the ellipse 24 | * @yc: the Y coordinate of the center of the ellipse 25 | * @rx: the radius in the X direction 26 | * @ry: the radius in the Y direction 27 | * @c: the color 28 | * 29 | * Draws a filled ellipse on the current context using the specified color. 30 | * 31 | * The ellipse can only draw ellipses with its major axis parallel with either 32 | * the X or Y coordinate axis 33 | */ 34 | void grx_draw_filled_ellipse(int xc, int yc, int rx, int ry, GrxColor c) 35 | { 36 | GrFillArg fval; 37 | fval.color = c; 38 | _GrScanEllipse(xc, yc, rx, ry, &_GrSolidFiller, fval, TRUE); 39 | } 40 | -------------------------------------------------------------------------------- /src/shape/fillpoly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fillpoly.c ---- fill an arbitrary polygon with a solid color 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | /** 22 | * grx_draw_filled_polygon: 23 | * @n_points: the number of points in @points 24 | * @points: (array length=n_points): an array of #GrxPoint 25 | * @c: the color 26 | * 27 | * Draw a filled polygon on the current context that connects each point in 28 | * the @points array using the specified color. 29 | * 30 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 31 | * It will be automatically appended to the list if it is missing. 32 | */ 33 | void grx_draw_filled_polygon(int n, const GrxPoint *pt, GrxColor c) 34 | { 35 | GrFillArg fval; 36 | fval.color = c; 37 | _GrScanPolygon(n, pt, &_GrSolidFiller, fval); 38 | } 39 | -------------------------------------------------------------------------------- /src/shape/floodfil.c: -------------------------------------------------------------------------------- 1 | /* 2 | * floodfil.c ---- fill an arbitrary area with a solid color 3 | * 4 | * Copyright (c) 1997 Hartmut Schirmer 5 | * [e-mail: hsc@techfak.uni-kiel.de] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | /** 22 | * grx_flood_fill: 23 | * @x: the starting X coordinate 24 | * @y: the starting Y coordinate 25 | * @border: the color of the border that contains the fill 26 | * @c: the color of the fill 27 | * 28 | * Flood-fills the area of the current context bounded by the color @border 29 | * using @x, @y as the starting point. 30 | */ 31 | void grx_flood_fill(int x, int y, GrxColor border, GrxColor c) 32 | { 33 | GrFillArg fval; 34 | fval.color = c; 35 | _GrFloodFill(x, y, border, &_GrSolidFiller, fval); 36 | } 37 | -------------------------------------------------------------------------------- /src/shape/genpoints.c: -------------------------------------------------------------------------------- 1 | /* 2 | * genpoints.c - generate points for a polyline/polygon 3 | * 4 | * Copyright (c) 2017 David Lechner 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | /** 22 | * grx_generate_points: 23 | * @coords: (element-type gint): the coordinate pairs 24 | * 25 | * Creates an array of points. 26 | * 27 | * This function is intended for use with language bindings that don't have 28 | * an elegant way to create an array of points. Each pair of coordinates is 29 | * converted into a point, so the returned array will be 1/2 the length of 30 | * @coords. 31 | * 32 | * Returns: (element-type GrxPoint) (transfer full): a new #GArray 33 | */ 34 | GArray *grx_generate_points(GArray *coords) 35 | { 36 | GArray *points; 37 | guint n_points; 38 | gint i; 39 | 40 | g_return_val_if_fail(coords != NULL, NULL); 41 | 42 | n_points = coords->len / 2; 43 | points = g_array_sized_new(FALSE, FALSE, sizeof(GrxPoint), n_points); 44 | 45 | for (i = 0; i < n_points; i++) { 46 | GrxPoint p = { 47 | .x = g_array_index(coords, gint, i * 2), 48 | .y = g_array_index(coords, gint, i * 2 + 1), 49 | }; 50 | g_array_append_val(points, p); 51 | } 52 | 53 | return points; 54 | } 55 | -------------------------------------------------------------------------------- /src/shape/polygon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * POLYGON.C ---- draw a closed polygon 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] See "copying.grx" for details. 6 | */ 7 | 8 | #include "libgrx.h" 9 | #include "shapes.h" 10 | 11 | /** 12 | * grx_draw_polygon: 13 | * @n_points: the number of points in @points 14 | * @points: (array length=n_points): an array of #GrxPoint 15 | * @c: the color 16 | * 17 | * Draw a closed polygon on the current context that connects each point in 18 | * the @points array using the specified color. 19 | * 20 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 21 | * It will be automatically appended to the list if it is missing. 22 | */ 23 | void grx_draw_polygon(int n, const GrxPoint *pt, GrxColor c) 24 | { 25 | GrFillArg fval; 26 | fval.color = c; 27 | _GrDrawPolygon(n, pt, &_GrSolidFiller, fval, TRUE); 28 | } 29 | -------------------------------------------------------------------------------- /src/shape/polyline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * POLYLINE.C ---- draw an open ended polygon 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] See "copying.grx" for details. 6 | */ 7 | 8 | #include "libgrx.h" 9 | #include "shapes.h" 10 | 11 | /** 12 | * grx_draw_polyline: 13 | * @n_points: the number of points in @points 14 | * @points: (array length=n_points): an array of #GrxPoint 15 | * @c: the color 16 | * 17 | * Draw a multi-segment line on the current context that connects each point in 18 | * the @points array using the specified color. 19 | */ 20 | void grx_draw_polyline(int n, const GrxPoint *pt, GrxColor c) 21 | { 22 | GrFillArg fval; 23 | fval.color = c; 24 | _GrDrawPolygon(n, pt, &_GrSolidFiller, fval, FALSE); 25 | } 26 | -------------------------------------------------------------------------------- /src/shape/solidfil.c: -------------------------------------------------------------------------------- 1 | /* 2 | * solidfil.c ---- wrapper for solid filling 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include "globals.h" 18 | #include "libgrx.h" 19 | #include "shapes.h" 20 | 21 | static void pixel(int x, int y, GrFillArg fval) 22 | { 23 | GRX_ENTER(); 24 | FDRV->drawpixel(x, y, fval.color); 25 | GRX_LEAVE(); 26 | } 27 | 28 | static void line(int x, int y, int dx, int dy, GrFillArg fval) 29 | { 30 | GRX_ENTER(); 31 | FDRV->drawline(x, y, dx, dy, fval.color); 32 | GRX_LEAVE(); 33 | } 34 | 35 | static void scan(int x, int y, int w, GrFillArg fval) 36 | { 37 | GRX_ENTER(); 38 | FDRV->drawhline(x, y, w, fval.color); 39 | GRX_LEAVE(); 40 | } 41 | 42 | GrFiller _GrSolidFiller = { pixel, line, scan }; 43 | -------------------------------------------------------------------------------- /src/text/error.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include FT_FREETYPE_H 5 | 6 | typedef struct { 7 | gint code; 8 | const gchar *msg; 9 | } FtError; 10 | 11 | #undef __FTERRORS_H__ 12 | #define FT_ERRORDEF(e, v, s) { e, s }, 13 | #define FT_ERROR_END_LIST \ 14 | { \ 15 | 0, NULL \ 16 | } 17 | 18 | static const FtError ft_errors[] = { 19 | 20 | #include FT_ERRORS_H 21 | 22 | }; 23 | 24 | const gchar *get_ft_error_msg(gint code) 25 | { 26 | const FtError *err; 27 | 28 | for (err = ft_errors; err->msg; err++) { 29 | if (err->code == code) { 30 | return err->msg; 31 | } 32 | } 33 | 34 | g_return_val_if_reached(NULL); 35 | } 36 | -------------------------------------------------------------------------------- /src/text/text.h: -------------------------------------------------------------------------------- 1 | /* 2 | * text.h ---- some shared definitions 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #ifndef __GRX_TEXT_TEXT_H 18 | #define __GRX_TEXT_TEXT_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include FT_FREETYPE_H 24 | 25 | #include 26 | #include 27 | 28 | struct _GrxFont { 29 | FT_Face face; 30 | guint ref_count; 31 | }; 32 | 33 | struct _GrxTextOptions { 34 | GrxFont *font; 35 | GrxColor fg_color; 36 | GrxColor bg_color; 37 | GrxTextHAlign h_align; 38 | GrxTextVAlign v_align; 39 | guint ref_count; 40 | }; 41 | 42 | typedef void (*TextDrawBitmapFunc)(int x, int y, int w, int h, int ox, int oy, 43 | unsigned char *bmp, int pitch, int start, GrxColor fg, GrxColor bg, GrxPixmap *p); 44 | 45 | G_GNUC_INTERNAL FcCharSet *script_to_charset(const gchar *script); 46 | G_GNUC_INTERNAL const gchar *get_ft_error_msg(gint code); 47 | 48 | #endif /* __GRX_TEXT_TEXT_H */ 49 | -------------------------------------------------------------------------------- /src/user/ubox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ubox.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_box: 27 | * @x1: the left X coordinate 28 | * @y1: the top Y coordinate 29 | * @x2: the right X coordinate 30 | * @y2: the bottom Y coordinate 31 | * @c: the color 32 | * 33 | * Draws a rectangle on the current context using the specified coordinates 34 | * and color. 35 | */ 36 | void grx_user_draw_box(int x1, int y1, int x2, int y2, GrxColor c) 37 | { 38 | U2SX(x1, CURC); 39 | U2SY(y1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y2, CURC); 42 | grx_draw_box(x1, y1, x2, y2, c); 43 | } 44 | -------------------------------------------------------------------------------- /src/user/ucbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucbox.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_box_with_options: 26 | * @x1: the left X coordinate 27 | * @y1: the top Y coordinate 28 | * @x2: the right X coordinate 29 | * @y2: the bottom Y coordinate 30 | * @o: the options 31 | * 32 | * Draws a rectangle on the current context using the specified coordinates 33 | * and options. 34 | */ 35 | void grx_user_draw_box_with_options( 36 | int x1, int y1, int x2, int y2, const GrxLineOptions *lo) 37 | { 38 | U2SX(x1, CURC); 39 | U2SX(x2, CURC); 40 | U2SY(y1, CURC); 41 | U2SY(y2, CURC); 42 | grx_draw_box_with_options(x1, y1, x2, y2, lo); 43 | } 44 | -------------------------------------------------------------------------------- /src/user/uccirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uccirc.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle 18 | * looks like a circle on the screen 19 | */ 20 | 21 | #include 22 | 23 | #include "globals.h" 24 | #include "libgrx.h" 25 | #include "usercord.h" 26 | 27 | /** 28 | * grx_user_draw_circle_with_options: 29 | * @xc: the X coordinate of the center of the circle 30 | * @yc: the Y coordinate of the center of the circle 31 | * @r: the radius of the circle 32 | * @o: the options 33 | * 34 | * Draws a circle on the current context centered at the specified coordinates 35 | * with the specified radius and options. 36 | */ 37 | void grx_user_draw_circle_with_options(int xc, int yc, int r, const GrxLineOptions *lo) 38 | { 39 | #ifdef USR_KEEP_SHAPE 40 | U2SX(xc, CURC); 41 | U2SY(yc, CURC); 42 | SCALE(r, r, CURC->x_max, CURC->user_width); 43 | grx_draw_circle_with_options(xc, yc, r, lo); 44 | #else 45 | grx_user_draw_ellipse_with_options(xc, yc, r, r, lo); 46 | #endif /* USR_KEEP_SHAPE */ 47 | } 48 | -------------------------------------------------------------------------------- /src/user/ucelli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucelli.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_ellipse_with_options: 26 | * @xc: the X coordinate of the center of the ellipse 27 | * @yc: the Y coordinate of the center of the ellipse 28 | * @rx: the radius in the X direction 29 | * @ry: the radius in the Y direction 30 | * @o: the options 31 | * 32 | * Draws an ellipse on the current context using the specified options. 33 | * 34 | * The ellipse can only draw ellipses with its major axis parallel with either 35 | * the X or Y coordinate axis 36 | */ 37 | void grx_user_draw_ellipse_with_options( 38 | int xc, int yc, int rx, int ry, const GrxLineOptions *lo) 39 | { 40 | U2SX(xc, CURC); 41 | U2SY(yc, CURC); 42 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 43 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 44 | grx_draw_ellipse_with_options(xc, yc, rx, ry, lo); 45 | } 46 | -------------------------------------------------------------------------------- /src/user/ucellia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucellia.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_ellipse_arc_with_options: 27 | * @xc: the X coordinate of the center of the arc 28 | * @yc: the Y coordinate of the center of the arc 29 | * @rx: the radius in the X direction 30 | * @ry: the radius in the Y direction 31 | * @start: the starting angle in 1/10ths of degrees 32 | * @end: the ending angle in 1/10ths of degrees 33 | * @style: the arc style 34 | * @o: the options 35 | * 36 | * Draws an arc on the current context centered at the specified coordinates 37 | * from the starting angle to the ending angle with the specified radii, 38 | * arc style and options. 39 | */ 40 | void grx_user_draw_ellipse_arc_with_options(int xc, int yc, int rx, int ry, int start, 41 | int end, GrxArcStyle style, const GrxLineOptions *lo) 42 | { 43 | U2SX(xc, CURC); 44 | U2SY(yc, CURC); 45 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 46 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 47 | grx_draw_ellipse_arc_with_options(xc, yc, rx, ry, start, end, style, lo); 48 | } 49 | -------------------------------------------------------------------------------- /src/user/ucirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucirc.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * Copyright (C) 1997, Michael Goffioul 9 | * [goffioul@emic.ucl.ac.be] 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | * 21 | * Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle 22 | * looks like a circle on the screen 23 | */ 24 | 25 | #ifdef USR_KEEP_SHAPE 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | #include "globals.h" 32 | #include "libgrx.h" 33 | #include "usercord.h" 34 | 35 | /** 36 | * grx_user_draw_circle: 37 | * @xc: the X coordinate of the center of the circle 38 | * @yc: the Y coordinate of the center of the circle 39 | * @r: the radius of the circle 40 | * @c: the color 41 | * 42 | * Draws a circle on the current context centered at the specified coordinates 43 | * with the specified radius and color. 44 | */ 45 | void grx_user_draw_circle(int xc, int yc, int r, GrxColor c) 46 | { 47 | #ifdef USR_KEEP_SHAPE 48 | U2SX(xc, CURC); 49 | U2SY(yc, CURC); 50 | SCALE(r, r, CURC->x_max, CURC->user_width); 51 | grx_draw_circle(xc, yc, r, c); 52 | #else 53 | grx_user_draw_ellipse(xc, yc, r, r, c); 54 | #endif 55 | } 56 | -------------------------------------------------------------------------------- /src/user/ucline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucline.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_line_with_options: 26 | * @x1: starting X coordinate 27 | * @y1: starting Y coordinate 28 | * @x2: ending X coordinate 29 | * @y2: ending Y coordinate 30 | * @o: the options 31 | * 32 | * Draws a line on the current context from the starting coordinates to the 33 | * ending coordinates using the specified options. 34 | */ 35 | void grx_user_draw_line_with_options( 36 | int x1, int y1, int x2, int y2, const GrxLineOptions *lo) 37 | { 38 | U2SX(x1, CURC); 39 | U2SX(x2, CURC); 40 | U2SY(y1, CURC); 41 | U2SY(y2, CURC); 42 | grx_draw_line_with_options(x1, y1, x2, y2, lo); 43 | } 44 | -------------------------------------------------------------------------------- /src/user/ucpolyg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucpolyg.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_polygon_with_options: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @o: the options 30 | * 31 | * Draw a closed polygon on the current context that connects each point in 32 | * the @points array using the specified options. 33 | * 34 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 35 | * It will be automatically appended to the list if it is missing. 36 | */ 37 | void grx_user_draw_polygon_with_options( 38 | gint numpts, const GrxPoint *points, const GrxLineOptions *lo) 39 | { 40 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 41 | 42 | for (gint pt = 0; pt < numpts; pt++) { 43 | tmp[pt] = points[pt]; 44 | U2SX(tmp[pt].x, CURC); 45 | U2SY(tmp[pt].y, CURC); 46 | } 47 | 48 | grx_draw_polygon_with_options(numpts, tmp, lo); 49 | } 50 | -------------------------------------------------------------------------------- /src/user/ucpolyl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ucpolyl.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_polyline_with_options: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @o: the options 30 | * 31 | * Draw a multi-segment line on the current context that connects each point in 32 | * the @points array using the specified options. 33 | */ 34 | void grx_user_draw_polyline_with_options( 35 | gint numpts, const GrxPoint *points, const GrxLineOptions *lo) 36 | { 37 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 38 | 39 | for (gint pt = 0; pt < numpts; pt++) { 40 | tmp[pt] = points[pt]; 41 | U2SX(tmp[pt].x, CURC); 42 | U2SY(tmp[pt].y, CURC); 43 | } 44 | 45 | grx_draw_polyline_with_options(numpts, tmp, lo); 46 | } 47 | -------------------------------------------------------------------------------- /src/user/uelli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uelli.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * Copyright (C) 1997, Michael Goffioul 9 | * [goffioul@emic.ucl.ac.be] 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | 24 | #include "globals.h" 25 | #include "libgrx.h" 26 | #include "usercord.h" 27 | 28 | /** 29 | * grx_user_draw_ellipse: 30 | * @xc: the X coordinate of the center of the ellipse 31 | * @yc: the Y coordinate of the center of the ellipse 32 | * @rx: the radius in the X direction 33 | * @ry: the radius in the Y direction 34 | * @c: the color 35 | * 36 | * Draws an ellipse on the current context using the specified color. 37 | * 38 | * The ellipse can only draw ellipses with its major axis parallel with either 39 | * the X or Y coordinate axis 40 | */ 41 | void grx_user_draw_ellipse(int xc, int yc, int rx, int ry, GrxColor c) 42 | { 43 | U2SX(xc, CURC); 44 | U2SY(yc, CURC); 45 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 46 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 47 | grx_draw_ellipse(xc, yc, rx, ry, c); 48 | } 49 | -------------------------------------------------------------------------------- /src/user/uellia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uellia.c 3 | * 4 | * Copyright (C), Michael Goffioul 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "usercord.h" 22 | 23 | /** 24 | * grx_user_draw_ellipse_arc: 25 | * @xc: the X coordinate of the center of the arc 26 | * @yc: the Y coordinate of the center of the arc 27 | * @rx: the radius in the X direction 28 | * @ry: the radius in the Y direction 29 | * @start: the starting angle in 1/10ths of degrees 30 | * @end: the ending angle in 1/10ths of degrees 31 | * @style: the arc style 32 | * @c: the color 33 | * 34 | * Draws an arc on the current context centered at the specified coordinates 35 | * from the starting angle to the ending angle with the specified radii, 36 | * arc style and color. 37 | */ 38 | void grx_user_draw_ellipse_arc( 39 | int xc, int yc, int rx, int ry, int start, int end, GrxArcStyle style, GrxColor c) 40 | { 41 | U2SX(xc, CURC); 42 | U2SY(yc, CURC); 43 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 44 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 45 | grx_draw_ellipse_arc(xc, yc, rx, ry, start, end, style, c); 46 | } 47 | -------------------------------------------------------------------------------- /src/user/uellif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uellif.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * Copyright (C) 1997, Michael Goffioul 9 | * [goffioul@emic.ucl.ac.be] 10 | * 11 | * This file is part of the GRX graphics library. 12 | * 13 | * The GRX graphics library is free software; you can redistribute it 14 | * and/or modify it under some conditions; see the "copying.grx" file 15 | * for details. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 20 | */ 21 | 22 | #include 23 | 24 | #include "globals.h" 25 | #include "libgrx.h" 26 | #include "usercord.h" 27 | 28 | /** 29 | * grx_user_draw_filled_ellipse: 30 | * @xc: the X coordinate of the center of the ellipse 31 | * @yc: the Y coordinate of the center of the ellipse 32 | * @rx: the radius in the X direction 33 | * @ry: the radius in the Y direction 34 | * @c: the color 35 | * 36 | * Draws a filled ellipse on the current context using the specified color. 37 | * 38 | * The ellipse can only draw ellipses with its major axis parallel with either 39 | * the X or Y coordinate axis 40 | */ 41 | void grx_user_draw_filled_ellipse(int xc, int yc, int rx, int ry, GrxColor c) 42 | { 43 | U2SX(xc, CURC); 44 | U2SY(yc, CURC); 45 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 46 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 47 | grx_draw_filled_ellipse(xc, yc, rx, ry, c); 48 | } 49 | -------------------------------------------------------------------------------- /src/user/uellifa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uellifa.c 3 | * 4 | * Copyright (C), Michael Goffioul 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "usercord.h" 22 | 23 | /** 24 | * grx_user_draw_filled_ellipse_arc: 25 | * @xc: the X coordinate of the center of the arc 26 | * @yc: the Y coordinate of the center of the arc 27 | * @rx: the radius in the X direction 28 | * @ry: the radius in the Y direction 29 | * @start: the starting angle in 1/10ths of degrees 30 | * @end: the ending angle in 1/10ths of degrees 31 | * @style: the arc style 32 | * @c: the color 33 | * 34 | * Draws a filled arc on the current context centered at the specified 35 | * coordinates from the starting angle to the ending angle with the specified 36 | * radii, arc style and color. 37 | */ 38 | void grx_user_draw_filled_ellipse_arc( 39 | int xc, int yc, int rx, int ry, int start, int end, GrxArcStyle style, GrxColor c) 40 | { 41 | U2SX(xc, CURC); 42 | U2SY(yc, CURC); 43 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 44 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 45 | grx_draw_filled_ellipse_arc(xc, yc, rx, ry, start, end, style, c); 46 | } 47 | -------------------------------------------------------------------------------- /src/user/ufillbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ufillbox.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_filled_box: 27 | * @x1: the left X coordinate 28 | * @y1: the top Y coordinate 29 | * @x2: the right X coordinate 30 | * @y2: the bottom Y coordinate 31 | * @c: the color 32 | * 33 | * Draws a filled rectangle on the current context using the specified 34 | * coordinates and color. 35 | */ 36 | void grx_user_draw_filled_box(int x1, int y1, int x2, int y2, GrxColor c) 37 | { 38 | U2SX(x1, CURC); 39 | U2SY(y1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y2, CURC); 42 | grx_draw_filled_box(x1, y1, x2, y2, c); 43 | } 44 | -------------------------------------------------------------------------------- /src/user/uflood.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uflood.c ---- fill an arbitrary area in user coordinates 3 | * 4 | * Copyright (c) 1997 Hartmut Schirmer 5 | * [e-mail: hsc@techfak.uni-kiel.de] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_flood_fill: 26 | * @x: the starting X coordinate 27 | * @y: the starting Y coordinate 28 | * @border: the color of the border that contains the fill 29 | * @c: the color of the fill 30 | * 31 | * Flood-fills the area of the current context bounded by the color @border 32 | * using @x, @y as the starting point. 33 | */ 34 | void grx_user_flood_fill(int x, int y, GrxColor border, GrxColor c) 35 | { 36 | U2SX(x, CURC); 37 | U2SY(y, CURC); 38 | grx_flood_fill(x, y, border, c); 39 | } 40 | -------------------------------------------------------------------------------- /src/user/ufpolyg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ufpolyg.c 3 | * 4 | * Copyright (C), Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_filled_polygon: 26 | * @n_points: the number of points in @points 27 | * @points: (array length=n_points): an array of #GrxPoint 28 | * @c: the color 29 | * 30 | * Draw a filled polygon on the current context that connects each point in 31 | * the @points array using the specified color. 32 | * 33 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 34 | * It will be automatically appended to the list if it is missing. 35 | */ 36 | void grx_user_draw_filled_polygon(gint numpts, const GrxPoint *points, GrxColor c) 37 | { 38 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 39 | 40 | for (gint pt = 0; pt < numpts; pt++) { 41 | tmp[pt] = points[pt]; 42 | U2SX(tmp[pt].x, CURC); 43 | U2SY(tmp[pt].y, CURC); 44 | } 45 | 46 | grx_draw_filled_polygon(numpts, tmp, c); 47 | } 48 | -------------------------------------------------------------------------------- /src/user/uframbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uframbox.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_framed_box: 27 | * @x1: the left X coordinate 28 | * @y1: the top Y coordinate 29 | * @x2: the right X coordinate 30 | * @y2: the bottom Y coordinate 31 | * @width: the width of the frame 32 | * @c: the colors 33 | * 34 | * Draws a framed rectangle on the current context using the specified 35 | * coordinates and colors. The coordinates specify the interior box. The border 36 | * extends outside of the box using the given @width. 37 | */ 38 | void grx_user_draw_framed_box( 39 | int x1, int y1, int x2, int y2, int wdt, const GrxFramedBoxColors *c) 40 | { 41 | int w1, w2; 42 | 43 | U2SX(x1, CURC); 44 | U2SY(y1, CURC); 45 | U2SX(x2, CURC); 46 | U2SY(y2, CURC); 47 | SCALE(w1, wdt, CURC->x_max, CURC->user_width); 48 | SCALE(w2, wdt, CURC->y_max, CURC->user_height); 49 | wdt = (ABS(w1) + ABS(w2)) >> 1; 50 | if (wdt == 0) 51 | grx_draw_filled_box(x1, y1, x2, y2, c->background); 52 | else 53 | grx_draw_framed_box(x1, y1, x2, y2, wdt, c); 54 | } 55 | -------------------------------------------------------------------------------- /src/user/ugetwin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ugetwin.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | 22 | /** 23 | * grx_user_get_window: 24 | * @x1: (out): the left X coordinate 25 | * @y1: (out): the top Y coordinate 26 | * @x2: (out): the right X coordinate 27 | * @y2: (out): the bottom Y coordinate 28 | * 29 | * Gets the user window of the current context. 30 | */ 31 | void grx_user_get_window(int *x1, int *y1, int *x2, int *y2) 32 | { 33 | *x1 = CURC->user_x_base; 34 | *y1 = CURC->user_y_base; 35 | *x2 = CURC->user_x_base + CURC->user_width; 36 | *y2 = CURC->user_y_base + CURC->user_height; 37 | } 38 | -------------------------------------------------------------------------------- /src/user/uhline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uhline.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_hline: 27 | * @x1: starting X coordinate 28 | * @x2: ending X coordinate 29 | * @y: Y coordinate 30 | * @c: the color 31 | * 32 | * Draws a horizontal line on the current context from the starting coordinates 33 | * to the ending coordinates using the specified color. 34 | * 35 | * This is more efficient that using grx_user_draw_line(). 36 | */ 37 | void grx_user_draw_hline(int x1, int x2, int y, GrxColor c) 38 | { 39 | U2SX(x1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y, CURC); 42 | grx_draw_hline(x1, x2, y, c); 43 | } 44 | -------------------------------------------------------------------------------- /src/user/uline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uline.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_line: 27 | * @x1: starting X coordinate 28 | * @y1: starting Y coordinate 29 | * @x2: ending X coordinate 30 | * @y2: ending Y coordinate 31 | * @c: the color 32 | * 33 | * Draws a line on the current context from the starting coordinates to the 34 | * ending coordinates using the specified color. 35 | * 36 | * For horizontal and vertical lines, see grx_user_draw_hline() and 37 | * grx_user_draw_vline(). 38 | */ 39 | void grx_user_draw_line(int x1, int y1, int x2, int y2, GrxColor c) 40 | { 41 | U2SX(x1, CURC); 42 | U2SY(y1, CURC); 43 | U2SX(x2, CURC); 44 | U2SY(y2, CURC); 45 | grx_draw_line(x1, y1, x2, y2, c); 46 | } 47 | -------------------------------------------------------------------------------- /src/user/upbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upbox.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_box_with_pixmap: 26 | * @x1: the left X coordinate 27 | * @y1: the top Y coordinate 28 | * @x2: the right X coordinate 29 | * @y2: the bottom Y coordinate 30 | * @o: the line options 31 | * @p: the pixmap 32 | * 33 | * Draws a rectangle on the current context using the specified coordinates 34 | * and line options and pixmap. 35 | */ 36 | void grx_user_draw_box_with_pixmap( 37 | int x1, int y1, int x2, int y2, const GrxLineOptions *o, GrxPixmap *p) 38 | { 39 | U2SX(x1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y1, CURC); 42 | U2SY(y2, CURC); 43 | grx_draw_box_with_pixmap(x1, y1, x2, y2, o, p); 44 | } 45 | -------------------------------------------------------------------------------- /src/user/upcirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upcirc.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle 18 | * looks like a circle on the screen 19 | */ 20 | 21 | #include 22 | 23 | #include "globals.h" 24 | #include "libgrx.h" 25 | #include "usercord.h" 26 | 27 | /** 28 | * grx_user_draw_circle_with_pixmap: 29 | * @xc: the X coordinate of the center of the circle 30 | * @yc: the Y coordinate of the center of the circle 31 | * @r: the radius of the circle 32 | * @o: the line options 33 | * @p: the pixmap 34 | * 35 | * Draws a circle on the current context centered at the specified coordinates 36 | * with the specified radius and line options and pixmap. 37 | */ 38 | void grx_user_draw_circle_with_pixmap( 39 | int xc, int yc, int r, const GrxLineOptions *o, GrxPixmap *p) 40 | { 41 | #ifdef USR_KEEP_SHAPE 42 | U2SX(xc, CURC); 43 | U2SY(yc, CURC); 44 | SCALE(r, r, CURC->x_max, CURC->user_width); 45 | grx_draw_circle_with_pixmap(xc, yc, r, o, p); 46 | #else 47 | grx_user_draw_ellipse_with_pixmap(xc, yc, r, r, o, p); 48 | #endif /* USR_KEEP_SHAPE */ 49 | } 50 | -------------------------------------------------------------------------------- /src/user/upelli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upelli.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_ellipse_with_pixmap: 27 | * @xc: the X coordinate of the center of the ellipse 28 | * @yc: the Y coordinate of the center of the ellipse 29 | * @rx: the radius in the X direction 30 | * @ry: the radius in the Y direction 31 | * @o: the line options 32 | * @p: the pixmap 33 | * 34 | * Draws an ellipse on the current context using the specified line options and 35 | * pattern. 36 | * 37 | * The ellipse can only draw ellipses with its major axis parallel with either 38 | * the X or Y coordinate axis 39 | */ 40 | void grx_user_draw_ellipse_with_pixmap( 41 | int xc, int yc, int rx, int ry, const GrxLineOptions *o, GrxPixmap *p) 42 | { 43 | U2SX(xc, CURC); 44 | U2SY(yc, CURC); 45 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 46 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 47 | grx_draw_ellipse_with_pixmap(xc, yc, rx, ry, o, p); 48 | } 49 | -------------------------------------------------------------------------------- /src/user/upellia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upellia.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_ellipse_arc_with_pixmap: 27 | * @xc: the X coordinate of the center of the arc 28 | * @yc: the Y coordinate of the center of the arc 29 | * @rx: the radius in the X direction 30 | * @ry: the radius in the Y direction 31 | * @start: the starting angle in 1/10ths of degrees 32 | * @end: the ending angle in 1/10ths of degrees 33 | * @style: the arc style 34 | * @o: the line options 35 | * @p: the pixmap 36 | * 37 | * Draws an arc on the current context centered at the specified coordinates 38 | * from the starting angle to the ending angle with the specified radii, 39 | * arc style and line options and pixmap. 40 | */ 41 | void grx_user_draw_ellipse_arc_with_pixmap(int xc, int yc, int rx, int ry, int start, 42 | int end, GrxArcStyle style, const GrxLineOptions *o, GrxPixmap *p) 43 | { 44 | U2SX(xc, CURC); 45 | U2SY(yc, CURC); 46 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 47 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 48 | grx_draw_ellipse_arc_with_pixmap(xc, yc, rx, ry, start, end, style, o, p); 49 | } 50 | -------------------------------------------------------------------------------- /src/user/upfbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfbox.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_filled_box_with_pixmap: 26 | * @x1: the left X coordinate 27 | * @y1: the top Y coordinate 28 | * @x2: the right X coordinate 29 | * @y2: the bottom Y coordinate 30 | * @p: the pixmap 31 | * 32 | * Draws a filled rectangle on the current context using the specified 33 | * coordinates and pixmap. 34 | */ 35 | void grx_user_draw_filled_box_with_pixmap(int x1, int y1, int x2, int y2, GrxPixmap *p) 36 | { 37 | U2SX(x1, CURC); 38 | U2SX(x2, CURC); 39 | U2SY(y1, CURC); 40 | U2SY(y2, CURC); 41 | grx_draw_filled_box_with_pixmap(x1, y1, x2, y2, p); 42 | } 43 | -------------------------------------------------------------------------------- /src/user/upfcirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfcirc.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | * 17 | * Note : compiling the library with -DUSR_KEEP_SHAPE makes a circle 18 | * looks like a circle on the screen 19 | */ 20 | 21 | #include 22 | 23 | #include "libgrx.h" 24 | #include "usercord.h" 25 | 26 | /** 27 | * grx_user_draw_filled_circle_with_pixmap: 28 | * @xc: the X coordinate of the center of the circle 29 | * @yc: the Y coordinate of the center of the circle 30 | * @r: the radius of the circle 31 | * @p: the pixmap 32 | * 33 | * Draws a filled circle on the current context centered at the specified 34 | * coordinates with the specified radius and pixmap. 35 | */ 36 | void grx_user_draw_filled_circle_with_pixmap(int xc, int yc, int r, GrxPixmap *p) 37 | { 38 | #ifdef USR_KEEP_SHAPE 39 | U2SX(xc, CURC); 40 | U2SY(yc, CURC); 41 | SCALE(r, r, CURC->x_max, CURC->user_width); 42 | grx_draw_filled_circle_with_pixmap(xc, yc, r, p); 43 | #else 44 | grx_user_draw_filled_ellipse_with_pixmap(xc, yc, r, r, p); 45 | #endif /* USR_KEEP_SHAPE */ 46 | } 47 | -------------------------------------------------------------------------------- /src/user/upfelli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfelli.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | */ 7 | 8 | #include 9 | 10 | #include "globals.h" 11 | #include "libgrx.h" 12 | #include "usercord.h" 13 | 14 | /** 15 | * grx_user_draw_filled_ellipse_with_pixmap: 16 | * @xc: the X coordinate of the center of the ellipse 17 | * @yc: the Y coordinate of the center of the ellipse 18 | * @rx: the radius in the X direction 19 | * @ry: the radius in the Y direction 20 | * @p: the pixmap 21 | * 22 | * Draws a filled ellipse on the current context using the specified pixmap. 23 | * 24 | * The ellipse can only draw ellipses with its major axis parallel with either 25 | * the X or Y coordinate axis 26 | */ 27 | void grx_user_draw_filled_ellipse_with_pixmap( 28 | int xc, int yc, int rx, int ry, GrxPixmap *p) 29 | { 30 | U2SX(xc, CURC); 31 | U2SY(yc, CURC); 32 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 33 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 34 | grx_draw_filled_ellipse_with_pixmap(xc, yc, rx, ry, p); 35 | } 36 | -------------------------------------------------------------------------------- /src/user/upfellia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfellia.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_filled_ellipse_arc_with_pixmap: 27 | * @xc: the X coordinate of the center of the arc 28 | * @yc: the Y coordinate of the center of the arc 29 | * @rx: the radius in the X direction 30 | * @ry: the radius in the Y direction 31 | * @start: the starting angle in 1/10ths of degrees 32 | * @end: the ending angle in 1/10ths of degrees 33 | * @style: the arc style 34 | * @p: the pixmap 35 | * 36 | * Draws a filled arc on the current context centered at the specified 37 | * coordinates from the starting angle to the ending angle with the specified 38 | * radii, arc style and pixmap. 39 | */ 40 | void grx_user_draw_filled_ellipse_arc_with_pixmap( 41 | int xc, int yc, int rx, int ry, int start, int end, GrxArcStyle style, GrxPixmap *p) 42 | { 43 | U2SX(xc, CURC); 44 | U2SY(yc, CURC); 45 | SCALE(rx, rx, CURC->x_max, CURC->user_width); 46 | SCALE(ry, ry, CURC->y_max, CURC->user_height); 47 | grx_draw_filled_ellipse_arc_with_pixmap(xc, yc, rx, ry, start, end, style, p); 48 | } 49 | -------------------------------------------------------------------------------- /src/user/upfflood.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfflood.c ---- pattern fill an arbitrary area in user coordinates 3 | * 4 | * Copyright (c) 1997 Hartmut Schirmer 5 | * [e-mail: hsc@techfak.uni-kiel.de] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_flood_fill_with_pixmap: 26 | * @x: the starting X coordinate 27 | * @y: the starting Y coordinate 28 | * @border: the color of the border that contains the fill 29 | * @p: the pixmap of the fill 30 | * 31 | * Flood-fills the area of the current context bounded by the color @border 32 | * using @x, @y as the starting point. 33 | */ 34 | void grx_user_flood_fill_with_pixmap(int x, int y, GrxColor border, GrxPixmap *p) 35 | { 36 | U2SX(x, CURC); 37 | U2SY(y, CURC); 38 | grx_flood_fill_with_pixmap(x, y, border, p); 39 | } 40 | -------------------------------------------------------------------------------- /src/user/upfline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfline.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_filled_line_with_pixmap: 26 | * @x1: starting X coordinate 27 | * @y1: starting Y coordinate 28 | * @x2: ending X coordinate 29 | * @y2: ending Y coordinate 30 | * @p: the pixmap 31 | * 32 | * Draws a line on the current context from the starting coordinates to the 33 | * ending coordinates using the specified pixmap. 34 | * 35 | * For horizontal and vertical lines, see grx_draw_hline() and grx_draw_vline(). 36 | */ 37 | void grx_user_draw_filled_line_with_pixmap(int x1, int y1, int x2, int y2, GrxPixmap *p) 38 | { 39 | U2SX(x1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y1, CURC); 42 | U2SY(y2, CURC); 43 | grx_draw_filled_line_with_pixmap(x1, y1, x2, y2, p); 44 | } 45 | -------------------------------------------------------------------------------- /src/user/upfplot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfplot.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_filled_pixel_with_pixmap: 26 | * @x: the X coordinate 27 | * @y: the Y coordinate 28 | * @p: the pixmap 29 | * 30 | * Draw a single pixel on the current context at the specified coordinates. 31 | */ 32 | void grx_user_draw_filled_pixel_with_pixmap(int x, int y, GrxPixmap *p) 33 | { 34 | U2SX(x, CURC); 35 | U2SY(y, CURC); 36 | grx_draw_filled_pixel_with_pixmap(x, y, p); 37 | } 38 | -------------------------------------------------------------------------------- /src/user/upfpolyg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upfpolyg.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_filled_polygon_with_pixmap: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @p: the pixmap 30 | * 31 | * Draw a filled polygon on the current context that connects each point in 32 | * the @points array using the specified pixmap. 33 | * 34 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 35 | * It will be automatically appended to the list if it is missing. 36 | */ 37 | void grx_user_draw_filled_polygon_with_pixmap( 38 | gint numpts, const GrxPoint *points, GrxPixmap *p) 39 | { 40 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 41 | 42 | for (gint pt = 0; pt < numpts; pt++) { 43 | tmp[pt] = points[pt]; 44 | U2SX(tmp[pt].x, CURC); 45 | U2SY(tmp[pt].y, CURC); 46 | } 47 | 48 | grx_draw_filled_polygon_with_pixmap(numpts, tmp, p); 49 | } 50 | -------------------------------------------------------------------------------- /src/user/upixel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upixel.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_get_pixel_at: 27 | * @x: the X coordinate 28 | * @y: the Y coordinate 29 | * 30 | * Gets the color value of the pixel in the current context at the specified 31 | * coordinates. 32 | */ 33 | GrxColor grx_user_get_pixel_at(int x, int y) 34 | { 35 | U2SX(x, CURC); 36 | U2SY(y, CURC); 37 | return grx_get_pixel_at(x, y); 38 | } 39 | -------------------------------------------------------------------------------- /src/user/upixelc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upixelc.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_context_get_pixel_at_user: 26 | * @context: the context 27 | * @x: the X coordinate 28 | * @y: the Y coordinate 29 | * 30 | * Gets the color value of the pixel in the context at the specified 31 | * coordinates. 32 | * 33 | * Also see grx_get_pixel_at() for operating on the current context. 34 | */ 35 | GrxColor grx_context_get_pixel_at_user(GrxContext *c, int x, int y) 36 | { 37 | U2SX(x, c); 38 | U2SY(y, c); 39 | return grx_context_get_pixel_at(c, x, y); 40 | } 41 | -------------------------------------------------------------------------------- /src/user/upline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upline.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_line_with_pixmap: 26 | * @x1: starting X coordinate 27 | * @y1: starting Y coordinate 28 | * @x2: ending X coordinate 29 | * @y2: ending Y coordinate 30 | * @o: the line options 31 | * @p: the pixmap 32 | * 33 | * Draws a line on the current context from the starting coordinates to the 34 | * ending coordinates using the specified line options and pixmap. 35 | */ 36 | void grx_user_draw_line_with_pixmap( 37 | int x1, int y1, int x2, int y2, const GrxLineOptions *o, GrxPixmap *p) 38 | { 39 | U2SX(x1, CURC); 40 | U2SX(x2, CURC); 41 | U2SY(y1, CURC); 42 | U2SY(y2, CURC); 43 | grx_draw_line_with_pixmap(x1, y1, x2, y2, o, p); 44 | } 45 | -------------------------------------------------------------------------------- /src/user/uplot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uplot.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_pixel: 27 | * @x: the X coordinate 28 | * @y: the Y coordinate 29 | * @c: the color (can include #GrxColorMode) 30 | * 31 | * Draw a single pixel on the current context at the specified user coordinates. 32 | */ 33 | void grx_user_draw_pixel(int x, int y, GrxColor c) 34 | { 35 | U2SX(x, CURC); 36 | U2SY(y, CURC); 37 | grx_draw_pixel(x, y, c); 38 | } 39 | -------------------------------------------------------------------------------- /src/user/upolygon.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upolygon.c 3 | * 4 | * Copyright (C), Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_polygon: 26 | * @n_points: the number of points in @points 27 | * @points: (array length=n_points): an array of #GrxPoint 28 | * @c: the color 29 | * 30 | * Draw a closed polygon on the current context that connects each point in 31 | * the @points array using the specified color. 32 | * 33 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 34 | * It will be automatically appended to the list if it is missing. 35 | */ 36 | void grx_user_draw_polygon(gint numpts, const GrxPoint *points, GrxColor c) 37 | { 38 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 39 | 40 | for (gint pt = 0; pt < numpts; pt++) { 41 | tmp[pt] = points[pt]; 42 | U2SX(tmp[pt].x, CURC); 43 | U2SY(tmp[pt].y, CURC); 44 | } 45 | 46 | grx_draw_polygon(numpts, tmp, c); 47 | } 48 | -------------------------------------------------------------------------------- /src/user/upolylin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * upolylin.c 3 | * 4 | * Copyright (C), Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "globals.h" 21 | #include "libgrx.h" 22 | #include "usercord.h" 23 | 24 | /** 25 | * grx_user_draw_polyline: 26 | * @n_points: the number of points in @points 27 | * @points: (array length=n_points): an array of #GrxPoint 28 | * @c: the color 29 | * 30 | * Draw a multi-segment line on the current context that connects each point in 31 | * the @points array using the specified color. 32 | */ 33 | void grx_user_draw_polyline(gint numpts, const GrxPoint *points, GrxColor c) 34 | { 35 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 36 | 37 | for (gint pt = 0; pt < numpts; pt++) { 38 | tmp[pt] = points[pt]; 39 | U2SX(tmp[pt].x, CURC); 40 | U2SY(tmp[pt].y, CURC); 41 | } 42 | 43 | grx_draw_polyline(numpts, tmp, c); 44 | } 45 | -------------------------------------------------------------------------------- /src/user/uppolyg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uppolyg.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_polygon_with_pixmap: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @o: the line options 30 | * @p: the pixmap 31 | * 32 | * Draw a closed polygon on the current context that connects each point in 33 | * the @points array using the specified line options and pixmap. 34 | * 35 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 36 | * It will be automatically appended to the list if it is missing. 37 | */ 38 | void grx_user_draw_polygon_with_pixmap( 39 | gint numpts, const GrxPoint *points, const GrxLineOptions *o, GrxPixmap *p) 40 | { 41 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 42 | 43 | for (gint pt = 0; pt < numpts; pt++) { 44 | tmp[pt] = points[pt]; 45 | U2SX(tmp[pt].x, CURC); 46 | U2SY(tmp[pt].y, CURC); 47 | } 48 | 49 | grx_draw_polygon_with_pixmap(numpts, tmp, o, p); 50 | } 51 | -------------------------------------------------------------------------------- /src/user/uppolyl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uppolyl.c 3 | * 4 | * Copyright (C) 1997, Michael Goffioul 5 | * [goffioul@emic.ucl.ac.be] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_polyline_with_pixmap: 27 | * @n_points: the number of points in @points 28 | * @points: (array length=n_points): an array of #GrxPoint 29 | * @o: the line options 30 | * @p: the pixmap 31 | * 32 | * Draw a multi-segment line on the current context that connects each point in 33 | * the @points array using the specified line options and pattern. 34 | */ 35 | void grx_user_draw_polyline_with_pixmap( 36 | gint numpts, const GrxPoint *points, const GrxLineOptions *o, GrxPixmap *p) 37 | { 38 | GrxPoint *tmp = g_newa(GrxPoint, numpts); 39 | 40 | for (gint pt = 0; pt < numpts; pt++) { 41 | tmp[pt] = points[pt]; 42 | U2SX(tmp[pt].x, CURC); 43 | U2SY(tmp[pt].y, CURC); 44 | } 45 | 46 | grx_draw_polyline_with_pixmap(numpts, tmp, o, p); 47 | } 48 | -------------------------------------------------------------------------------- /src/user/usercord.c: -------------------------------------------------------------------------------- 1 | /* 2 | * usercord.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include "globals.h" 20 | #include "libgrx.h" 21 | #include "usercord.h" 22 | 23 | /** 24 | * grx_user_convert_user_to_screen: 25 | * @x: (inout): the X coordinate 26 | * @y: (inout): the Y coordinate 27 | * 28 | * Converts @x and @y from coordinates in the user window to coordinates in the 29 | * current context. 30 | */ 31 | void grx_user_convert_user_to_screen(int *x, int *y) 32 | { 33 | U2SX(*x, CURC); 34 | U2SY(*y, CURC); 35 | } 36 | 37 | /** 38 | * grx_user_convert_screen_to_user: 39 | * @x: (inout): the X coordinate 40 | * @y: (inout): the Y coordinate 41 | * 42 | * Converts @x and @y from coordinates in the current context to coordinates in 43 | * the user window. 44 | */ 45 | void grx_user_convert_screen_to_user(int *x, int *y) 46 | { 47 | S2UX(*x, CURC); 48 | S2UY(*y, CURC); 49 | } 50 | -------------------------------------------------------------------------------- /src/user/utextxy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * utextxy.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | void grx_user_draw_text(const char *text, int x, int y, GrxTextOptions *options) 26 | { 27 | U2SX(x, CURC); 28 | U2SY(y, CURC); 29 | grx_draw_text(text, x, y, options); 30 | } 31 | -------------------------------------------------------------------------------- /src/user/uvline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uvline.c 3 | * 4 | * Copyright (C) 1992, Csaba Biegl 5 | * 820 Stirrup Dr, Nashville, TN, 37221 6 | * csaba@vuse.vanderbilt.edu 7 | * 8 | * This file is part of the GRX graphics library. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include 20 | 21 | #include "globals.h" 22 | #include "libgrx.h" 23 | #include "usercord.h" 24 | 25 | /** 26 | * grx_user_draw_vline: 27 | * @x: X coordinate 28 | * @y1: starting Y coordinate 29 | * @y2: ending Y coordinate 30 | * @c: the color 31 | * 32 | * Draws a vertical line on the current context from the starting coordinates 33 | * to the ending coordinates using the specified color. 34 | * 35 | * This is more efficient that using grx_user_draw_line(). 36 | */ 37 | void grx_user_draw_vline(int x, int y1, int y2, GrxColor c) 38 | { 39 | U2SX(x, CURC); 40 | U2SY(y1, CURC); 41 | U2SY(y2, CURC); 42 | grx_draw_vline(x, y1, y2, c); 43 | } 44 | -------------------------------------------------------------------------------- /src/utils/dbgprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dbgprint.c ---- GRX debug support 3 | * 4 | * Copyright (c) 1998 Hartmut Schirmer 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #ifdef DEBUG 18 | #include 19 | #include 20 | #include 21 | 22 | #include "grxdebug.h" 23 | 24 | #ifndef DBG_LOGFILE 25 | #define DBG_LOGFILE "grxdebug.log" 26 | #endif 27 | 28 | char *_GR_debug_file; 29 | int _GR_debug_line; 30 | #ifdef __GNUC__ 31 | const char *_GR_debug_function; 32 | #endif 33 | int _GR_debug_flags = DEBUG - 0; 34 | 35 | void _GR_debug_printf(char *fmt, ...) 36 | { 37 | FILE *dfp = NULL; 38 | va_list ap; 39 | dfp = fopen(DBG_LOGFILE, "at"); 40 | if (!dfp) 41 | return; 42 | #ifdef __GNUC__ 43 | fprintf(dfp, "%s|%s|%d: ", _GR_debug_file, _GR_debug_function, _GR_debug_line); 44 | #else 45 | fprintf(dfp, "%s/%d: ", _GR_debug_file, _GR_debug_line); 46 | #endif 47 | va_start(ap, fmt); 48 | vfprintf(dfp, fmt, ap); 49 | va_end(ap); 50 | fclose(dfp); 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/utils/error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * error.c 3 | * 4 | * Copyright (c) 2016 David Lechner 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | /** 20 | * grx_error_quark: 21 | * 22 | * Gets the GRX Error Quark. 23 | * 24 | * Returns: a #GQuark. 25 | */ 26 | G_DEFINE_QUARK(grx - error - quark, grx_error) 27 | -------------------------------------------------------------------------------- /src/utils/scanline_buf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * scanline_buf.c ---- scan line buffer 3 | * 4 | * Copyright (c) 2020 David Lechner 5 | * 6 | * This file is part of the GRX graphics library. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | static GrxColor *grx_scanline_buffer; 22 | 23 | GrxColor *_grx_get_scanline_buf(gint n_colors) 24 | { 25 | return g_realloc_n(grx_scanline_buffer, n_colors + 1, sizeof(GrxColor)); 26 | } 27 | -------------------------------------------------------------------------------- /src/wideline/ccirc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ccirc.c ---- draw dashed and/or wide circles 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_circle_with_options: 25 | * @xc: the X coordinate of the center of the circle 26 | * @yc: the Y coordinate of the center of the circle 27 | * @r: the radius of the circle 28 | * @o: the options 29 | * 30 | * Draws a circle on the current context centered at the specified coordinates 31 | * with the specified radius and options. 32 | */ 33 | void grx_draw_circle_with_options(int xc, int yc, int r, const GrxLineOptions *o) 34 | { 35 | grx_draw_ellipse_with_options(xc, yc, r, r, o); 36 | } 37 | -------------------------------------------------------------------------------- /src/wideline/ccirca.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ccirca.c ---- draw dashed and/or wide circle arcs 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "libgrx.h" 22 | #include "shapes.h" 23 | 24 | /** 25 | * grx_draw_circle_arc_with_options: 26 | * @xc: the X coordinate of the center of the arc 27 | * @yc: the Y coordinate of the center of the arc 28 | * @r: the radius of the arc 29 | * @start: the starting angle in 1/10ths of degrees 30 | * @end: the ending angle in 1/10ths of degrees 31 | * @style: the arc style 32 | * @o: the options 33 | * 34 | * Draws an arc on the current context centered at the specified coordinates 35 | * from the starting angle to the ending angle with the specified radius, 36 | * arc style and options. 37 | */ 38 | void grx_draw_circle_arc_with_options(int xc, int yc, int r, int start, int end, 39 | GrxArcStyle style, const GrxLineOptions *o) 40 | { 41 | grx_draw_ellipse_arc_with_options(xc, yc, r, r, start, end, style, o); 42 | } 43 | -------------------------------------------------------------------------------- /src/wideline/celli.c: -------------------------------------------------------------------------------- 1 | /* 2 | * celli.c ---- draw dashed and/or wide ellipses 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "libgrx.h" 22 | #include "shapes.h" 23 | 24 | /** 25 | * grx_draw_ellipse_with_options: 26 | * @xc: the X coordinate of the center of the ellipse 27 | * @yc: the Y coordinate of the center of the ellipse 28 | * @rx: the radius in the X direction 29 | * @ry: the radius in the Y direction 30 | * @o: the options 31 | * 32 | * Draws an ellipse on the current context using the specified options. 33 | * 34 | * The ellipse can only draw ellipses with its major axis parallel with either 35 | * the X or Y coordinate axis 36 | */ 37 | void grx_draw_ellipse_with_options( 38 | int xc, int yc, int rx, int ry, const GrxLineOptions *o) 39 | { 40 | GArray *points; 41 | GrFillArg fval; 42 | 43 | points = grx_generate_ellipse(xc, yc, rx, ry); 44 | fval.color = o->color; 45 | _GrDrawCustomPolygon( 46 | points->len, (GrxPoint *)points->data, o, &_GrSolidFiller, fval, TRUE, TRUE); 47 | g_array_unref(points); 48 | } 49 | -------------------------------------------------------------------------------- /src/wideline/custbox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * custbox.c ---- wide and/or dashed box outline 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "libgrx.h" 22 | #include "shapes.h" 23 | 24 | /** 25 | * grx_draw_box_with_options: 26 | * @x1: the left X coordinate 27 | * @y1: the top Y coordinate 28 | * @x2: the right X coordinate 29 | * @y2: the bottom Y coordinate 30 | * @o: the options 31 | * 32 | * Draws a rectangle on the current context using the specified coordinates 33 | * and options. 34 | */ 35 | void grx_draw_box_with_options(int x1, int y1, int x2, int y2, const GrxLineOptions *o) 36 | { 37 | GrFillArg fval; 38 | GrxPoint pt[4]; 39 | pt[0].x = x1; 40 | pt[0].y = y1; 41 | pt[1].x = x2; 42 | pt[1].y = y1; 43 | pt[2].x = x2; 44 | pt[2].y = y2; 45 | pt[3].x = x1; 46 | pt[3].y = y2; 47 | fval.color = o->color; 48 | _GrDrawCustomPolygon(4, pt, o, &_GrSolidFiller, fval, TRUE, FALSE); 49 | } 50 | -------------------------------------------------------------------------------- /src/wideline/custline.c: -------------------------------------------------------------------------------- 1 | /* 2 | * custline.c ---- wide and/or dashed line 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include "libgrx.h" 22 | #include "shapes.h" 23 | 24 | /** 25 | * grx_draw_line_with_options: 26 | * @x1: starting X coordinate 27 | * @y1: starting Y coordinate 28 | * @x2: ending X coordinate 29 | * @y2: ending Y coordinate 30 | * @o: the options 31 | * 32 | * Draws a line on the current context from the starting coordinates to the 33 | * ending coordinates using the specified options. 34 | */ 35 | void grx_draw_line_with_options(int x1, int y1, int x2, int y2, const GrxLineOptions *o) 36 | { 37 | GrFillArg fval; 38 | GrxPoint pt[2]; 39 | pt[0].x = x1; 40 | pt[0].y = y1; 41 | pt[1].x = x2; 42 | pt[1].y = y2; 43 | fval.color = o->color; 44 | _GrDrawCustomPolygon(2, pt, o, &_GrSolidFiller, fval, FALSE, FALSE); 45 | } 46 | -------------------------------------------------------------------------------- /src/wideline/custplne.c: -------------------------------------------------------------------------------- 1 | /* 2 | * custplne.c ---- draw an open ended dashed and/or wide polygon 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_polyline_with_options: 25 | * @n_points: the number of points in @points 26 | * @points: (array length=n_points): an array of #GrxPoint 27 | * @o: the options 28 | * 29 | * Draw a multi-segment line on the current context that connects each point in 30 | * the @points array using the specified options. 31 | */ 32 | void grx_draw_polyline_with_options(int n, const GrxPoint *pt, const GrxLineOptions *o) 33 | { 34 | GrFillArg fval; 35 | fval.color = o->color; 36 | _GrDrawCustomPolygon(n, pt, o, &_GrSolidFiller, fval, FALSE, FALSE); 37 | } 38 | -------------------------------------------------------------------------------- /src/wideline/custpoly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * custpoly.c ---- draw a closed dashed and/or wide polygon 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This file is part of the GRX graphics library. 8 | * 9 | * The GRX graphics library is free software; you can redistribute it 10 | * and/or modify it under some conditions; see the "copying.grx" file 11 | * for details. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 | */ 17 | 18 | #include 19 | 20 | #include "libgrx.h" 21 | #include "shapes.h" 22 | 23 | /** 24 | * grx_draw_polygon_with_options: 25 | * @n_points: the number of points in @points 26 | * @points: (array length=n_points): an array of #GrxPoint 27 | * @o: the options 28 | * 29 | * Draw a closed polygon on the current context that connects each point in 30 | * the @points array using the specified options. 31 | * 32 | * Coordinate arrays can either contain or omit the closing edge of the polygon. 33 | * It will be automatically appended to the list if it is missing. 34 | */ 35 | void grx_draw_polygon_with_options(int n, const GrxPoint *pt, const GrxLineOptions *o) 36 | { 37 | GrFillArg fval; 38 | fval.color = o->color; 39 | _GrDrawCustomPolygon(n, pt, o, &_GrSolidFiller, fval, TRUE, FALSE); 40 | } 41 | -------------------------------------------------------------------------------- /test/arctest.dat: -------------------------------------------------------------------------------- 1 | arc xc=300 yc=200 rx=50 ry=50 start=10 end=40 2 | arc xc=300 yc=200 rx=250 ry=150 start=10 end=200 3 | arc xc=300 yc=200 rx=250 ry=150 start=10 end=2000 4 | arc xc=300 yc=200 rx=250 ry=150 start=1000 end=200 5 | arc xc=300 yc=200 rx=25 ry=15 start=3500 end=800 6 | arc xc=300 yc=200 rx=25 ry=15 start=10 end=100 7 | arc xc=300 yc=200 rx=25 ry=15 start=3500 end=10 8 | arc xc=300 yc=200 rx=25 ry=15 start=0 end=900 9 | 10 | -------------------------------------------------------------------------------- /test/cliptest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cliptest.c ---- test clipping 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This is a test/demo file of the GRX graphics library. 8 | * You can use GRX test/demo files as you want. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include "rand.h" 20 | #include "test.h" 21 | 22 | TESTFUNC(cliptest) 23 | { 24 | long delay; 25 | int x = grx_get_width(); 26 | int y = grx_get_height(); 27 | int ww = (x * 2) / 3; 28 | int wh = (y * 2) / 3; 29 | GrxColor c; 30 | 31 | c = grx_color_get(200, 100, 100); 32 | grx_draw_box( 33 | ww / 4 - 1, wh / 4 - 1, ww / 4 + ww + 1, wh / 4 + wh + 1, GRX_COLOR_WHITE); 34 | grx_set_clip_box(ww / 4, wh / 4, ww / 4 + ww, wh / 4 + wh); 35 | 36 | drawing(0, 0, ww, wh, c, GRX_COLOR_BLACK); 37 | run_main_loop_until_key_press(); 38 | 39 | while (!run_one_main_loop_iteration()) { 40 | grx_draw_filled_box(0, 0, x, y, GRX_COLOR_BLACK); 41 | drawing(-(RND() % (2 * ww)) + ww / 2, -(RND() % (2 * wh)) + wh / 2, 42 | RND() % (3 * ww) + 10, RND() % (3 * wh) + 10, c, GRX_COLOR_NONE); 43 | for (delay = 200000L; delay > 0L; delay--) 44 | ; 45 | } 46 | run_main_loop_until_key_press(); 47 | } 48 | -------------------------------------------------------------------------------- /test/drawing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DRAWING.H ---- a stupid little drawing used all over in test programs 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] See "copying.grx" for details. 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "rand.h" 12 | 13 | void drawing(int xpos, int ypos, int xsize, int ysize, long fg, long bg) 14 | { 15 | #define XP(x) (int)((((long)(x) * (long)xsize) / 100L) + xpos) 16 | #define YP(y) (int)((((long)(y) * (long)ysize) / 100L) + ypos) 17 | int ii; 18 | if (bg != GRX_COLOR_NONE) { 19 | grx_draw_filled_box(xpos, ypos, xpos + xsize - 1, ypos + ysize - 1, bg); 20 | } 21 | grx_draw_line(XP(10), YP(10), XP(40), YP(40), fg); 22 | grx_draw_line(XP(40), YP(10), XP(10), YP(40), fg); 23 | grx_draw_line(XP(35), YP(10), XP(65), YP(40), fg); 24 | grx_draw_line(XP(35), YP(40), XP(65), YP(10), fg); 25 | grx_draw_line(XP(70), YP(10), XP(90), YP(40), fg); 26 | grx_draw_line(XP(70), YP(40), XP(90), YP(10), fg); 27 | for (ii = 0; ii < 5; ii++) { 28 | grx_draw_box( 29 | XP(70 + 2 * ii), YP(10 + 3 * ii), XP(90 - 2 * ii), YP(40 - 3 * ii), fg); 30 | } 31 | grx_draw_filled_box(XP(10), YP(50), XP(60), YP(90), fg); 32 | grx_draw_box(XP(70), YP(50), XP(90), YP(90), fg); 33 | for (ii = 0; ii < 100; ii++) { 34 | grx_draw_pixel(XP((RND() % 20U) + 70), YP((RND() % 40U) + 50), fg); 35 | } 36 | } 37 | 38 | #undef XP 39 | #undef YP 40 | -------------------------------------------------------------------------------- /test/jpeg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/jpeg1.jpg -------------------------------------------------------------------------------- /test/jpeg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/jpeg2.jpg -------------------------------------------------------------------------------- /test/loop.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | typedef struct { 6 | GMainLoop *loop; 7 | GrxKey key; 8 | } EventData; 9 | 10 | static void run_main_loop_until_key_press_handle_event( 11 | GrxEvent *event, gpointer user_data) 12 | { 13 | EventData *data = user_data; 14 | 15 | if (event->type == GRX_EVENT_TYPE_KEY_DOWN) { 16 | data->key = grx_event_get_keysym(event); 17 | g_main_loop_quit(data->loop); 18 | } 19 | } 20 | 21 | GrxKey run_main_loop_until_key_press() 22 | { 23 | EventData data; 24 | 25 | data.loop = g_main_loop_new(NULL, FALSE); 26 | data.key = GRX_KEY_NO_SYMBOL; 27 | 28 | guint id = 29 | grx_event_handler_add(run_main_loop_until_key_press_handle_event, &data, NULL); 30 | g_main_loop_run(data.loop); 31 | g_source_remove(id); 32 | g_main_loop_unref(data.loop); 33 | return data.key; 34 | } 35 | -------------------------------------------------------------------------------- /test/pngcompo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pngcompo.png -------------------------------------------------------------------------------- /test/pngowl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pngowl.png -------------------------------------------------------------------------------- /test/pngred.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pngred.png -------------------------------------------------------------------------------- /test/pnmtest.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pnmtest.pbm -------------------------------------------------------------------------------- /test/pnmtest.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pnmtest.ppm -------------------------------------------------------------------------------- /test/pnmtest2.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ev3dev/grx/956b301eae331ca56bd54fce3dab350ab885c2a7/test/pnmtest2.ppm -------------------------------------------------------------------------------- /test/polytest.dat: -------------------------------------------------------------------------------- 1 | beginc 2 | 300 200 3 | 400 400 4 | 200 400 5 | end 6 | 7 | beginc 8 | 300 200 9 | 400 400 10 | 150 470 11 | 200 400 12 | end 13 | 14 | beginc 15 | 300 200 16 | 400 400 17 | 150 470 18 | 120 330 19 | end 20 | 21 | beginc 22 | 300 200 23 | 400 400 24 | 050 470 25 | 020 330 26 | end 27 | 28 | beginc 29 | 300 -100 30 | 400 400 31 | 050 870 32 | 020 330 33 | end 34 | 35 | beginc 36 | 300 20 37 | 400 100 38 | 050 100 39 | end 40 | 41 | beginc 42 | 400 500 43 | 050 500 44 | 200 560 45 | end 46 | 47 | beginc 48 | 400 500 49 | 250 495 50 | 050 500 51 | 200 560 52 | end 53 | 54 | beginc 55 | 100 500 56 | 400 500 57 | 300 550 58 | end 59 | 60 | beginc 61 | 150 150 62 | 300 150 63 | 250 250 64 | 300 400 65 | 120 444 66 | end 67 | 68 | begin 69 | 250 150 70 | 200 450 71 | 350 250 72 | 150 250 73 | 400 450 74 | end 75 | 76 | beginc 77 | 150 150 78 | 400 200 79 | 400 202 80 | end 81 | 82 | begin 83 | -10 0 84 | 100 -10 85 | 200 200 86 | -10 200 87 | end 88 | -------------------------------------------------------------------------------- /test/rand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rand.h ---- a very simple random number generator 3 | * (from "Numerical recipies") 4 | * 5 | * This is a test/demo file of the GRX graphics library. 6 | * You can use GRX test/demo files as you want. 7 | * 8 | * The GRX graphics library is free software; you can redistribute it 9 | * and/or modify it under some conditions; see the "copying.grx" file 10 | * for details. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | */ 16 | 17 | #ifndef __RAND_H_INCLUDED 18 | #define __RAND_H_INCLUDED 19 | 20 | #define _IA 16807 21 | #define _IM 2147483647L 22 | #define _IQ 127773L 23 | #define _IR 2836 24 | #define _MASK 123459876UL 25 | 26 | static long _idum = 0; 27 | 28 | unsigned long ran0(void) 29 | { 30 | long k; 31 | _idum ^= _MASK; 32 | k = _idum / _IQ; 33 | _idum = _IA * (_idum - k * _IQ) - _IR * k; 34 | if (_idum < 0) 35 | _idum += _IM; 36 | return (unsigned long)_idum; 37 | } 38 | 39 | #define sran0(x) \ 40 | do \ 41 | _idum = (x); \ 42 | while (0) 43 | 44 | #define RND() ran0() 45 | #define SRND(x) sran0(x) 46 | #define RND_MAX (_MASK) 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /test/rgbtest.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rgbtest.c ---- show 256 color RGB palette 3 | * 4 | * Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221 5 | * [e-mail: csaba@vuse.vanderbilt.edu] 6 | * 7 | * This is a test/demo file of the GRX graphics library. 8 | * You can use GRX test/demo files as you want. 9 | * 10 | * The GRX graphics library is free software; you can redistribute it 11 | * and/or modify it under some conditions; see the "copying.grx" file 12 | * for details. 13 | * 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | */ 18 | 19 | #include "test.h" 20 | 21 | TESTFUNC(rgbtest) 22 | { 23 | int x = grx_get_width(); 24 | int y = grx_get_height(); 25 | int ww = (x - 10) / 32; 26 | int wh = (y - 10) / 8; 27 | int ii, jj; 28 | 29 | grx_color_info_set_palette_type_rgb(); 30 | for (ii = 0; ii < 8; ii++) { 31 | for (jj = 0; jj < 32; jj++) { 32 | grx_draw_filled_box(5 + jj * ww, 5 + ii * wh, 5 + jj * ww + ww - 1, 33 | 5 + ii * wh + wh - 1, ii * 32 + jj); 34 | } 35 | } 36 | run_main_loop_until_key_press(); 37 | } 38 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") 3 | 4 | find_package (PkgConfig REQUIRED) 5 | find_package (Valac REQUIRED) 6 | 7 | pkg_check_modules (GRX_CALIBRATE_DEPS REQUIRED 8 | glib-2.0 9 | gobject-2.0 10 | gio-2.0 11 | gudev-1.0 12 | ) 13 | 14 | vala2c (grx-calibrate-touch-vala 15 | SOURCE_FILES 16 | calibrate-touch.vala 17 | PACKAGES 18 | grx-3.0 19 | gio-2.0 20 | gudev-1.0 21 | VAPI_DIRS 22 | ${CMAKE_SOURCE_DIR}/bindings/vala/ 23 | DEPENDS 24 | ${CMAKE_SOURCE_DIR}/bindings/vala/grx-3.0.vapi 25 | ) 26 | 27 | add_executable (grx-calibrate-touch $) 28 | target_compile_options (grx-calibrate-touch PRIVATE "-w") 29 | target_include_directories (grx-calibrate-touch PRIVATE 30 | ${CMAKE_SOURCE_DIR}/include 31 | ${CMAKE_BINARY_DIR}/src/include 32 | ${GRX_CALIBRATE_DEPS_INCLUDE_DIRS} 33 | ) 34 | target_link_libraries (grx-calibrate-touch ${GRX_CALIBRATE_DEPS_LIBRARIES} ${SHARED_LIBRARY_TARGET}) 35 | if (CMAKE_CROSSCOMPILING) 36 | # not sure why we need to do this when cross compiling 37 | target_link_libraries (grx-calibrate-touch "-pthread" "-lresolv") 38 | endif (CMAKE_CROSSCOMPILING) 39 | 40 | install (TARGETS grx-calibrate-touch RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) 41 | 42 | endif (CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") 43 | --------------------------------------------------------------------------------