Drawing functions
Posted: Sun Feb 11, 2007 11:49 pm
Hi everyone, here is a .c file that I made today.
It defines four new drawing functions:
-Draw elipse
-Draw square
-Draw triangle
-Draw 5-point star
All of these shapes can be rotated (except the ellipse), resized, thickened, colored, moved.
Script editor syntax:
You should be careful not to call these functions to often as they can slow down your game.
For more info about the functions look at the c file, it is somewhat commented. I tried to optimize it as much as i could, if anyone can do better please do and post here. Shapes are not fillable because it really slows things down.
Please post your opinions and comments. Bye
It defines four new drawing functions:
-Draw elipse
-Draw square
-Draw triangle
-Draw 5-point star
All of these shapes can be rotated (except the ellipse), resized, thickened, colored, moved.
Script editor syntax:
- Code: Select all
void draw_elipse(int xe, int ye,//coordinates on canvas
short int xrad,short int yrad,//x and y radius
short int thicknes,//line thicknes should be 1-15
short int red,short int green,short int blue)//color should be 0-255
ex:
//this will draw a squashed red elipse 2 pixels thick at canvas coordinates 100,100
draw_elipse(100,100,40,20,2,255,0,0);
- Code: Select all
void draw_square(int xs, int ys,//canvas coordinates
short int size,//size
short int thicknes,//1-15
float rotation,//0-2
short int red,short int green,short int blue)//0-255
ex:
//This will draw a small rotated square
draw_square(200,200,10,1,0,255,255,255);
- Code: Select all
void draw_triangle(int xt, int yt,//Canvas coordinates
short int size,//Size
short int thicknes,//1-15
float rotation,//Rotation should be 0-2 (limit it to these values if changing
//dynamicaly
short int red, short int green, short int blue)//color
ex:
//this will draw a medium triangle tree pixels thick and slightly rotated
draw_triangle(500,100,40,3,1,0,200,200);
- Code: Select all
void draw_star(int xs, int ys,
short int size,
short int thicknes,
float rotation,//0-2
short int red, short int green, short int blue)//0-255
ex:
//This will draw a large rotated star
draw_star(400,100,50,1,1.5,0,0,255);
You should be careful not to call these functions to often as they can slow down your game.
For more info about the functions look at the c file, it is somewhat commented. I tried to optimize it as much as i could, if anyone can do better please do and post here. Shapes are not fillable because it really slows things down.
Please post your opinions and comments. Bye