update templates
This commit is contained in:
parent
a17f36a5ee
commit
a0ee8b436d
|
@ -5,8 +5,12 @@
|
|||
#define RAYGUI_IMPLEMENTATION
|
||||
#include <raygui/raygui.h>
|
||||
|
||||
void updateRadius(int baseL, int outerL, int *pBaseR, int *pOuterR) {
|
||||
int totalL=baseL+outerL+outerL;
|
||||
void updateRadius(int baseL, int outerL, int pointL, int *pBaseR, int *pOuterR, int *pPointR) {
|
||||
int totalL=baseL+outerL;
|
||||
if (pointL>outerL)
|
||||
totalL+=pointL;
|
||||
else
|
||||
totalL+=outerL;
|
||||
int totalR = 420;
|
||||
int remainder = totalR % totalL;
|
||||
if (remainder!=0) {
|
||||
|
@ -18,17 +22,19 @@ void updateRadius(int baseL, int outerL, int *pBaseR, int *pOuterR) {
|
|||
}
|
||||
*pBaseR = (totalR) / totalL * baseL;
|
||||
*pOuterR = (totalR) / totalL * outerL;
|
||||
*pPointR = (totalR) / totalL * pointL;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int baseL=2;
|
||||
int outerL=13;
|
||||
int baseR,outerR;
|
||||
int pointL=3;
|
||||
int baseR,outerR,pointR;
|
||||
int cx=450,cy=450;
|
||||
int speed = 1;
|
||||
Color trackColor = BLUE;
|
||||
updateRadius(baseL, outerL, &baseR, &outerR);
|
||||
updateRadius(baseL, outerL, pointL, &baseR, &outerR, & pointR);
|
||||
InitWindow(1300,900,"Epitrochoid");
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
SetTargetFPS(60);
|
||||
|
@ -43,22 +49,27 @@ int main() {
|
|||
float r=0;
|
||||
int lastx,lasty;
|
||||
lasty=cy;
|
||||
lastx=cx+(baseR+outerR+outerR);
|
||||
lastx=cx+(baseR+outerR-pointR);
|
||||
int frameCount = 0;
|
||||
while(!WindowShouldClose()) {
|
||||
//GUI
|
||||
int newOuterL = GuiSliderBar((Rectangle){ 70, 20, 200, 30 },"Outer",TextFormat("%i", (int)outerL), outerL, 1, 50);
|
||||
int newBaseL = GuiSliderBar((Rectangle){ 70, 60, 200, 30 },"Base",TextFormat("%i", (int)baseL), baseL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 120, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
int newPointL = GuiSliderBar((Rectangle){ 70, 100, 200, 30 },"Point",TextFormat("%i", (int)pointL), pointL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 150, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
GuiLabel((Rectangle){ 20, 220, 80, 30 },TextFormat("Color: 0x%X%X%X ",(int)(trackColor.r), (int)(trackColor.g),(int)(trackColor.b)));
|
||||
trackColor= GuiColorPicker((Rectangle){ 50, 250, 196, 192 }, NULL, trackColor);
|
||||
int doClear = GuiButton((Rectangle){ 120, 700, 80, 30 },"Clear");
|
||||
if (newOuterL!=outerL || newBaseL!=baseL) {
|
||||
if (newOuterL!=outerL || newBaseL!=baseL || newPointL!=pointL) {
|
||||
if (newInnerL!=innerL)
|
||||
pointL=newInnerL;
|
||||
else
|
||||
pointL=newPointL;
|
||||
outerL=newOuterL;
|
||||
baseL=newBaseL;
|
||||
updateRadius(baseL, outerL, &baseR, &outerR);
|
||||
updateRadius(baseL, outerL, pointL, &baseR, &outerR, & pointR);
|
||||
lasty=cy;
|
||||
lastx=cx+(baseR+outerR+outerR);
|
||||
lastx=cx+(baseR+outerR-pointR);
|
||||
r=0;
|
||||
ImageClearBackground(&trackImage,WHITE);
|
||||
ImageFillRectangleEx(&trackImage,0,0,900,900,LIGHTGRAY);
|
||||
|
@ -72,9 +83,9 @@ int main() {
|
|||
r+=0.01;
|
||||
float outerCX=cx+ (baseR+outerR)*cos(r);
|
||||
float outerCY=cy+ (baseR+outerR)*sin(r);
|
||||
float theta = r * baseL / outerL;
|
||||
int x=round(outerCX + outerR * cos(theta));
|
||||
int y=round(outerCY + outerR * sin(theta));
|
||||
float theta = r * (baseL+outerL) / outerL;
|
||||
int x=round(outerCX - pointR * cos(theta));
|
||||
int y=round(outerCY - pointR * sin(theta));
|
||||
|
||||
//update image (in CPU)
|
||||
//ImageClearBackground(&trackImage,WHITE);
|
||||
|
@ -86,6 +97,8 @@ int main() {
|
|||
//base circle
|
||||
ImageDrawCircleEx(&circlesImage,cx,cy,baseR,1,LIGHTRED);
|
||||
ImageDrawCircleEx(&circlesImage,outerCX,outerCY,outerR,1,LIGHTSLATEGRAY);
|
||||
ImageDrawLineEx(&circlesImage,cx,cy,outerCX,outerCY,1,LIGHTRED);
|
||||
ImageDrawLineEx(&circlesImage,x,y,outerCX,outerCY,1,LIGHTSLATEGRAY);
|
||||
ImageDrawPointEx(&circlesImage,x,y,7,RED);
|
||||
|
||||
//Drawing in GPU
|
||||
|
@ -109,4 +122,4 @@ int main() {
|
|||
UnloadImage(circlesImage);
|
||||
UnloadImage(trackImage);
|
||||
CloseWindow();
|
||||
}
|
||||
}
|
|
@ -5,10 +5,18 @@
|
|||
#define RAYGUI_IMPLEMENTATION
|
||||
#include <raygui/raygui.h>
|
||||
|
||||
void updateRadius(int baseL, int innerL, int *pBaseR, int *pInnerR) {
|
||||
void updateRadius(int baseL, int innerL,int pointL, int *pBaseR, int *pInnerR, int *pPointR) {
|
||||
int totalL=baseL;
|
||||
if (innerL>baseL)
|
||||
totalL = (2*innerL-baseL);
|
||||
if (innerL>baseL) {
|
||||
if (innerL>pointL)
|
||||
totalL = (2*innerL-baseL);
|
||||
else {
|
||||
totalL = (innerL+pointL-baseL);
|
||||
}
|
||||
} else {
|
||||
if (pointL>innerL)
|
||||
totalL = baseL-innerL+pointL;
|
||||
}
|
||||
int totalR = 420;
|
||||
int remainder = totalR % totalL;
|
||||
if (remainder!=0) {
|
||||
|
@ -18,24 +26,21 @@ void updateRadius(int baseL, int innerL, int *pBaseR, int *pInnerR) {
|
|||
totalR += ( totalL - remainder);
|
||||
}
|
||||
}
|
||||
if (innerL<baseL) {
|
||||
*pBaseR = totalR;
|
||||
*pInnerR = (totalR) / totalL * innerL;
|
||||
} else {
|
||||
*pBaseR = (totalR) / totalL * baseL;
|
||||
*pInnerR = totalR / totalL * innerL;
|
||||
}
|
||||
*pBaseR = totalR / totalL * baseL;
|
||||
*pInnerR = totalR / totalL * innerL;
|
||||
*pPointR = totalR / totalL * pointL;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int baseL=2;
|
||||
int baseL=6;
|
||||
int innerL=3;
|
||||
int baseR,innerR;
|
||||
int pointL=6;
|
||||
int baseR,innerR,pointR;
|
||||
int cx=450,cy=450;
|
||||
int speed = 1;
|
||||
Color trackColor = BLUE;
|
||||
updateRadius(baseL, innerL, &baseR, &innerR);
|
||||
updateRadius(baseL, innerL, pointL, &baseR, &innerR, &pointR);
|
||||
InitWindow(1300,900,"Hypotrochoid");
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
SetTargetFPS(60);
|
||||
|
@ -49,6 +54,7 @@ int main() {
|
|||
Image circlesImage = GenImageColor(900,900,BLANK);
|
||||
float r=0;
|
||||
int lastx,lasty;
|
||||
bool skip=true;
|
||||
lasty=cy;
|
||||
lastx=cx+baseR;
|
||||
int frameCount = 0;
|
||||
|
@ -56,17 +62,21 @@ int main() {
|
|||
//GUI
|
||||
int newInnerL = GuiSliderBar((Rectangle){ 70, 20, 200, 30 },"Inner",TextFormat("%i", (int)innerL), innerL, 1, 50);
|
||||
int newBaseL = GuiSliderBar((Rectangle){ 70, 60, 200, 30 },"Base",TextFormat("%i", (int)baseL), baseL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 120, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
int newPointL = GuiSliderBar((Rectangle){ 70, 100, 200, 30 },"Point",TextFormat("%i", (int)pointL), pointL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 150, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
GuiLabel((Rectangle){ 20, 220, 80, 30 },TextFormat("Color: 0x%X%X%X ",(int)(trackColor.r), (int)(trackColor.g),(int)(trackColor.b)));
|
||||
trackColor= GuiColorPicker((Rectangle){ 50, 250, 196, 192 }, NULL, trackColor);
|
||||
int doClear = GuiButton((Rectangle){ 120, 700, 80, 30 },"Clear");
|
||||
if (newInnerL!=innerL || newBaseL!=baseL) {
|
||||
if (newInnerL!=innerL || newBaseL!=baseL || newPointL!=pointL) {
|
||||
if (newInnerL!=innerL)
|
||||
pointL=newInnerL;
|
||||
else
|
||||
pointL=newPointL;
|
||||
innerL=newInnerL;
|
||||
baseL=newBaseL;
|
||||
updateRadius(baseL, innerL, &baseR, &innerR);
|
||||
lasty=cy;
|
||||
lastx=cx+baseR;
|
||||
updateRadius(baseL, innerL, pointL, &baseR, &innerR, &pointR);
|
||||
r=0;
|
||||
skip=true;
|
||||
ImageClearBackground(&trackImage,WHITE);
|
||||
ImageFillRectangleEx(&trackImage,0,0,900,900,LIGHTGRAY);
|
||||
ImageFillRectangleEx(&trackImage,5,5,890,890,WHITE);
|
||||
|
@ -76,23 +86,33 @@ int main() {
|
|||
ImageFillRectangleEx(&trackImage,5,5,890,890,WHITE);
|
||||
}
|
||||
//update datas
|
||||
r+=0.01;
|
||||
float innerCX=cx+ (baseR-innerR)*cos(r);
|
||||
float innerCY=cy+ (baseR-innerR)*sin(r);
|
||||
float theta = r * baseL / innerL;
|
||||
int x=round(innerCX + innerR * cos(theta));
|
||||
int y=round(innerCY + innerR * sin(theta));
|
||||
int x,y;
|
||||
float theta;
|
||||
if (innerL<baseL) {
|
||||
theta = r * (baseL-innerL) / innerL;
|
||||
x=round(innerCX + pointR * cos(theta));
|
||||
y=round(innerCY - pointR * sin(theta));
|
||||
} else {
|
||||
theta = r * (innerL-baseL) / innerL;
|
||||
x=round(innerCX + pointR * cos(theta));
|
||||
y=round(innerCY + pointR * sin(theta));
|
||||
}
|
||||
|
||||
//update image (in CPU)
|
||||
//ImageClearBackground(&trackImage,WHITE);
|
||||
ImageDrawLineEx(&trackImage,lastx,lasty,x,y,3,trackColor);
|
||||
if (!skip)
|
||||
ImageDrawLineEx(&trackImage,lastx,lasty,x,y,3,trackColor);
|
||||
|
||||
frameCount++;
|
||||
if (frameCount>=speed) {
|
||||
ImageClearBackground(&circlesImage,BLANK);
|
||||
//base circle
|
||||
ImageDrawCircleEx(&circlesImage,cx,cy,baseR,1,LIGHTRED);
|
||||
ImageDrawCircleEx(&circlesImage,innerCX,innerCY,innerR,1,LIGHTSLATEGRAY);
|
||||
ImageDrawCircleEx(&circlesImage,innerCX,innerCY,innerR,1,LIGHTGRAY);
|
||||
ImageDrawLineEx(&circlesImage,innerCX,innerCY,cx,cy,1,LIGHTRED);
|
||||
ImageDrawLineEx(&circlesImage,innerCX,innerCY,x,y,1,LIGHTGRAY);
|
||||
ImageDrawPointEx(&circlesImage,x,y,7,RED);
|
||||
|
||||
//Drawing in GPU
|
||||
|
@ -107,13 +127,14 @@ int main() {
|
|||
UnloadTexture(trackTexture);
|
||||
frameCount=0;
|
||||
}
|
||||
|
||||
lastx=x;
|
||||
lasty=y;
|
||||
skip=false;
|
||||
r+=0.01;
|
||||
}
|
||||
|
||||
//Clean up
|
||||
UnloadImage(circlesImage);
|
||||
UnloadImage(trackImage);
|
||||
CloseWindow();
|
||||
}
|
||||
}
|
|
@ -5,8 +5,12 @@
|
|||
#define RAYGUI_IMPLEMENTATION
|
||||
#include <raygui/raygui.h>
|
||||
|
||||
void updateRadius(int baseL, int outerL, int *pBaseR, int *pOuterR) {
|
||||
int totalL=baseL+outerL+outerL;
|
||||
void updateRadius(int baseL, int outerL, int pointL, int *pBaseR, int *pOuterR, int *pPointR) {
|
||||
int totalL=baseL+outerL;
|
||||
if (pointL>outerL)
|
||||
totalL+=pointL;
|
||||
else
|
||||
totalL+=outerL;
|
||||
int totalR = 420;
|
||||
int remainder = totalR % totalL;
|
||||
if (remainder!=0) {
|
||||
|
@ -18,17 +22,19 @@ void updateRadius(int baseL, int outerL, int *pBaseR, int *pOuterR) {
|
|||
}
|
||||
*pBaseR = (totalR) / totalL * baseL;
|
||||
*pOuterR = (totalR) / totalL * outerL;
|
||||
*pPointR = (totalR) / totalL * pointL;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int baseL=2;
|
||||
int outerL=13;
|
||||
int baseR,outerR;
|
||||
int pointL=3;
|
||||
int baseR,outerR,pointR;
|
||||
int cx=450,cy=450;
|
||||
int speed = 1;
|
||||
Color trackColor = BLUE;
|
||||
updateRadius(baseL, outerL, &baseR, &outerR);
|
||||
updateRadius(baseL, outerL, pointL, &baseR, &outerR, & pointR);
|
||||
InitWindow(1300,900,"Epitrochoid");
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
SetTargetFPS(60);
|
||||
|
@ -43,22 +49,27 @@ int main() {
|
|||
float r=0;
|
||||
int lastx,lasty;
|
||||
lasty=cy;
|
||||
lastx=cx+(baseR+outerR+outerR);
|
||||
lastx=cx+(baseR+outerR-pointR);
|
||||
int frameCount = 0;
|
||||
while(!WindowShouldClose()) {
|
||||
//GUI
|
||||
int newOuterL = GuiSliderBar((Rectangle){ 70, 20, 200, 30 },"Outer",TextFormat("%i", (int)outerL), outerL, 1, 50);
|
||||
int newBaseL = GuiSliderBar((Rectangle){ 70, 60, 200, 30 },"Base",TextFormat("%i", (int)baseL), baseL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 120, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
int newPointL = GuiSliderBar((Rectangle){ 70, 100, 200, 30 },"Point",TextFormat("%i", (int)pointL), pointL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 150, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
GuiLabel((Rectangle){ 20, 220, 80, 30 },TextFormat("Color: 0x%X%X%X ",(int)(trackColor.r), (int)(trackColor.g),(int)(trackColor.b)));
|
||||
trackColor= GuiColorPicker((Rectangle){ 50, 250, 196, 192 }, NULL, trackColor);
|
||||
int doClear = GuiButton((Rectangle){ 120, 700, 80, 30 },"Clear");
|
||||
if (newOuterL!=outerL || newBaseL!=baseL) {
|
||||
if (newOuterL!=outerL || newBaseL!=baseL || newPointL!=pointL) {
|
||||
if (newInnerL!=innerL)
|
||||
pointL=newInnerL;
|
||||
else
|
||||
pointL=newPointL;
|
||||
outerL=newOuterL;
|
||||
baseL=newBaseL;
|
||||
updateRadius(baseL, outerL, &baseR, &outerR);
|
||||
updateRadius(baseL, outerL, pointL, &baseR, &outerR, & pointR);
|
||||
lasty=cy;
|
||||
lastx=cx+(baseR+outerR+outerR);
|
||||
lastx=cx+(baseR+outerR-pointR);
|
||||
r=0;
|
||||
ImageClearBackground(&trackImage,WHITE);
|
||||
ImageFillRectangleEx(&trackImage,0,0,900,900,LIGHTGRAY);
|
||||
|
@ -72,9 +83,9 @@ int main() {
|
|||
r+=0.01;
|
||||
float outerCX=cx+ (baseR+outerR)*cos(r);
|
||||
float outerCY=cy+ (baseR+outerR)*sin(r);
|
||||
float theta = r * baseL / outerL;
|
||||
int x=round(outerCX + outerR * cos(theta));
|
||||
int y=round(outerCY + outerR * sin(theta));
|
||||
float theta = r * (baseL+outerL) / outerL;
|
||||
int x=round(outerCX - pointR * cos(theta));
|
||||
int y=round(outerCY - pointR * sin(theta));
|
||||
|
||||
//update image (in CPU)
|
||||
//ImageClearBackground(&trackImage,WHITE);
|
||||
|
@ -86,6 +97,8 @@ int main() {
|
|||
//base circle
|
||||
ImageDrawCircleEx(&circlesImage,cx,cy,baseR,1,LIGHTRED);
|
||||
ImageDrawCircleEx(&circlesImage,outerCX,outerCY,outerR,1,LIGHTSLATEGRAY);
|
||||
ImageDrawLineEx(&circlesImage,cx,cy,outerCX,outerCY,1,LIGHTRED);
|
||||
ImageDrawLineEx(&circlesImage,x,y,outerCX,outerCY,1,LIGHTSLATEGRAY);
|
||||
ImageDrawPointEx(&circlesImage,x,y,7,RED);
|
||||
|
||||
//Drawing in GPU
|
||||
|
@ -109,4 +122,4 @@ int main() {
|
|||
UnloadImage(circlesImage);
|
||||
UnloadImage(trackImage);
|
||||
CloseWindow();
|
||||
}
|
||||
}
|
|
@ -5,10 +5,18 @@
|
|||
#define RAYGUI_IMPLEMENTATION
|
||||
#include <raygui/raygui.h>
|
||||
|
||||
void updateRadius(int baseL, int innerL, int *pBaseR, int *pInnerR) {
|
||||
void updateRadius(int baseL, int innerL,int pointL, int *pBaseR, int *pInnerR, int *pPointR) {
|
||||
int totalL=baseL;
|
||||
if (innerL>baseL)
|
||||
totalL = (2*innerL-baseL);
|
||||
if (innerL>baseL) {
|
||||
if (innerL>pointL)
|
||||
totalL = (2*innerL-baseL);
|
||||
else {
|
||||
totalL = (innerL+pointL-baseL);
|
||||
}
|
||||
} else {
|
||||
if (pointL>innerL)
|
||||
totalL = baseL-innerL+pointL;
|
||||
}
|
||||
int totalR = 420;
|
||||
int remainder = totalR % totalL;
|
||||
if (remainder!=0) {
|
||||
|
@ -18,24 +26,21 @@ void updateRadius(int baseL, int innerL, int *pBaseR, int *pInnerR) {
|
|||
totalR += ( totalL - remainder);
|
||||
}
|
||||
}
|
||||
if (innerL<baseL) {
|
||||
*pBaseR = totalR;
|
||||
*pInnerR = (totalR) / totalL * innerL;
|
||||
} else {
|
||||
*pBaseR = (totalR) / totalL * baseL;
|
||||
*pInnerR = totalR / totalL * innerL;
|
||||
}
|
||||
*pBaseR = totalR / totalL * baseL;
|
||||
*pInnerR = totalR / totalL * innerL;
|
||||
*pPointR = totalR / totalL * pointL;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
int baseL=2;
|
||||
int baseL=6;
|
||||
int innerL=3;
|
||||
int baseR,innerR;
|
||||
int pointL=6;
|
||||
int baseR,innerR,pointR;
|
||||
int cx=450,cy=450;
|
||||
int speed = 1;
|
||||
Color trackColor = BLUE;
|
||||
updateRadius(baseL, innerL, &baseR, &innerR);
|
||||
updateRadius(baseL, innerL, pointL, &baseR, &innerR, &pointR);
|
||||
InitWindow(1300,900,"Hypotrochoid");
|
||||
SetTraceLogLevel(LOG_WARNING);
|
||||
SetTargetFPS(60);
|
||||
|
@ -49,6 +54,7 @@ int main() {
|
|||
Image circlesImage = GenImageColor(900,900,BLANK);
|
||||
float r=0;
|
||||
int lastx,lasty;
|
||||
bool skip=true;
|
||||
lasty=cy;
|
||||
lastx=cx+baseR;
|
||||
int frameCount = 0;
|
||||
|
@ -56,17 +62,21 @@ int main() {
|
|||
//GUI
|
||||
int newInnerL = GuiSliderBar((Rectangle){ 70, 20, 200, 30 },"Inner",TextFormat("%i", (int)innerL), innerL, 1, 50);
|
||||
int newBaseL = GuiSliderBar((Rectangle){ 70, 60, 200, 30 },"Base",TextFormat("%i", (int)baseL), baseL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 120, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
int newPointL = GuiSliderBar((Rectangle){ 70, 100, 200, 30 },"Point",TextFormat("%i", (int)pointL), pointL, 1, 50);
|
||||
speed = GuiSliderBar((Rectangle){ 70, 150, 200, 30 },"Speed",TextFormat("%i", (int)speed), speed, 1, 50);
|
||||
GuiLabel((Rectangle){ 20, 220, 80, 30 },TextFormat("Color: 0x%X%X%X ",(int)(trackColor.r), (int)(trackColor.g),(int)(trackColor.b)));
|
||||
trackColor= GuiColorPicker((Rectangle){ 50, 250, 196, 192 }, NULL, trackColor);
|
||||
int doClear = GuiButton((Rectangle){ 120, 700, 80, 30 },"Clear");
|
||||
if (newInnerL!=innerL || newBaseL!=baseL) {
|
||||
if (newInnerL!=innerL || newBaseL!=baseL || newPointL!=pointL) {
|
||||
if (newInnerL!=innerL)
|
||||
pointL=newInnerL;
|
||||
else
|
||||
pointL=newPointL;
|
||||
innerL=newInnerL;
|
||||
baseL=newBaseL;
|
||||
updateRadius(baseL, innerL, &baseR, &innerR);
|
||||
lasty=cy;
|
||||
lastx=cx+baseR;
|
||||
updateRadius(baseL, innerL, pointL, &baseR, &innerR, &pointR);
|
||||
r=0;
|
||||
skip=true;
|
||||
ImageClearBackground(&trackImage,WHITE);
|
||||
ImageFillRectangleEx(&trackImage,0,0,900,900,LIGHTGRAY);
|
||||
ImageFillRectangleEx(&trackImage,5,5,890,890,WHITE);
|
||||
|
@ -76,23 +86,33 @@ int main() {
|
|||
ImageFillRectangleEx(&trackImage,5,5,890,890,WHITE);
|
||||
}
|
||||
//update datas
|
||||
r+=0.01;
|
||||
float innerCX=cx+ (baseR-innerR)*cos(r);
|
||||
float innerCY=cy+ (baseR-innerR)*sin(r);
|
||||
float theta = r * baseL / innerL;
|
||||
int x=round(innerCX + innerR * cos(theta));
|
||||
int y=round(innerCY + innerR * sin(theta));
|
||||
int x,y;
|
||||
float theta;
|
||||
if (innerL<baseL) {
|
||||
theta = r * (baseL-innerL) / innerL;
|
||||
x=round(innerCX + pointR * cos(theta));
|
||||
y=round(innerCY - pointR * sin(theta));
|
||||
} else {
|
||||
theta = r * (innerL-baseL) / innerL;
|
||||
x=round(innerCX + pointR * cos(theta));
|
||||
y=round(innerCY + pointR * sin(theta));
|
||||
}
|
||||
|
||||
//update image (in CPU)
|
||||
//ImageClearBackground(&trackImage,WHITE);
|
||||
ImageDrawLineEx(&trackImage,lastx,lasty,x,y,3,trackColor);
|
||||
if (!skip)
|
||||
ImageDrawLineEx(&trackImage,lastx,lasty,x,y,3,trackColor);
|
||||
|
||||
frameCount++;
|
||||
if (frameCount>=speed) {
|
||||
ImageClearBackground(&circlesImage,BLANK);
|
||||
//base circle
|
||||
ImageDrawCircleEx(&circlesImage,cx,cy,baseR,1,LIGHTRED);
|
||||
ImageDrawCircleEx(&circlesImage,innerCX,innerCY,innerR,1,LIGHTSLATEGRAY);
|
||||
ImageDrawCircleEx(&circlesImage,innerCX,innerCY,innerR,1,LIGHTGRAY);
|
||||
ImageDrawLineEx(&circlesImage,innerCX,innerCY,cx,cy,1,LIGHTRED);
|
||||
ImageDrawLineEx(&circlesImage,innerCX,innerCY,x,y,1,LIGHTGRAY);
|
||||
ImageDrawPointEx(&circlesImage,x,y,7,RED);
|
||||
|
||||
//Drawing in GPU
|
||||
|
@ -107,13 +127,14 @@ int main() {
|
|||
UnloadTexture(trackTexture);
|
||||
frameCount=0;
|
||||
}
|
||||
|
||||
lastx=x;
|
||||
lasty=y;
|
||||
skip=false;
|
||||
r+=0.01;
|
||||
}
|
||||
|
||||
//Clean up
|
||||
UnloadImage(circlesImage);
|
||||
UnloadImage(trackImage);
|
||||
CloseWindow();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue