This repository has been archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
g.hpp
89 lines (71 loc) · 1.97 KB
/
g.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// code by userElaina
// pop version that you can start quickly
#pragma once
#include "bmp24bits.hpp"
BMP24bits*nft;
int ox,oy;
int col=0x000000;
double xa=1,xb=0,ya=1,yb=0;
inline int NewImage(int x,int y){
ox=((x>>2)+1)<<2;
oy=((y>>2)+1)<<2;
nft=new BMP24bits(ox<<1,oy<<1);
printf("NewImage: O(%d,%d)\n",ox,oy);
return 0;
}
inline int LoadImage(std::string pth){
nft=new BMP24bits(pth);
ox=nft->width>>1;
oy=nft->height>>1;
printf("LoadImage: O(%d,%d)\n",ox,oy);
return 0;
}
inline int SetAxis(){
for(int i=0;i<nft->width;i++)
nft->setpixel(nft->getp(i,oy));
for(int i=0;i<nft->height;i++)
nft->setpixel(nft->getp(ox,i));
return 0;
}
inline int SetColor(int color=0x000000){
col=color;
return 0;
}
inline int SetPixel(int x,int y,int rgb=(-1)){
if(rgb==(-1))rgb=col;
return nft->setpixel(nft->getp(x+ox,y+oy),rgb);
}
inline int SetPixel(double x,double y,int rgb=(-1)){
return SetPixel((int)(x>0?x+0.5:x-0.5),(int)(y>0?y+0.5:y-0.5),rgb);
}
inline int SetPixel(std::pair<int,int>p,int rgb=(-1)){
return SetPixel(p.first,p.second,rgb);
}
inline int SetPixel(std::pair<double,double>p,int rgb=(-1)){
return SetPixel(p.first,p.second,rgb);
}
inline int SetPixel2(int x,int y,int rgb=(-1)){
return SetPixel(x,y,rgb)+SetPixel(-x,-y,rgb);
}
inline int SetPixel4(int x,int y,int rgb=(-1)){
return SetPixel2(x,y,rgb)+SetPixel2(-x,y,rgb);
}
inline int SetPixel8(int x,int y,int rgb=(-1)){
return SetPixel4(x,y,rgb)+SetPixel4(y,x,rgb);
}
inline int SetPixel_map(double x,double y,int rgb=(-1)){
return SetPixel(x*xa+xb,y*ya+yb,rgb);
}
inline int GetPixel(int x,int y){
return nft->getpixel(nft->getp(x+ox,y+oy));
}
inline int RGB(int r,int g,int b,int a=0){
return argb(r,g,b,a);
}
inline int Save(std::string pth){
return nft->save(pth);
}
inline int Clear(){
nft->white();
return 0;
}