Beispiel #1
0
void graphicsDrawRect(JsGraphics *gfx, short x1, short y1, short x2, short y2) {
  graphicsToDeviceCoordinates(gfx, &x1, &y1);
  graphicsToDeviceCoordinates(gfx, &x2, &y2);
  // rather than writing pixels, we use fillrect - as it is faster
  graphicsFillRectDevice(gfx,x1,y1,x2,y1);
  graphicsFillRectDevice(gfx,x2,y1,x2,y2);
  graphicsFillRectDevice(gfx,x1,y2,x2,y2);
  graphicsFillRectDevice(gfx,x1,y2,x1,y1);
}
Beispiel #2
0
void graphicsFillCircle(JsGraphics *gfx, short x, short y, short rad) {
  graphicsToDeviceCoordinates(gfx, &x, &y);

  int radY = 0;
  int decisionOver2 = 1 - rad;

  while (rad >= radY) {
    graphicsFillRectDevice(gfx, rad + x, radY + y, -rad + x, -radY + y);
    graphicsFillRectDevice(gfx, radY + x, rad + y, -radY + x, -rad + y);
    graphicsFillRectDevice(gfx, -rad + x, radY + y, rad + x, -radY + y);
    graphicsFillRectDevice(gfx, -radY + x, rad + y, radY + x, -rad + y);
    radY++;
    if (decisionOver2 <= 0){
      // Change in decision criterion for radY -> radY+1
      decisionOver2 += 2 * radY + 1;
    }else{
      rad--;
      // Change for radY -> radY+1, rad -> rad-1
      decisionOver2 += 2 * (radY - rad) + 1;
    }
  }
}
Beispiel #3
0
void graphicsClear(JsGraphics *gfx) {
  unsigned int c = gfx->data.fgColor;
  gfx->data.fgColor = gfx->data.bgColor;
  graphicsFillRectDevice(gfx,0,0,(short)(gfx->data.width-1),(short)(gfx->data.height-1));
  gfx->data.fgColor = c;
}
Beispiel #4
0
void graphicsFillRect(JsGraphics *gfx, short x1, short y1, short x2, short y2) {
  graphicsToDeviceCoordinates(gfx, &x1, &y1);
  graphicsToDeviceCoordinates(gfx, &x2, &y2);
  graphicsFillRectDevice(gfx, x1, y1, x2, y2);
}