Re: Image Manipulation
No.
I had to find a tutorial on it and it's mad hard for how easy it should be.
http://www.farcrydesign.com/tutorials/G ... orial.html
Moderator: Inside3D Admins
Baker wrote:Sheesh. I'm drawing to draw a circle in Gimp and you'd think that'd be easy.
No.
I had to find a tutorial on it and it's mad hard for how easy it should be.
http://www.farcrydesign.com/tutorials/G ... orial.html

void GL_Draw_Polygon_Inscribed (ScreenRect location, int numSides, unsigned RGBAcolor)
{
float center_x = ScreenRect_CenterXf (location);
float center_y = ScreenRect_CenterYf (location);
float circumradius = ScreenRect_CircumRadiusf (location);
Point2D** pointsList = Polygon_Vertices_ArrayListAlloc (numSides, center_x, center_y, circumradius);
const int numPointsList = ArrayListCount (pointsList);
color4_t RGBAColor4f;
Color_RGBA_To_Color4f (RGBAcolor, RGBAColor4f);
GL_Prepare_Colored_ListVerts (pointsList, numPointsList, GL_TRIANGLE_FAN, RGBAColor4f);
glLineWidth(3);
GL_Prepare_Colored_ListVerts (pointsList, numPointsList, GL_LINE_LOOP, COLOR4F_WHITE);
glLineWidth(1);
glPointSize(8);
GL_Prepare_Colored_ListVerts (pointsList, numPointsList, GL_POINTS, COLOR4F_YELLOW);
glPointSize(6);
GL_Prepare_Colored_ListVerts (pointsList, numPointsList, GL_POINTS, COLOR4F_LITERED);
glPointSize(1);
ArrayListFree (pointsList);
}Point2D** Polygon_Vertices_ArrayListAlloc (int numSides, float center_x, float center_y, float circumradius)
{
Point2D myPolygons[numSides];
const float pieSlice = 360 / numSides;
float degrees = 90;
for (int side = 0; side < numSides; degrees += pieSlice, side ++)
{
float x = -1, y = -1;
Circle_Set_Point_With_Center_Radius_Degrees (&x, &y, 0, 0, circumradius, degrees);
myPolygons[side].x = center_x + x;
myPolygons[side].y = center_y - y; // True geometry flips Y, we need descending Y or whatever
}
ReturnArray_Alloc (Point2D**, myPolygons);
}void pArrayFree (void** arrayList)
{
Memory_free (*arrayList);
Memory_free (arrayList);
}
int pArrayCount (void** arrayList)
{
int count;
for (count = 0; arrayList[count]; count ++ )
;
return count;
}
void** pReturnArray (const void* sourceItems, const size_t numItems, const size_t itemSizeBytes)
{
void* myReturnData = Memory_calloc (numItems + 0, itemSizeBytes, "Array data"); // Malloc return data block
void** myReturnPointer = Memory_calloc (numItems + 1, sizeof(myReturnData), "Array of pointers"); // Malloc return pointer block
myReturnPointer[numItems] = NULL; // NULL terminate list
for (int n = 0; n < numItems; n++)
{
size_t addy = n * itemSizeBytes;
memcpy (&myReturnData[addy], &sourceItems[addy], itemSizeBytes);
myReturnPointer[n] = &myReturnData[addy];
}
return myReturnPointer;
}
// Creation
void** pReturnArray (const void* sourceItems, const size_t numItems, const size_t itemSizeBytes);
// Utilization
int pArrayCount (void** arrayList);
#define ArrayListCount(arrayList) pArrayCount((void**)arrayList) // Warning free
// Destruction
void pArrayFree (void** arrayList);
#define ArrayListFree(arrayList) pArrayFree((void**)arrayList) // Warning free
#define ReturnArray_Alloc(type, array) { \
const int sizeOfItem = sizeof(array[0]); \
const size_t numItems = sizeof(array)/sizeOfItem; \
return (type)pReturnArray(array, numItems, sizeOfItem ); \
}PROPERTY_LIST_START
PROPERTY_FIELD (controltype, controlType ); // Intended location x1, y1 and x2, y2
PROPERTY_FIELD (ScreenRect, origin ); // Intended location x1, y1 and x2, y2
PROPERTY_FIELD (fbool, hidden );
PROPERTY_FIELD (fbool, notFocusable );
PROPERTY_ARRAY (char, 64, name );
PROPERTY_ARRAY (char, 256, text );
PROPERTY_FIELD (size_t, textMaxBytes );
PROPERTY_FIELD (float, value );
PROPERTY_FIELD (float, valueMin );
PROPERTY_FIELD (float, valueMax );
PROPERTY_ARRAY (char, 64, bundleURL );
PROPERTY_FIELD (color4byte, foregroundColor );
PROPERTY_FIELD (color4byte, backgroundColor );
PROPERTY_FIELD (color4byte, contentsForeColor );
PROPERTY_FIELD (color4byte, contentsBackColor );
PROPERTY_FIELD (int, borderWidth );
PROPERTY_FIELD (int, tabIndex );
PROPERTY_RUNTIME (ScreenRect, runtime_absOrigin );
PROPERTY_RUNTIME (ScreenRect, runtime_hotspot );
PROPERTY_RUNTIME (imageRGBA_t, runtime_image );
PROPERTY_RUNTIME (texture_t*, runtime_textureBoss );
PROPERTY_RUNTIME (charset_t*, runtime_charset );
PROPERTY_RUNTIME (texture_t*, runtime_textureBoss );
PROPERTY_RUNTIME (size_t, runtime_textStrlength );
PROPERTY_RUNTIME (size_t, runtime_textCursor );
PROPERTY_RUNTIME (size_t, runtime_textSelectionStart );
PROPERTY_RUNTIME (size_t, runtime_textSelectionLength );
PROPERTY_RUNTIME (size_t, runtime_textFirstVisibleCol );
PROPERTY_LIST_END#define PROPERTY_FIELD(datatype, propertyname) datatype* propertyname; datatype _##propertyname
#define PROPERTY_ARRAY(datatype, size, propertyname) datatype* propertyname; datatype _##propertyname[size]
#define PROPERTY_RUNTIME(datatype, propertyname) datatype* propertyname; datatype _##propertyname#define PROPERTY_SYNTHESIZE(propertyname, datatype) \
void Property_Set_##propertyname (exControl* myControl, datatype value); \
\
void Property_Set_##propertyname (exControl* myControl, datatype value) \
{ \
myControl->_##propertyname = value; \
myControl->propertyname = &myControl->_##propertyname; \
}// A collection of controls
typedef struct exForm_s
{
// Run time properties
exControl controls[256]; // A set of 256 max controls. Form is control 0
int numControls; // We might not use this for anything.
exControl* myself; // This form as a control for others to inherit from where property isn't specified?
exControl* focus; // NULL for none?
exControl* drawFirst; // Linked list header. Should we ever save to disk, save using this as the order.
} exForm;typedef enum {DESIGN_TIME, RUN_TIME, } propavail;
typedef fbool (*property_read_t)(exControl*, const char*);
typedef fbool (*property_write_t)(exControl*, char*);
// propertytable propertyTable [] =
// {
//
// {"controlType", Property_Read_controlType, Property_Write_controlType , DESIGN_TIME },
// {"origin", Property_Read_origin, Property_Write_origin , DESIGN_TIME },
// {"hidden", Property_Read_hidden, Property_Write_hidden , DESIGN_TIME },
// {"notFocusable", Property_Read_notFocusable, Property_Write_notFocusable , DESIGN_TIME },Users browsing this forum: No registered users and 1 guest