mirror of
				https://codeberg.org/1414codeforge/gear.git
				synced 2025-06-05 22:09:24 +02:00 
			
		
		
		
	[shadowtext] Add text with drop shadow utilities.
This commit is contained in:
		
							
								
								
									
										1
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								init.lua
									
									
									
									
									
								
							| @@ -16,6 +16,7 @@ return { | |||||||
|     algo = require(BASE..'algo'), |     algo = require(BASE..'algo'), | ||||||
|     meta = require(BASE..'meta'), |     meta = require(BASE..'meta'), | ||||||
|     rect = require(BASE..'rect'), |     rect = require(BASE..'rect'), | ||||||
|  |     shadowtext = require(BASE..'shadowtext') | ||||||
|     strings = require(BASE..'strings'), |     strings = require(BASE..'strings'), | ||||||
|     vec = require(BASE..'vec') |     vec = require(BASE..'vec') | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										38
									
								
								shadowtext.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								shadowtext.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | |||||||
|  | --- Draw text with drop shadows. | ||||||
|  | -- | ||||||
|  | -- Drop shadows improve text contrast and readability. | ||||||
|  | -- | ||||||
|  | -- @module gear.shadowtext | ||||||
|  | -- @copyright 2022 The DoubleFourteen Code Forge | ||||||
|  | -- @author Lorenzo Cogotti | ||||||
|  |  | ||||||
|  | local shadowtext = {} | ||||||
|  |  | ||||||
|  |  | ||||||
|  | --- Print text with drop shadow, supports the same arguments as love.graphics.print(text, x, y). | ||||||
|  | function shadowtext.print(text, x, y, ...) | ||||||
|  |     local r,g,b,a = love.graphics.getColor() | ||||||
|  |  | ||||||
|  |     -- Draw drop shadow. | ||||||
|  |     love.graphics.setColor(0, 0, 0, a) | ||||||
|  |     love.graphics.print(text, x+2, y+2, ...) | ||||||
|  |  | ||||||
|  |     -- Draw text. | ||||||
|  |     love.graphics.setColor(r, g, b, a) | ||||||
|  |     love.graphics.print(text, x, y, ...) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | --- Print text with drop shadow, supports the same arguments as love.graphics.printf(text, x, y). | ||||||
|  | function shadowtext.printf(text, x, y, ...) | ||||||
|  |     local r,g,b,a = love.graphics.getColor() | ||||||
|  |  | ||||||
|  |     -- Draw drop shadow. | ||||||
|  |     love.graphics.setColor(0, 0, 0, a) | ||||||
|  |     love.graphics.printf(text, x+2, y+2, ...) | ||||||
|  |  | ||||||
|  |     -- Draw text. | ||||||
|  |     love.graphics.setColor(r, g, b, a) | ||||||
|  |     love.graphics.printf(text, x, y, ...) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | return shadowtext | ||||||
		Reference in New Issue
	
	Block a user