| 1188 | |
| 1189 | |
| 1190 | void Globe::XuLine(Surface* surface, Surface* src, double x1, double y1, double x2, double y2, int shade) |
| 1191 | { |
| 1192 | if (_clipper->LineClip(&x1,&y1,&x2,&y2) != 1) return; //empty line |
| 1193 | |
| 1194 | double deltax = x2-x1, deltay = y2-y1; |
| 1195 | bool inv; |
| 1196 | Sint16 tcol; |
| 1197 | double len,x0,y0,SX,SY; |
| 1198 | if (abs((int)y2-(int)y1) > abs((int)x2-(int)x1)) |
| 1199 | { |
| 1200 | len=abs((int)y2-(int)y1); |
| 1201 | inv=false; |
| 1202 | } |
| 1203 | else |
| 1204 | { |
| 1205 | len=abs((int)x2-(int)x1); |
| 1206 | inv=true; |
| 1207 | } |
| 1208 | |
| 1209 | if (y2<y1) { |
| 1210 | SY=-1; |
| 1211 | } else if ( AreSame(deltay, 0.0) ) { |
| 1212 | SY=0; |
| 1213 | } else { |
| 1214 | SY=1; |
| 1215 | } |
| 1216 | |
| 1217 | if (x2<x1) { |
| 1218 | SX=-1; |
| 1219 | } else if ( AreSame(deltax, 0.0) ) { |
| 1220 | SX=0; |
| 1221 | } else { |
| 1222 | SX=1; |
| 1223 | } |
| 1224 | |
| 1225 | x0=x1; y0=y1; |
| 1226 | if (inv) |
| 1227 | SY=(deltay/len); |
| 1228 | else |
| 1229 | SX=(deltax/len); |
| 1230 | |
| 1231 | while(len>0) |
| 1232 | { |
| 1233 | tcol=src->getPixel((int)x0,(int)y0); |
| 1234 | if (tcol) |
| 1235 | { |
| 1236 | const int d = tcol & helper::ColorGroup; |
| 1237 | if(d == Palette::blockOffset(12) || d == Palette::blockOffset(13)) |
| 1238 | { |
| 1239 | //this pixel is ocean |
| 1240 | tcol = Palette::blockOffset(12) + shade + 8; |
| 1241 | } |
| 1242 | else |
| 1243 | { |
| 1244 | const int e = tcol + shade; |
| 1245 | if(e > d + helper::ColorShade) |
| 1246 | tcol = d + helper::ColorShade; |
| 1247 | else tcol = e; |