9 changed files with 6169 additions and 13 deletions
-
5933src/CELLMath.hpp
-
5src/CMakeLists.txt
-
71src/Rester.cc
-
32src/Rester.h
-
61src/Rgba.cc
-
12src/Rgba.h
-
29src/common.h
-
16src/gtktest.cc
-
23src/tt.cc
5933
src/CELLMath.hpp
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,5 +1,8 @@ |
|||
add_executable(gtktest gtktest.cc Rgba.cc) |
|||
add_executable(gtktest gtktest.cc Rgba.cc Rester.cc) |
|||
target_link_libraries (gtktest ${FC_DEP_LIBS}) |
|||
|
|||
add_executable(timer timer.cc) |
|||
target_link_libraries (timer ${FC_DEP_LIBS}) |
|||
|
|||
add_executable(tt tt.cc Rgba.cc) |
|||
target_link_libraries (timer ${FC_DEP_LIBS}) |
@ -0,0 +1,71 @@ |
|||
/*
|
|||
* To change this license header, choose License Headers in Project Properties. |
|||
* To change this template file, choose Tools | Templates |
|||
* and open the template in the editor. |
|||
*/ |
|||
|
|||
/*
|
|||
* File: Rester.cc |
|||
* Author: blobt |
|||
* |
|||
* Created on January 23, 2020, 6:00 PM |
|||
*/ |
|||
|
|||
#include "Rgba.h"
|
|||
#include "Rester.h"
|
|||
#include <stdio.h>
|
|||
#include <iostream>
|
|||
#include <string.h>
|
|||
|
|||
using namespace std; |
|||
|
|||
Rester::Rester(int width, int height) { |
|||
_width = width; |
|||
_height = height; |
|||
|
|||
buffer = new Rgba[width * height]; |
|||
} |
|||
|
|||
Rester::~Rester() { |
|||
delete buffer; |
|||
} |
|||
|
|||
void Rester::drawPointer(int x, int y, Rgba color, int pointSize) { |
|||
switch (pointSize) { |
|||
case 1: |
|||
setPixel(x, y, color); |
|||
case 2: |
|||
setPixel(x, y, color); |
|||
setPixel(x + 1, y, color); |
|||
setPixel(x, y + 1, color); |
|||
setPixel(x + 1, y + 1, color); |
|||
case 3: |
|||
setPixel(x - 1, y - 1, color); |
|||
setPixel(x, y - 1, color); |
|||
setPixel(x + 1, y - 1, color); |
|||
|
|||
setPixel(x - 1, y, color); |
|||
setPixel(x, y, color); |
|||
setPixel(x + 1, y, color); |
|||
|
|||
setPixel(x - 1, y + 1, color); |
|||
setPixel(x, y + 1, color); |
|||
setPixel(x + 1, y + 1, color); |
|||
} |
|||
} |
|||
|
|||
int Rester::size() { |
|||
return _width * _height * sizeof (Rgba); |
|||
} |
|||
|
|||
void Rester::clean() { |
|||
memset(buffer, 0, size()); |
|||
} |
|||
|
|||
bool Rester::setPixel(int x, int y, Rgba color) { |
|||
if (x < 0 || y < 0 || x >= 500 || y >= 500) { |
|||
return false; |
|||
} |
|||
//行列是反的
|
|||
buffer[y * _width + x] = color; |
|||
} |
@ -0,0 +1,32 @@ |
|||
/* |
|||
* To change this license header, choose License Headers in Project Properties. |
|||
* To change this template file, choose Tools | Templates |
|||
* and open the template in the editor. |
|||
*/ |
|||
|
|||
/* |
|||
* File: Rester.h |
|||
* Author: blobt |
|||
* |
|||
* Created on January 23, 2020, 6:00 PM |
|||
*/ |
|||
|
|||
#ifndef RESTER_H |
|||
#define RESTER_H |
|||
|
|||
class Rester { |
|||
public: |
|||
Rgba* buffer; |
|||
Rester(int width, int height); |
|||
virtual ~Rester(); |
|||
void drawPointer(int x, int y, Rgba color, int pointSize = 1); |
|||
int size(); |
|||
void clean(); |
|||
bool setPixel(int x, int y, Rgba color); |
|||
private: |
|||
int _width; |
|||
int _height; |
|||
}; |
|||
|
|||
#endif /* RESTER_H */ |
|||
|
@ -0,0 +1,29 @@ |
|||
/* |
|||
* To change this license header, choose License Headers in Project Properties. |
|||
* To change this template file, choose Tools | Templates |
|||
* and open the template in the editor. |
|||
*/ |
|||
|
|||
/* |
|||
* File: common.h |
|||
* Author: Blobt |
|||
* |
|||
* Created on October 5, 2019, 4:55 PM |
|||
*/ |
|||
|
|||
#ifndef COMMON_H |
|||
#define COMMON_H |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
#define die(m) do { perror(m); exit(EXIT_FAILURE); } while(0) |
|||
|
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* COMMON_H */ |
|||
|
@ -0,0 +1,23 @@ |
|||
#include "Rgba.h"
|
|||
#include <stdio.h>
|
|||
#include <iostream>
|
|||
#include <bitset>
|
|||
#include <string.h>
|
|||
|
|||
using namespace std; |
|||
|
|||
int main() { |
|||
Rgba x(255, 0, 0, 255); |
|||
Rgba y(0, 0, 255, 255); |
|||
|
|||
unsigned char* z = new unsigned char[4]; |
|||
|
|||
Rgba buffer[5][5]; |
|||
|
|||
printf("%ld\n", sizeof(buffer)); |
|||
//memcpy(z, x, sizeof(x));
|
|||
//
|
|||
//
|
|||
// bitset<32> set = (int)z;
|
|||
// cout << set << endl;
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue