Example #1
0
  public void render(IGraphics g) {
    if (!Visible) return;

    g.pushClip();
    g.clipRect(WindowX, WindowY, WindowW, WindowH);

    {
      int bx = CMath.cycNum(X, 0, MapW) / CellW;
      int by = CMath.cycNum(Y, 0, MapH) / CellH;
      int dx = CMath.cycNum(X, 0, MapW) % CellW;
      int dy = CMath.cycNum(Y, 0, MapH) % CellH;

      int cpx = WindowX - dx;
      int cpy = WindowY - dy;

      for (int y = 0; y < WindowBH; y++) {
        for (int x = 0; x < WindowBW; x++) {
          Map.renderCell(
              g,
              cpx + x * CellW,
              cpy + y * CellH,
              CMath.cycNum(bx, x, MapBW),
              CMath.cycNum(by, y, MapBH));
        }
      }
    }
    g.popClip();
  }
Example #2
0
 static StringAttribute[] attributesSub(CStringLayer src, int start, int end) {
   int dst_len = end - start;
   ArrayList<StringAttribute> attributes = new ArrayList<StringAttribute>();
   if (src.Attributes != null) {
     for (StringAttribute attr : src.Attributes) {
       attr = new StringAttribute(attr);
       if (CMath.intersectRect(start, 1, end, 1, attr.Start, 1, attr.End, 1)) {
         attributes.add(attr);
         attr.Start -= start;
         attr.End -= start;
         attr.Start = Math.max(attr.Start, 0);
         attr.End = Math.min(attr.End, dst_len);
       }
     }
   }
   return attributes.toArray(new StringAttribute[attributes.size()]);
 }