line function
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
BasedOnStyle: LLVM
|
|
||||||
IndentWidth: 4
|
|
||||||
TabWidth: 4
|
|
||||||
UseTab: Never
|
|
22
src/main.cpp
22
src/main.cpp
@@ -1,13 +1,21 @@
|
|||||||
#include "tgaimage.h"
|
#include "tgaimage.h"
|
||||||
|
|
||||||
const TGAColor white = TGAColor(255, 255, 255, 255);
|
const TGAColor white = TGAColor(255, 255, 255, 255);
|
||||||
const TGAColor red = TGAColor(255, 0, 0, 255);
|
const TGAColor red = TGAColor(255, 0, 0, 255);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
void line(int x0, int y0, int x1, int y1, TGAImage &image, TGAColor color) {
|
||||||
TGAImage image(100, 100, TGAImage::RGB);
|
for (float t = 0.0; t < 1.0; t += 0.01) {
|
||||||
image.set(52, 41, red);
|
int x = x0 + (x1 - x0) * t;
|
||||||
image.flip_vertically(); // i want to have the origin at the left bottom corner of the image
|
int y = y0 + (y1 - y0) * t;
|
||||||
image.write_tga_file("output.tga");
|
image.set(x, y, color);
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
TGAImage image(100, 100, TGAImage::RGB);
|
||||||
|
line(0, 0, 99, 99, image, white);
|
||||||
|
image.flip_vertically(); // i want to have the origin at the left bottom
|
||||||
|
// corner of the image
|
||||||
|
image.write_tga_file("output.tga");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user