Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "graphics.h"
- #include <math.h>
- #include <stdlib.h>
- #include <dos.h>
- #include <windows.h>
- #include <iostream>
- #include<time.h>
- using namespace std;
- #define pi 3.14159265359
- float x_1, x_2, y_1, y_2;
- float xa, xb, xc;
- float theta;
- int a, b;
- int xe(float x){// normalizarea coordonatei
- return((int)((x - x_1) / (x_2 - x_1)*a));
- }
- int ye(float y){// normalizarea coordonatei y
- return((int)((y_2 - y) / (y_2 - y_1)*b));
- }
- void axe(){
- setcolor(0);
- outtextxy(xe(x_2) - 20, ye(0) - 20, "x");
- outtextxy(xe(x_2) - 18, ye(0) - 7, ">");
- outtextxy(xe(0) - 15, ye(y_2) + 15, "y");
- outtextxy(xe(0) - 15, ye(0) - 15, "O");
- outtextxy(xe(0) - 1, ye(y_2) , "^");
- line(xe(x_1), ye(0), xe(x_2), ye(0));
- line(xe(0), ye(y_1), xe(0), ye(y_2));
- }
- float l_x(float theta) {
- float sin_t = sin(theta);
- return 1 / (1 + sin_t*sin_t);
- }
- float l_y(float theta) {
- float sin_t = sin(theta);
- return 1 * cos(theta) / (1 + sin_t*sin_t);
- }
- void grafic() {
- float theta;
- float h = 2 * pi / 400;
- float x, y;
- theta = 0;
- float r = 1.f;
- while (-2*pi>= theta <= 2 * pi) {
- x = theta*cos(theta) ;
- y = sin(theta);
- putpixel(xe(x), ye(y), 14);
- theta = theta + h;
- setcolor(3);
- }
- }
- int main(){
- /*printf("Limitele domeniului orizontal:\n");
- printf("Atentie, x_1<0<x_2 si y_1<0<y_2 \n");
- printf("x_1="); scanf("%f", &x_1); //x_1<0<x_2
- printf("x_2="); scanf("%f", &x_2);
- printf("Limitele domeniului vertical:\n");
- printf("y_1="); scanf("%f", &y_1); //y_1<0<y_2
- printf("y_2="); scanf("%f", &y_2);*/
- initwindow(800, 600, "AXE", 200, 200);
- setbkcolor(20);
- cleardevice();
- //time_t;
- //srand(time(NULL));
- //patrat desenat ale carui laturi au culori diferite
- //setcolor(rand() % 15);
- line(200, 220, 200, 320);
- //setcolor(rand() % 15);
- line(200, 220, 300, 220);
- //setcolor(rand() % 15);
- line(300, 220, 300, 320);
- //setcolor(rand() % 15);
- line(200, 320, 300, 320);
- //setcolor(rand() % 15);
- /*//100 puncte aleatoriu de culori diferite //nu ai treaba cu asta
- for (int i = 0;i <= 100; i++) {
- putpixel(rand() % 200, rand() % 300, rand() % 15);
- }*/
- //cercuri concentrice
- //float raza = 12.4;
- circle(400, 200, 12.4);
- /*a = getmaxx(); //nr. maxim de pixeli pe coord. x
- b = getmaxy();
- axe();
- grafic();*/
- getch();
- closegraph();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement