Blame view

emulateur/epsilon-nofrendo/escher/src/tiled_view.cpp 820 Bytes
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #include <escher/tiled_view.h>
  #include <assert.h>
  
  void TiledView::drawRect(KDContext * ctx, KDRect rect) const {
    KDColor * pixels = tile();
    KDSize size = tileSize();
    KDFrameBuffer tileBuffer(pixels, size);
    KDFrameBufferContext tileContext = KDFrameBufferContext(&tileBuffer);
  
    for (int i=0; i<(rect.width()/size.width()+1); i++) {
      for (int j=0; j<(rect.height()/size.height()+1); j++) {
        KDRect tileRect(
            rect.x() + i*size.width(),
            rect.y() + j*size.height(),
            size.width(), size.height()
            );
        //tileRect = KDRectIntersection(tileRect, rect); // Optional
        KDPoint origin = tileRect.origin().opposite();
        tileContext.setOrigin(origin);
  
        drawTile(&tileContext, tileRect);
  
        ctx->fillRectWithPixels(tileRect, pixels, pixels);
      }
    }
  }