| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | /* |
| 24 | * |
| 25 | * imagehandler.cpp |
| 26 | * |
| 27 | * the stone rendering part has been coded by Marin Ferecatu - thanks, good job! |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <cmath> |
| 32 | |
| 33 | #include "defines.h"cxx . . $ `<file>/src/defines.h`/ |
| 34 | #include "imagehandler.h"cxx . . $ `<file>/src/board/imagehandler.h`/ |
| 35 | |
| 36 | |
| 37 | #ifdef Q_OS_WIN |
| 38 | #ifndef M_PI |
| 39 | #define M_PI 3.141592653 |
| 40 | #endif //M_PI |
| 41 | double drand48() { return rand()*1.0/RAND_MAX; } |
| 42 | #endif |
| 43 | |
| 44 | |
| 45 | /* |
| 46 | * Static class variables |
| 47 | */ |
| 48 | QPixmapcxx . . $ QPixmap# *ImageHandlercxx . . $ ImageHandler#::woodPixmap1cxx . . $ ImageHandler#woodPixmap1. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 49 | |
| 50 | QPixmapcxx . . $ QPixmap# *ImageHandlercxx . . $ ImageHandler#::tablePixmapcxx . . $ ImageHandler#tablePixmap. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 51 | QListcxx . . $ QList#<QPixmapcxx . . $ QPixmap#> *ImageHandlercxx . . $ ImageHandler#::altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 52 | int ImageHandlercxx . . $ ImageHandler#::classCountercxx . . $ ImageHandler#classCounter. = 0; |
| 53 | |
| 54 | |
| 55 | /* |
| 56 | * Stone rendering code |
| 57 | * Heavily inspired from Jago and CGoban code |
| 58 | * http://www.igoweb.org/~wms/comp/cgoban |
| 59 | * /http://www.rene-grothmann.de/jago/ |
| 60 | */ |
| 61 | |
| 62 | |
| 63 | ImageHandlercxx . . $ ImageHandler#::ImageHandlercxx . . $ ImageHandler#ImageHandler(49f6e7a06ebc5aa8).() |
| 64 | { |
| 65 | // Load the pixmaps |
| 66 | // if (tablePixmap == NULL) |
| 67 | tablePixmapcxx . . $ ImageHandler#tablePixmap. = new QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(":/boardicons/resources/pics/table.png"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 68 | // if (woodPixmap1 == NULL) |
| 69 | woodPixmap1cxx . . $ ImageHandler#woodPixmap1. = new QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(":/boardicons/resources/pics/wood.png"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 70 | /* I wanted to make it look like an old style go manual, but apparently |
| 71 | * this is possible by changing the stone type to "Ugly 2d" and I |
| 72 | * made this little paper graphic with some speckle... but I'll add a |
| 73 | * comment here in case someone else has the same bright idea for a |
| 74 | * "classic" mode */ |
| 75 | //paperPixmap = new QPixmap(":/boardicons/resources/pics/paper.png"); |
| 76 | |
| 77 | // if (tablePixmap == NULL || tablePixmap->isNull()) |
| 78 | // qFatal("Could not load pixmaps."); |
| 79 | |
| 80 | stonePixmapscxx . . $ ImageHandler#stonePixmaps. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 81 | ghostPixmapscxx . . $ ImageHandler#ghostPixmaps. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 82 | smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 83 | #ifdef DONTREDRAWSTONES |
| 84 | stonePixmapsScaled = NULL; |
| 85 | ghostPixmapsScaled = NULL; |
| 86 | smallStonePixmapsScaled = NULL; |
| 87 | #endif //DONTREDRAWSTONES |
| 88 | #define STONEIMAGE_MAXSIZEcxx . . $ `src/board/imagehandler.cpp:88:9`! 400 |
| 89 | painting_buffercxx . . $ ImageHandler#painting_buffer. = new int[STONEIMAGE_MAXSIZEcxx . . $ `src/board/imagehandler.cpp:88:9`!*STONEIMAGE_MAXSIZEcxx . . $ `src/board/imagehandler.cpp:88:9`!]; |
| 90 | |
| 91 | // Init the alternate ghost pixmaps |
| 92 | if (altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) |
| 93 | { |
| 94 | altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps. = new QListcxx . . $ QList#<QPixmapcxx . . $ QPixmap#>();//::QList(); |
| 95 | |
| 96 | QPixmapcxx . . $ QPixmap# alt1 = QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(":/boardicons/resources/pics/alt_ghost_black.png"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 97 | QPixmapcxx . . $ QPixmap# alt2 = QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(":/boardicons/resources/pics/alt_ghost_white.png"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 98 | |
| 99 | if (alt1.isNullcxx . . $ QPixmap#isNull(50ce9a9e25b4a850).() || alt2.isNullcxx . . $ QPixmap#isNull(50ce9a9e25b4a850).()) |
| 100 | qFatalcxx . . $ `<external>/10450329605257866924/qlogging.h:168:9`!("Could not load alt_ghost pixmaps."); |
| 101 | // QList<QPixmap*> list; |
| 102 | |
| 103 | // list.append(alt1); |
| 104 | // list.append(alt2); |
| 105 | QListcxx . . $ QList#<QPointcxx . . $ QPoint#*> hotspotscxx . . $ QList#QList(ced63f7c635d850d).; |
| 106 | // hotspots.append(new QPoint(alt1.width()/2, alt1.height()/2)); |
| 107 | // hotspots.append(new QPoint(alt2.width()/2, alt2.height()/2)); |
| 108 | // altGhostPixmaps = new QList<QPixmap*>::QList(list);//, hotspots); |
| 109 | |
| 110 | altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(alt1); |
| 111 | altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(alt2); |
| 112 | } |
| 113 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(altGhostPixmaps); |
| 114 | |
| 115 | classCountercxx . . $ ImageHandler#classCounter. ++; |
| 116 | |
| 117 | QSettingscxx . . $ QSettings# settingscxx . . $ QSettings#QSettings(749de1b6ae65bddd).; |
| 118 | |
| 119 | isDisplayBoardcxx . . $ ImageHandler#isDisplayBoard. = false; |
| 120 | |
| 121 | stonePixmapscxx . . $ ImageHandler#stonePixmaps. = new QListcxx . . $ QList#<QPixmapcxx . . $ QPixmap#>();//::QList(); |
| 122 | if(preferencescxx . . $ preferences..terr_stone_markcxx . . $ _preferences#terr_stone_mark.) |
| 123 | smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps. = new QListcxx . . $ QList#<QPixmapcxx . . $ QPixmap#>(); |
| 124 | ghostPixmapscxx . . $ ImageHandler#ghostPixmaps. = new QListcxx . . $ QList#<QPixmapcxx . . $ QPixmap#>(); |
| 125 | } |
| 126 | |
| 127 | ImageHandlercxx . . $ ImageHandler#::~cxx . . $ ImageHandler#`~ImageHandler`(ced63f7c635d850d).ImageHandlercxx . . $ ImageHandler#() |
| 128 | { |
| 129 | |
| 130 | classCountercxx . . $ ImageHandler#classCounter. --; |
| 131 | if (classCountercxx . . $ ImageHandler#classCounter. == 0) |
| 132 | { |
| 133 | delete woodPixmap1cxx . . $ ImageHandler#woodPixmap1.; |
| 134 | woodPixmap1cxx . . $ ImageHandler#woodPixmap1. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 135 | |
| 136 | delete tablePixmapcxx . . $ ImageHandler#tablePixmap.; |
| 137 | tablePixmapcxx . . $ ImageHandler#tablePixmap. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 138 | |
| 139 | altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps.->clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 140 | // delete altGhostPixmaps; |
| 141 | altGhostPixmapscxx . . $ ImageHandler#altGhostPixmaps. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 142 | } |
| 143 | |
| 144 | delete stonePixmapscxx . . $ ImageHandler#stonePixmaps.; |
| 145 | delete ghostPixmapscxx . . $ ImageHandler#ghostPixmaps.; |
| 146 | delete smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps.; |
| 147 | #ifdef DONTREDRAWSTONES |
| 148 | delete stonePixmapsScaled; |
| 149 | delete ghostPixmapsScaled; |
| 150 | delete smallStonePixmapsScaled; |
| 151 | #endif //DONTREDRAWSTONES |
| 152 | |
| 153 | delete[] painting_buffercxx . . $ ImageHandler#painting_buffer.; |
| 154 | } |
| 155 | |
| 156 | void ImageHandlercxx . . $ ImageHandler#::icopycxx . . $ ImageHandler#icopy(94bb9eec2cee512d).(int *im, QImagecxx . . $ QImage# &qim, int w, int h) |
| 157 | { |
| 158 | |
| 159 | for (int y = 0; y < h; y++) |
| 160 | { |
| 161 | uintcxx . . $ uint# *p = (uintcxx . . $ uint# *)qim.scanLinecxx . . $ QImage#scanLine(f18dc31a6ecbac56).(y); |
| 162 | for(int x = 0; x < w; x++) |
| 163 | { |
| 164 | p[x] = im[y*h + x]; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | void ImageHandlercxx . . $ ImageHandler#::decideAppearancecxx . . $ ImageHandler#decideAppearance(d2bbad5d533427ea).(WhiteDesccxx . . $ WhiteDesc# *desc, int size) |
| 170 | { |
| 171 | double minStripeW, maxStripeW, theta; |
| 172 | |
| 173 | minStripeW = (double)size / 20.0; |
| 174 | if (minStripeW < 1.5) |
| 175 | minStripeW = 1.5; |
| 176 | maxStripeW = (double)size / 10.0; |
| 177 | if (maxStripeW < 2.5) |
| 178 | maxStripeW = 2.5; |
| 179 | |
| 180 | theta = drand48() * 2.0 * M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!; |
| 181 | desc->cosThetacxx . . $ WhiteDesc#cosTheta. = cos(theta); |
| 182 | desc->sinThetacxx . . $ WhiteDesc#sinTheta. = sin(theta); |
| 183 | desc->stripeWidthcxx . . $ WhiteDesc#stripeWidth. = 1.5*minStripeW + |
| 184 | (drand48() * (maxStripeW - minStripeW)); |
| 185 | |
| 186 | desc->xAddcxx . . $ WhiteDesc#xAdd. = 3*desc->stripeWidthcxx . . $ WhiteDesc#stripeWidth. + |
| 187 | (double)size * 3.0; |
| 188 | |
| 189 | desc->stripeMulcxx . . $ WhiteDesc#stripeMul. = 3.0; |
| 190 | desc->zMulcxx . . $ WhiteDesc#zMul. = drand48() * 650.0 + 70.0; |
| 191 | |
| 192 | } |
| 193 | |
| 194 | double ImageHandlercxx . . $ ImageHandler#::getStripecxx . . $ ImageHandler#getStripe(d9dffde7ddc3be78).(WhiteDesccxx . . $ WhiteDesc# &white, double bright, double z, int x, int y) { |
| 195 | double wBright; |
| 196 | |
| 197 | bright = bright/256.0; |
| 198 | |
| 199 | double wStripeLoc = x*white.cosThetacxx . . $ WhiteDesc#cosTheta. - y*white.sinThetacxx . . $ WhiteDesc#sinTheta. + white.xAddcxx . . $ WhiteDesc#xAdd.; |
| 200 | double wStripeColor = fmod(wStripeLoc + (z * z * z * white.zMulcxx . . $ WhiteDesc#zMul.) * |
| 201 | white.stripeWidthcxx . . $ WhiteDesc#stripeWidth., |
| 202 | white.stripeWidthcxx . . $ WhiteDesc#stripeWidth.) / white.stripeWidthcxx . . $ WhiteDesc#stripeWidth.; |
| 203 | wStripeColor = wStripeColor * white.stripeMulcxx . . $ WhiteDesc#stripeMul. - 0.5; |
| 204 | if (wStripeColor < 0.0) |
| 205 | wStripeColor = -2.0 * wStripeColor; |
| 206 | if (wStripeColor > 1.0) |
| 207 | wStripeColor = 1.0; |
| 208 | wStripeColor = wStripeColor * 0.15 + 0.85; |
| 209 | |
| 210 | if (bright < 0.95) |
| 211 | wBright = bright*wStripeColor; |
| 212 | else |
| 213 | wBright = bright*sqrt(sqrt(wStripeColor)); |
| 214 | |
| 215 | if (wBright > 255) |
| 216 | wBright = 255; |
| 217 | if (wBright < 0) |
| 218 | wBright = 0; |
| 219 | |
| 220 | return wBright*255; |
| 221 | |
| 222 | } |
| 223 | |
| 224 | void ImageHandlercxx . . $ ImageHandler#::paintBlackStonecxx . . $ ImageHandler#paintBlackStone(4e9e9c8a28d6ae02). (QImagecxx . . $ QImage# &bi, int d, int stone_render) |
| 225 | { |
| 226 | const double pixel=0.8;//,shadow=0.99; |
| 227 | |
| 228 | |
| 229 | bool Alias=true; |
| 230 | |
| 231 | // these are the images |
| 232 | int i, j, g,g1,g2, k; |
| 233 | double di, dj, d2=(double)d/2.0-5e-1, r=d2-2e-1, f=sqrt(3.0); |
| 234 | double x, y, z, xr,xr1, xr2, xg1,xg2,hh; |
| 235 | |
| 236 | k=0; |
| 237 | |
| 238 | bool smallerstones = false; |
| 239 | if (smallerstones) r-=1; |
| 240 | |
| 241 | for (i=0; i<d; i++) |
| 242 | for (j=0; j<d; j++) { |
| 243 | di=i-d2; dj=j-d2; |
| 244 | hh=r-sqrt(di*di+dj*dj); |
| 245 | if (hh>=0) |
| 246 | { |
| 247 | if (stone_render !=1) |
| 248 | { |
| 249 | z=r*r-di*di-dj*dj; |
| 250 | if (z>0) z=sqrt(z)*f; |
| 251 | else z=0; |
| 252 | x=di; y=dj; |
| 253 | xr=sqrt(6*(x*x+y*y+z*z)); |
| 254 | xr1=(2*z-x+y)/xr; |
| 255 | //xr2=(1.6*z+x+1.75*y)/xr; |
| 256 | xr2=(2*z+x-y)/xr; |
| 257 | |
| 258 | if (xr1>0.9) xg1=(xr1-0.9)*10; |
| 259 | else xg1=0; |
| 260 | //if (xr2>1) xg2=(xr2-1)*10; |
| 261 | if (xr2>0.96) xg2=(xr2-0.96)*10; |
| 262 | else xg2=0; |
| 263 | |
| 264 | //random = drand48(); |
| 265 | |
| 266 | g1=(int)(5+10*drand48() + 10*xr1 + xg1*140); |
| 267 | g2=(int)(10+10* xr2+xg2*160); |
| 268 | g=(g1 > g2 ? g1 : g2); |
| 269 | //g=(int)1/ (1/g1 + 1/g2); |
| 270 | |
| 271 | if (hh>pixel || !Alias) { |
| 272 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=(255<<24)|(g<<16)|(g<<8)|g; |
| 273 | } |
| 274 | else { |
| 275 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(hh/pixel*255)<<24)|(g<<16)|(g<<8)|g; |
| 276 | } |
| 277 | |
| 278 | } |
| 279 | else //code for flat stones |
| 280 | { |
| 281 | g=0; |
| 282 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(255)<<24)|(g<<16)|(g<<8)|g; |
| 283 | } |
| 284 | } |
| 285 | else painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=0; |
| 286 | k++; |
| 287 | |
| 288 | } |
| 289 | |
| 290 | // now copy the result in QImages |
| 291 | icopycxx . . $ ImageHandler#icopy(94bb9eec2cee512d).(painting_buffercxx . . $ ImageHandler#painting_buffer., bi, d, d); |
| 292 | } |
| 293 | |
| 294 | // shadow under stones |
| 295 | void ImageHandlercxx . . $ ImageHandler#::paintShadowStonecxx . . $ ImageHandler#paintShadowStone(1cbfcdfc6ad5b986). (QImagecxx . . $ QImage# &si, int d) { |
| 296 | |
| 297 | //const double pixel=0.8,shadow=0.99; |
| 298 | |
| 299 | // these are the images |
| 300 | int i, j, k; |
| 301 | double di, dj, d2=(double)d/2.0-5e-1, r=d2-2e-1; |
| 302 | double hh; |
| 303 | |
| 304 | k=0; |
| 305 | |
| 306 | bool smallerstones = false; |
| 307 | if (smallerstones) r-=1; |
| 308 | |
| 309 | for (i=0; i<d; i++) |
| 310 | for (j=0; j<d; j++) { |
| 311 | di=i-d2; dj=j-d2; |
| 312 | hh=r-sqrt(di*di+dj*dj); |
| 313 | if (hh>=0) { |
| 314 | hh=2*hh/r ; |
| 315 | if (hh> 1) hh=1; |
| 316 | |
| 317 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(255*hh)<<24)|(1<<16)|(1<<8)|(1); |
| 318 | } |
| 319 | else painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=0; |
| 320 | k++; |
| 321 | |
| 322 | } |
| 323 | |
| 324 | // now copy the result in QImages |
| 325 | icopycxx . . $ ImageHandler#icopy(94bb9eec2cee512d).(painting_buffercxx . . $ ImageHandler#painting_buffer., si, d, d); |
| 326 | } |
| 327 | |
| 328 | // shaded white stones |
| 329 | void ImageHandlercxx . . $ ImageHandler#::paintWhiteStonecxx . . $ ImageHandler#paintWhiteStone(4e9e9c8a28d6ae02). (QImagecxx . . $ QImage# &wi, int d, int stone_render)//bool stripes ) { |
| 330 | { |
| 331 | WhiteDesccxx . . $ WhiteDesc# desc; |
| 332 | decideAppearancecxx . . $ ImageHandler#decideAppearance(d2bbad5d533427ea).(&desc, d); |
| 333 | |
| 334 | // the angle from which the dim starts (measured to the light direction = pi/4) |
| 335 | // alpha should be in (0, pi) |
| 336 | const double ALPHA = M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!/4; |
| 337 | // how big the dim is (should be < d/2) |
| 338 | const double STRIPE = d/5.0; |
| 339 | |
| 340 | double theta; |
| 341 | const double pixel=0.8;//, shadow=0.99; |
| 342 | |
| 343 | bool Alias=true; |
| 344 | |
| 345 | // these are the images |
| 346 | int i, j, g, g1,g2,k; |
| 347 | double di, dj, d2=(double)d/2.0-5e-1, r=d2-2e-1, f=sqrt(3.0); |
| 348 | double x, y, z, xr, xr1, xr2, xg1,xg2, hh; |
| 349 | |
| 350 | k=0; |
| 351 | |
| 352 | bool smallerstones = false; |
| 353 | if (smallerstones) r-=1; |
| 354 | |
| 355 | for (i=0; i<d; i++) |
| 356 | for (j=0; j<d; j++) { |
| 357 | di=i-d2; dj=j-d2; |
| 358 | hh=r-sqrt(di*di+dj*dj); |
| 359 | if (hh>=0) |
| 360 | { |
| 361 | if (stone_render != 1) |
| 362 | { |
| 363 | z=r*r-di*di-dj*dj; |
| 364 | if (z>0) z=sqrt(z)*f; |
| 365 | else z=0; |
| 366 | x=di; y=dj; |
| 367 | xr=sqrt(6*(x*x+y*y+z*z)); |
| 368 | xr1=(2*z-x+y)/xr; |
| 369 | xr2=(2*z+x-y)/xr; |
| 370 | |
| 371 | //#define WHITE_SHINE_START 0.9 |
| 372 | //#define WHITE_SHINE_END 0.92 |
| 373 | #define WHITE_SHINE_STARTcxx . . $ `src/board/imagehandler.cpp:373:9`! 0.9795 |
| 374 | #define WHITE_SHINE_ENDcxx . . $ `src/board/imagehandler.cpp:374:9`! 0.98 |
| 375 | if (xr1>WHITE_SHINE_STARTcxx . . $ `src/board/imagehandler.cpp:373:9`!) xg1=(xr1-WHITE_SHINE_STARTcxx . . $ `src/board/imagehandler.cpp:373:9`!)*10; |
| 376 | else xg1=0; |
| 377 | |
| 378 | if (xr2>WHITE_SHINE_ENDcxx . . $ `src/board/imagehandler.cpp:374:9`!) xg2=(xr2-WHITE_SHINE_ENDcxx . . $ `src/board/imagehandler.cpp:374:9`!)*10; |
| 379 | else xg2=0; |
| 380 | //#define WHITENESS 200 |
| 381 | #define WHITENESScxx . . $ `src/board/imagehandler.cpp:381:9`! 235 |
| 382 | //#define WHITENESS_SHINE 10 |
| 383 | #define WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`! 5 |
| 384 | g2=(int)(WHITENESScxx . . $ `src/board/imagehandler.cpp:381:9`!+WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`!* xr2+xg2*45); |
| 385 | //g=(g1 > g2 ? g1 : g2); |
| 386 | |
| 387 | theta = atan2(double(j-d/2), double(i-d/2)) + M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`! - M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!/4 + M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!/2; |
| 388 | bool stripeband = theta > ALPHA && theta < 2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!-ALPHA; |
| 389 | |
| 390 | if (theta > M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!) |
| 391 | theta = (2*M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!-theta); |
| 392 | |
| 393 | double stripe = STRIPE*sin((M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!/2)*(theta-ALPHA)/(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!-ALPHA)); |
| 394 | if (stripe < 1) stripe = 1; |
| 395 | |
| 396 | double g1min=(int)(0+WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`!*xr1+xg1*45), g2min=(int)(0+WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`!*xr2+xg2*45); |
| 397 | double g1max=(int)(WHITENESScxx . . $ `src/board/imagehandler.cpp:381:9`!+WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`!*xr1+xg1*45), g2max=(int)(WHITENESScxx . . $ `src/board/imagehandler.cpp:381:9`!+WHITENESS_SHINEcxx . . $ `src/board/imagehandler.cpp:383:9`!* xr2+xg2*45);; |
| 398 | g1min = g1max - (g1max-g1min)*(1-exp(-1*(theta-ALPHA)/(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!-ALPHA))); |
| 399 | g2min = g2max - (g2max-g2min)*(1-exp(-1*(theta-ALPHA)/(M_PIcxx . . $ `<external>/11263917310783833665/math.h:1121:10`!-ALPHA))); |
| 400 | |
| 401 | if ((hh < STRIPE) && hh > pixel && stripeband) |
| 402 | { |
| 403 | |
| 404 | if (hh > stripe) g1 = (int)g1max; |
| 405 | else g1 = int(g1min + (g1max-g1min)*sqrt(hh/stripe)); |
| 406 | |
| 407 | if (hh > stripe) g2 = (int)g2max; |
| 408 | else g2 = int(g2min + (g2max-g2min)*sqrt(hh/stripe)); |
| 409 | |
| 410 | g=(g1 > g2 ? g1 : g2); |
| 411 | |
| 412 | if (stone_render == 0) //stripes) |
| 413 | g = (int)getStripecxx . . $ ImageHandler#getStripe(d9dffde7ddc3be78).(desc, g, xr1/7.0, i, j); |
| 414 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=(255<<24)|(g<<16)|((g)<<8)|(g); |
| 415 | } |
| 416 | else if (( hh > pixel ) || (!Alias) ) |
| 417 | { |
| 418 | //g1=(int)(190+10*drand48()+10*xr1+xg1*45); |
| 419 | |
| 420 | g=(int)(g1max > g2max ? g1max : g2max); |
| 421 | |
| 422 | if (stone_render == 0)//stripes) |
| 423 | g = (int)getStripecxx . . $ ImageHandler#getStripe(d9dffde7ddc3be78).(desc, g, xr1/7.0, i, j); |
| 424 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=(255<<24)|(g<<16)|((g)<<8)|(g); |
| 425 | } |
| 426 | else { |
| 427 | |
| 428 | g1=(int)(stripeband ? g1min : g1max); |
| 429 | g2=(int)(stripeband ? g2min : g2max); |
| 430 | |
| 431 | g=(g1 > g2 ? g1 : g2); |
| 432 | |
| 433 | if (stone_render == 0)//stripes) |
| 434 | g = (int)getStripecxx . . $ ImageHandler#getStripe(d9dffde7ddc3be78).(desc, g, xr1/7.0, i, j); |
| 435 | |
| 436 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(hh/pixel*255)<<24)|(g<<16)|(g<<8)|g; |
| 437 | } |
| 438 | } |
| 439 | else // Code for flat stones |
| 440 | { |
| 441 | // draws a black circle for 2D stones |
| 442 | if ((hh>=-1)&&(hh<=1)) |
| 443 | { |
| 444 | g=0; |
| 445 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(255)<<24)|(g<<16)|(g<<8)|g; |
| 446 | } |
| 447 | else if (hh>0) |
| 448 | { |
| 449 | g=255; |
| 450 | painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=((int)(255)<<24)|(g<<16)|(g<<8)|g; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | } |
| 455 | else painting_buffercxx . . $ ImageHandler#painting_buffer.[k]=0; |
| 456 | k++; |
| 457 | } |
| 458 | |
| 459 | // now copy the result in QImages |
| 460 | icopycxx . . $ ImageHandler#icopy(94bb9eec2cee512d).(painting_buffercxx . . $ ImageHandler#painting_buffer., wi, d, d); |
| 461 | } |
| 462 | |
| 463 | |
| 464 | QPixmapcxx . . $ QPixmap# *ImageHandlercxx . . $ ImageHandler#::getBoardPixmapcxx . . $ ImageHandler#getBoardPixmap(238698adec9265ce).(QStringcxx . . $ QString# filename) |
| 465 | { |
| 466 | if (! QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d). (QStringcxx . . $ QString#QString(132dd6869045752b).(filename))) |
| 467 | { |
| 468 | if(filename !=cxx . . $ `operator!=`(5bc2975d2d751687). QStringcxx . . $ QString#QString(ced63f7c635d850d).()) |
| 469 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't open board picture: \"%s\"", filename.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 470 | return woodPixmap1cxx . . $ ImageHandler#woodPixmap1.; |
| 471 | } |
| 472 | |
| 473 | QPixmapcxx . . $ QPixmap# *p = new QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(filename) ; |
| 474 | |
| 475 | if (p->isNullcxx . . $ QPixmap#isNull(50ce9a9e25b4a850).()) |
| 476 | return woodPixmap1cxx . . $ ImageHandler#woodPixmap1.; |
| 477 | else |
| 478 | return p; |
| 479 | |
| 480 | } |
| 481 | |
| 482 | QPixmapcxx . . $ QPixmap# *ImageHandlercxx . . $ ImageHandler#::getTablePixmapcxx . . $ ImageHandler#getTablePixmap(238698adec9265ce).(QStringcxx . . $ QString# filename) |
| 483 | { |
| 484 | if (! QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d). (QStringcxx . . $ QString#QString(132dd6869045752b).(filename))) |
| 485 | { |
| 486 | if(filename !=cxx . . $ `operator!=`(5bc2975d2d751687). QStringcxx . . $ QString#QString(ced63f7c635d850d).()) |
| 487 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't open table picture: \"%s\"", filename.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 488 | return tablePixmapcxx . . $ ImageHandler#tablePixmap.; |
| 489 | } |
| 490 | |
| 491 | QPixmapcxx . . $ QPixmap# *p = new QPixmapcxx . . $ QPixmap#QPixmap(dec4543235ec9b46).(filename) ; |
| 492 | |
| 493 | if (p->isNullcxx . . $ QPixmap#isNull(50ce9a9e25b4a850).()) |
| 494 | return tablePixmapcxx . . $ ImageHandler#tablePixmap.; |
| 495 | else |
| 496 | return p; |
| 497 | |
| 498 | } |
| 499 | |
| 500 | void ImageHandlercxx . . $ ImageHandler#::setDisplaycxx . . $ ImageHandler#setDisplay(b45ddcbc8423892c).(bool isDisplay) |
| 501 | { |
| 502 | isDisplayBoardcxx . . $ ImageHandler#isDisplayBoard. = isDisplay; |
| 503 | } |
| 504 | |
| 505 | #ifdef DONTREDRAWSTONES |
| 506 | void ImageHandler::generateStonePixmaps(int size)//, bool smallerStones) |
| 507 | #else |
| 508 | void ImageHandlercxx . . $ ImageHandler#::setSquareSizecxx . . $ ImageHandler#setSquareSize(d4f767463ce0a6b3).(int size) |
| 509 | #endif //DONTREDRAWSTONES |
| 510 | { |
| 511 | QSettingscxx . . $ QSettings# settingscxx . . $ QSettings#QSettings(749de1b6ae65bddd).; |
| 512 | |
| 513 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(stonePixmaps); |
| 514 | Q_CHECK_PTRcxx . . $ `<external>/15045578679651060896/qglobal.h:890:11`!(ghostPixmaps); |
| 515 | |
| 516 | int stone_look = ( isDisplayBoardcxx . . $ ImageHandler#isDisplayBoard. ? 1 : settings.valuecxx . . $ QSettings#value(12a1b1749da49362).("STONES_LOOK"cxx . . $ QString#QString(85c52e162fed56f9).).toIntcxx . . $ QVariant#toInt(5bd9a3493f6a7a21).()); |
| 517 | int smallstones_size; |
| 518 | |
| 519 | stonePixmapscxx . . $ ImageHandler#stonePixmaps.->clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 520 | ghostPixmapscxx . . $ ImageHandler#ghostPixmaps.->clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 521 | if(preferencescxx . . $ preferences..terr_stone_markcxx . . $ _preferences#terr_stone_mark.) |
| 522 | { |
| 523 | smallstones_size = (int)(size / SMALL_STONE_TERR_DIVISORcxx . . $ `src/defines.h:45:9`!); |
| 524 | smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps.->clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 525 | } |
| 526 | |
| 527 | //repaint black stones |
| 528 | QImagecxx . . $ QImage# ib = QImagecxx . . $ QImage#QImage(bf9e47a5364bf007).(size, size, QImagecxx . . $ QImage#::Format_ARGB32cxx . . $ QImage#Format_ARGB32.); |
| 529 | QImagecxx . . $ QImage# iwscxx . . $ QImage#QImage(ced63f7c635d850d).; |
| 530 | // ib.setAlphaBuffer(true); |
| 531 | paintBlackStonecxx . . $ ImageHandler#paintBlackStone(4e9e9c8a28d6ae02).(ib, size, stone_look); |
| 532 | //stonePixmaps->append(QPixmap::fromImage(ib));//, |
| 533 | // Qt::PreferDither | |
| 534 | // Qt::DiffuseAlphaDither | |
| 535 | // Qt::DiffuseDither) ); |
| 536 | // stonePixmaps->image(0)->setOffset(size/2, size/2); |
| 537 | stonePixmapscxx . . $ ImageHandler#stonePixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(ib, |
| 538 | Qtcxx . . $ Qt/::PreferDithercxx . . $ Qt/PreferDither. |cxx . . $ Qt/`operator|`(7bee37f572288d31). |
| 539 | Qtcxx . . $ Qt/::DiffuseAlphaDithercxx . . $ Qt/DiffuseAlphaDither. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). |
| 540 | Qtcxx . . $ Qt/::DiffuseDithercxx . . $ Qt/DiffuseDither.) ); |
| 541 | |
| 542 | QImagecxx . . $ QImage# gbcxx . . $ QImage#QImage(9ff1334af0ec69dd).(ib); |
| 543 | ghostImagecxx . . $ ImageHandler#ghostImage(704f3a01150ff264).(&gb); |
| 544 | ghostPixmapscxx . . $ ImageHandler#ghostPixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(gb)); |
| 545 | |
| 546 | //small black stone |
| 547 | if(preferencescxx . . $ preferences..terr_stone_markcxx . . $ _preferences#terr_stone_mark.) |
| 548 | { |
| 549 | QImagecxx . . $ QImage# ibs = QImagecxx . . $ QImage#QImage(bf9e47a5364bf007).(smallstones_size, smallstones_size, QImagecxx . . $ QImage#::Format_ARGB32cxx . . $ QImage#Format_ARGB32.); |
| 550 | paintBlackStonecxx . . $ ImageHandler#paintBlackStone(4e9e9c8a28d6ae02).(ibs, smallstones_size, stone_look); |
| 551 | smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(ibs)); |
| 552 | |
| 553 | // small white stones |
| 554 | iws =cxx . . $ QImage#`operator=`(e6308d6f8c10e1d2). QImagecxx . . $ QImage#QImage(bf9e47a5364bf007).(smallstones_size, smallstones_size, QImagecxx . . $ QImage#::Format_ARGB32cxx . . $ QImage#Format_ARGB32.); |
| 555 | } |
| 556 | // white stones |
| 557 | QImagecxx . . $ QImage# iw1 = QImagecxx . . $ QImage#QImage(bf9e47a5364bf007).(size, size, QImagecxx . . $ QImage#::Format_ARGB32cxx . . $ QImage#Format_ARGB32.); |
| 558 | |
| 559 | |
| 560 | |
| 561 | for (int i=1 ; i<=WHITE_STONES_NBcxx . . $ `src/defines.h:40:9`!; i++) |
| 562 | { |
| 563 | paintWhiteStonecxx . . $ ImageHandler#paintWhiteStone(4e9e9c8a28d6ae02).(iw1, size, stone_look); |
| 564 | //stonePixmaps->append(QPixmap::fromImage(iw1)); |
| 565 | stonePixmapscxx . . $ ImageHandler#stonePixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(iw1, |
| 566 | Qtcxx . . $ Qt/::PreferDithercxx . . $ Qt/PreferDither. |cxx . . $ Qt/`operator|`(7bee37f572288d31). |
| 567 | Qtcxx . . $ Qt/::DiffuseAlphaDithercxx . . $ Qt/DiffuseAlphaDither. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). |
| 568 | Qtcxx . . $ Qt/::DiffuseDithercxx . . $ Qt/DiffuseDither.) ); |
| 569 | QImagecxx . . $ QImage# gw1cxx . . $ QImage#QImage(9ff1334af0ec69dd).(iw1); |
| 570 | ghostImagecxx . . $ ImageHandler#ghostImage(704f3a01150ff264).(&gw1); |
| 571 | ghostPixmapscxx . . $ ImageHandler#ghostPixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(gw1)); |
| 572 | |
| 573 | if(preferencescxx . . $ preferences..terr_stone_markcxx . . $ _preferences#terr_stone_mark.) |
| 574 | { |
| 575 | paintWhiteStonecxx . . $ ImageHandler#paintWhiteStone(4e9e9c8a28d6ae02).(iws, smallstones_size, stone_look); |
| 576 | smallStonePixmapscxx . . $ ImageHandler#smallStonePixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(iws)); |
| 577 | |
| 578 | /*smallStonePixmaps->append(QPixmap::fromImage(iws, |
| 579 | Qt::PreferDither | |
| 580 | Qt::DiffuseAlphaDither | |
| 581 | Qt::DiffuseDither) );*/ |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | // shadow |
| 586 | QImagecxx . . $ QImage# is = QImagecxx . . $ QImage#QImage(bf9e47a5364bf007).(size, size, QImagecxx . . $ QImage#::Format_ARGB32cxx . . $ QImage#Format_ARGB32.); |
| 587 | |
| 588 | if (stone_look == 0) |
| 589 | paintShadowStonecxx . . $ ImageHandler#paintShadowStone(1cbfcdfc6ad5b986).(is, size); |
| 590 | else |
| 591 | is.fillcxx . . $ QImage#fill(cb2f890c2fdad230).(0); |
| 592 | |
| 593 | //stonePixmaps->append(QPixmap::fromImage(is)); |
| 594 | stonePixmapscxx . . $ ImageHandler#stonePixmaps.->appendcxx . . $ QList#append(77d9f17553126ecb).(QPixmapcxx . . $ QPixmap#::fromImagecxx . . $ QPixmap#fromImage(e89e6101063912f).(is, |
| 595 | Qtcxx . . $ Qt/::PreferDithercxx . . $ Qt/PreferDither. |cxx . . $ Qt/`operator|`(7bee37f572288d31). |
| 596 | Qtcxx . . $ Qt/::DiffuseAlphaDithercxx . . $ Qt/DiffuseAlphaDither. |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). |
| 597 | Qtcxx . . $ Qt/::DiffuseDithercxx . . $ Qt/DiffuseDither.) ); |
| 598 | } |
| 599 | |
| 600 | #ifdef DONTREDRAWSTONES |
| 601 | void ImageHandler::rescale(int size) |
| 602 | { |
| 603 | int i; |
| 604 | QPixmap p; |
| 605 | int smallstones_size; |
| 606 | if(preferences.terr_stone_mark) |
| 607 | smallstones_size = (int)(size / SMALL_STONE_TERR_DIVISOR); |
| 608 | |
| 609 | for(i = 0; i < stonePixmaps->size(); i++) |
| 610 | { |
| 611 | p = (*stonePixmaps)[i].scaled(size, size); |
| 612 | (*stonePixmapsScaled)[i] = p; |
| 613 | } |
| 614 | if(preferences.terr_stone_mark) |
| 615 | { |
| 616 | for(i = 0; i < smallStonePixmaps->size(); i++) |
| 617 | { |
| 618 | p = (*smallStonePixmaps)[i].scaled(smallstones_size, smallstones_size); |
| 619 | (*smallStonePixmapsScaled)[i] = p; |
| 620 | } |
| 621 | } |
| 622 | for(i = 0; i < ghostPixmaps->size(); i++) |
| 623 | { |
| 624 | p = (*ghostPixmaps)[i].scaled(size, size); |
| 625 | (*ghostPixmapsScaled)[i] = p; |
| 626 | } |
| 627 | } |
| 628 | #endif //DONTREDRAWSTONES |
| 629 | |
| 630 | void ImageHandlercxx . . $ ImageHandler#::ghostImagecxx . . $ ImageHandler#ghostImage(704f3a01150ff264).(QImagecxx . . $ QImage# *img) |
| 631 | { |
| 632 | |
| 633 | int w = img->widthcxx . . $ QImage#width(455f465bc33b4cdf).(), |
| 634 | h = img->heightcxx . . $ QImage#height(455f465bc33b4cdf).(), |
| 635 | x, y; |
| 636 | |
| 637 | for (y=0; y<h; y++) |
| 638 | { |
| 639 | uintcxx . . $ uint# *line = (uintcxx . . $ uint#*)img->scanLinecxx . . $ QImage#scanLine(f18dc31a6ecbac56).(y); |
| 640 | for (x=0; x<w; x++) |
| 641 | { |
| 642 | //if ((x%2 && !(y%2)) || (!(x%2) && y%2)) |
| 643 | { |
| 644 | line[x] = qRgbacxx . . $ qRgba(7a6d2d8711beacc4).(qRedcxx . . $ qRed(4c679297bf94b9eb).(line[x]), qGreencxx . . $ qGreen(4c679297bf94b9eb).(line[x]), qBluecxx . . $ qBlue(4c679297bf94b9eb).(line[x]), (line[x] ? 125 : 0)); |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | } |