void MainWindow::saveSettings(){ if(fullScreen()) this->showNormal(); QSettings settingsNative; settingsNative.setValue("pos", pos()); settingsNative.setValue("size", size()); settingsNative.setValue("backgroundRed", backgroundColor().red()); settingsNative.setValue("backgroundGreen", backgroundColor().green()); settingsNative.setValue("backgroundBlue", backgroundColor().blue()); settingsNative.setValue("canvasRed", canvasColor().red()); settingsNative.setValue("canvasGreen", canvasColor().green()); settingsNative.setValue("canvasBlue", canvasColor().blue()); settingsNative.setValue("infoRed", infoColor().red()); settingsNative.setValue("infoGreen", infoColor().green()); settingsNative.setValue("infoBlue", infoColor().blue()); QSettings settings(Constants::SETTINGS_FOLDER + "/" + Constants::PLAYER_SETTINGS_FILE, QSettings::IniFormat); settings.setValue("orientation", orientation()); settings.setValue("alwaysOnTop", alwaysOnTop()); settings.setValue("autoScale", autoScale()); settings.setValue("width", width()); settings.setValue("height", height()); settings.setValue("fps", fps()); settings.setValue("scale", scale()); settings.setValue("drawInfos", drawInfos()); if(fullScreen()) this->showFullScreen(); }
static void canvasText(double x, double y, const char *str, double rot, double hadj, const pGEcontext gc, pDevDesc RGD) { canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; if (hadj!=0. || rot != 0.){ double strextent = strlen(str) * 7; /* wild guess that each char is 10px wide */ if (rot!=0.){ fprintf(cGD->fp,"ctx.save(); "); canvasColor(cGD->fp,"fillStyle",gc->col); fprintf(cGD->fp,"ctx.translate(%f,%f); ",x,y); fprintf(cGD->fp,"ctx.rotate(-%f / 180 * Math.PI); ",rot); fprintf(cGD->fp,"ctx.fillText(\"%s\",%f,0); ",str,-strextent*hadj); fprintf(cGD->fp,"ctx.restore();\n"); } else { canvasColor(cGD->fp,"fillStyle",gc->col); fprintf(cGD->fp,"ctx.fillText(\"%s\",%f,%f); ",str,x - strextent*hadj,y); } } else { canvasColor(cGD->fp,"fillStyle",gc->col); fprintf(cGD->fp,"ctx.fillText(\"%s\",%f,%f); ",str,x,y); } #ifdef CANVASDEBUG fprintf(cGD->fp,"//Text(x=%f,y=%f,str=%s,rot=%f,hadj=%f,gc=0x%x,RGD=0x%x)\n",x,y,str,rot,hadj,gc,RGD); #endif }
static void canvasPolygon(int n, double *x, double *y, const pGEcontext gc, pDevDesc RGD) { int i=1; canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; if(n<2) return; canvasSetLineType(cGD,gc); fprintf(cGD->fp,"ctx.beginPath(); ctx.moveTo(%f,%f);\n",x[0],y[0]); while (i<n) { fprintf(cGD->fp,"ctx.lineTo(%f,%f);", x[i], y[i]); i++; } fprintf(cGD->fp,"ctx.closePath(); "); if (CALPHA(gc->fill)) { canvasColor(cGD->fp,"fillStyle",gc->fill); fprintf(cGD->fp,"ctx.fill(); "); } if (CALPHA(gc->col) && gc->lty!=-1) { canvasColor(cGD->fp,"strokeStyle",gc->col); fprintf(cGD->fp,"ctx.stroke(); "); } fprintf(cGD->fp,"\n"); #ifdef CANVASDEBUG { int i=0; fprintf(cGD->fp,"//Polygon(n=%d,x=0x%x,y=0x%x,gc=0x%x,RGD=0x%x)\n\t//points: ",n,x,y,gc,RGD); while(i<n){ fprintf(cGD->fp,"(%.2f,%.2f) ",x[i],y[i]); i++;}; fprintf(cGD->fp,"\n"); } #endif }
void MainWindow::updateCanvasColor(){ float glCanvasColor[3]; glCanvasColor[0] = (float)canvasColor().red() / (float)255; glCanvasColor[1] = (float)canvasColor().green() / (float)255; glCanvasColor[2] = (float)canvasColor().blue() / (float)255; ui.glCanvas->setCanvasColor(glCanvasColor); }
static void canvasRect(double x0, double y0, double x1, double y1, const pGEcontext gc, pDevDesc RGD) { canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; if (CALPHA(gc->fill)){ canvasColor(cGD->fp,"fillStyle",gc->fill); fprintf(cGD->fp,"ctx.fillRect(%f,%f,%f,%f); ",x0,y0,x1-x0,y1-y0); } if (CALPHA(gc->col) && gc->lty!=-1){ canvasSetLineType(cGD,gc); canvasColor(cGD->fp,"strokeStyle",gc->col); fprintf(cGD->fp,"ctx.strokeRect(%f,%f,%f,%f); ",x0,y0,x1-x0,y1-y0); } #ifdef CANVASDEBUG fprintf(cGD->fp,"//Rect(x0=%f,y0=%f,x1=%f,y1=%f,gc=0x%x,RGD=0x%x)\n",x0,y0,x1,y1,gc,RGD); #endif }
static void canvasCircle(double x, double y, double r, const pGEcontext gc, pDevDesc RGD) { canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; fprintf(cGD->fp,"ctx.beginPath();"); fprintf(cGD->fp,"ctx.arc(%f,%f,%f,0,Math.PI*2,true); ", x, y, r); if (CALPHA(gc->fill)){ canvasColor(cGD->fp,"fillStyle",gc->fill); fprintf(cGD->fp,"ctx.fill(); "); } if (CALPHA(gc->col) && gc->lty!=-1){ canvasSetLineType(cGD,gc); canvasColor(cGD->fp,"strokeStyle",gc->col); fprintf(cGD->fp,"ctx.stroke();"); } fprintf(cGD->fp,"\n"); #ifdef CANVASDEBUG fprintf(cGD->fp,"//Circle(x=%f,y=%f,r=%f,gc=0x%x,RGD=0x%x)\n",x,y,r,gc,RGD); /*Rprintf("\tuser coords: x=%f,y=%f\n",fromDeviceX(x,GE_NDC,MGD->RGE),fromDeviceY(y,GE_NDC,MGD->RGE));*/ #endif }
static void canvasLine(double x1, double y1, double x2, double y2, const pGEcontext gc, pDevDesc RGD) { canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; if (CALPHA(gc->col) && gc->lty!=-1){ canvasSetLineType(cGD,gc); canvasColor(cGD->fp,"strokeStyle",gc->col); fprintf(cGD->fp,"ctx.beginPath(); ctx.moveTo(%f,%f); ctx.lineTo(%f,%f); ctx.stroke();\n",x1,y1,x2,y2); } #ifdef CANVASDEBUG fprintf(cGD->fp,"//Line(x0=%f,y0=%f,x1=%f,y1=%f,gc=0x%x,RGD=0x%x)\n",x1,y1,x2,y2,gc,RGD); #endif }
static void canvasNewPage(const pGEcontext gc, pDevDesc RGD) { canvasDesc *cGD = (canvasDesc *)RGD->deviceSpecific; fprintf(cGD->fp,"//NewPage\n"); /* Set background only if we have a color */ if (CALPHA(gc->fill)){ canvasColor(cGD->fp,"fillStyle",gc->fill); fprintf(cGD->fp,"ctx.fillRect(0,0,%f,%f);\n",RGD->right,RGD->bottom); } #ifdef CANVASDEBUG Rprintf("NewPage(gc=0x%x,RGD=0x%x)\n",gc,RGD); #endif }
void Executer::executeCanvasColor(TreeNode* node) { // //qDebug() << "called"; if (!checkParameterQuantity(node, 3, 20000+Token::CanvasColor*100+90) || !checkParameterType(node, Value::Number, 20000+Token::CanvasColor*100+91)) return; emit canvasColor(node->child(0)->value()->number(), node->child(1)->value()->number(), node->child(2)->value()->number()); }