immdraw.h
This commit is contained in:
		
							parent
							
								
									c8e6c320f1
								
							
						
					
					
						commit
						cc37e17046
					
				
							
								
								
									
										27
									
								
								src/immdraw.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/immdraw.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include"k3batch.h" | ||||||
|  | #include"k3font.h" | ||||||
|  | #include"k3menu.h" | ||||||
|  | 
 | ||||||
|  | static inline void immdraw_fill_rect(int16_t x, int16_t y, int16_t w, int16_t h, float r, float g, float b, float a, float borderRadius) { | ||||||
|  | 	k3BatchAdd(NULL, (struct k3RectF) {0, 0, 1, 1}, (struct k3RectF) { | ||||||
|  | 		x, y, | ||||||
|  | 		w, h | ||||||
|  | 	}, 0, (vec4) {r, g, b, a}, borderRadius); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void immdraw_font_draw(struct k3Font *font, int16_t x, int16_t y, int16_t w, float sz, size_t len, const char *txt, int alignment, float r, float g, float b, float a) { | ||||||
|  | 	if(alignment != k3M_ALIGN_LEFT) { | ||||||
|  | 		struct k3RectF txtsz; | ||||||
|  | 		k3FontSz(font, sz, txt, &txtsz); | ||||||
|  | 		 | ||||||
|  | 		if(alignment == k3M_ALIGN_CENTER) { | ||||||
|  | 			x += w / 2.0f - txtsz.w / 2.0f; | ||||||
|  | 		} else { | ||||||
|  | 			x += w - txtsz.w; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	k3FontDraw(font, x, y, sz, txt, (vec4) {r, g, b, a}); | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Mid
						Mid