📄 drawutil.h
字号:
#ifndef DRAWUTIL_H
#define DRAWUTIL_H
#include <crblib/inc.h>
#include <crblib/floatutil.h>
#include <math.h>
#include <drawdriver/DrawDriver.h>
#include <drawdriver/vec2d.h>
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------
typedef struct
{
Vec2d pos;
Vec2d curve; //2nd derivative
}
Driver_BezierPoint;
void DrawUtil_DrawBezierBy2ndD( Driver_Window * pWindow,
const Driver_BezierPoint *p,
const Driver_BezierPoint *q,
uword r,uword g,uword b,
float err);
void DrawUtil_DrawBezierByPoints( Driver_Window * pWindow,
const Vec2d *p0,const Vec2d *p1,
const Vec2d *p2,const Vec2d *p3,
uword r,uword g,uword b,
float err); // uses the 2ndD method
void DrawUtil_DrawBezierCasteljau( Driver_Window * pWindow,
const Vec2d *p0,const Vec2d *p1,
const Vec2d *p2,const Vec2d *p3,
uword r,uword g,uword b,
float err);
//--------------------------------------------------------------
void DrawUtil_Smooth(Driver_Window * Window);
uword DrawUtil_MakePixel(int Mode,uword r,uword g,uword b);
void DrawUtil_HueRGBFast(int H,uword *r,uword *g,uword *b);
void DrawUtil_HueRGBSlow(int H,uword *pr,uword *pg,uword *pb);
void DrawUtil_DrawLine( Driver_Window * W,int x1,int y1,int x2,int y2,uword pixel);
void DrawUtil_DrawLineAA(Driver_Window * W,int x1,int y1,int x2,int y2,uword r,uword g,uword b);
void DrawUtil_DrawLineV(Driver_Window * W,const Vec2d *v1,const Vec2d *v2,uword r,uword g,uword b);
bool DrawUtil_ClipPoint(const Driver_Window * pWindow,float *px,float *py);
// returns true if the point was forced inside the window
bool DrawUtil_ClipSegI(const Driver_Window * W,int *px1,int *py1,int *px2,int *py2);
// returns false if the seg is all outside
bool DrawUtil_ClipSegV(const Driver_Window * W,Vec2d *v1,Vec2d *v2);
//--------------------------------------------------------------
float REGCALL DrawUtil_BasicNoise1d(float f);
float REGCALL DrawUtil_SpectralNoise1d(float x);
float REGCALL DrawUtil_BasicNoise2d( float x,float y);
float REGCALL DrawUtil_SpectralNoise2d(float x,float y);
float REGCALL DrawUtil_BasicNoise3d( float x,float y,float z);
float REGCALL DrawUtil_SpectralNoise3d(float x,float y,float z);
float REGCALL DrawUtil_DeluxeSpectralNoise2d(float x,float y,float noisiness,int levels);
//--------------------------------------------------------------
#define TABLE_SHIFT (10)
#define TABLE_SIZE ((1UL)<<TABLE_SHIFT)
#define TABLE_MASK (TABLE_SIZE - 1)
#define TABLE_SIZE_OVER_TWO_PI ((float)TABLE_SIZE / TWOPI)
/****** Stuff ***/
/*** fast Rand() utilities *****/
extern void DrawUtil_Randomize( void );
extern ulong REGCALL DrawUtil_Rand( ulong max );
#define DrawUtil_RandSigned(max) ( ((int)DrawUtil_Rand((max)+(max)+1)) - (max) )
#define DrawUtil_RandUnitFloat() ( DrawUtil_Rand(3733) * (1.0f/3733.0f))
#define DrawUtil_RandSignedUnitFloat() ( DrawUtil_RandSigned(3733) * (1.0f/3733.0f))
#define DrawUtil_RandFloat(max) ( (max) * DrawUtil_RandUnitFloat())
#define DrawUtil_RandSignedFloat(max) ( (max) * DrawUtil_RandSignedUnitFloat())
/*** fast Sin/Cos with tables *****/
extern float DrawUtil_SinTable[];
extern float DrawUtil_CosTable[];
extern ubyte DrawUtil_ByteSinTable[];
extern ubyte DrawUtil_ByteCosTable[];
#define DrawUtil_Sin(a) ( DrawUtil_SinTable[((int)((a) * TABLE_SIZE_OVER_TWO_PI)) & TABLE_MASK] )
#define DrawUtil_Cos(a) ( DrawUtil_CosTable[((int)((a) * TABLE_SIZE_OVER_TWO_PI)) & TABLE_MASK] )
/** takes integer in (0-255) to (Trig * 127 + 128) **/
#define DrawUtil_ByteSin(a) ( DrawUtil_ByteSinTable[((int)(a)) & 0xFF] )
#define DrawUtil_ByteCos(a) ( DrawUtil_ByteCosTable[((int)(a)) & 0xFF] )
/****** you must call _Init before using DrawUtil functions ***/
/* (DrawDriver does it for you too) */
void DrawUtil_Init(void);
/***********************************************/
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -