Example #1
0
void graphics_fill_rect(GContext *ctx, GRect rect, uint8_t corner_radius, GCornerMask corner_mask) {
    //TODO: corner_mask
    GPoint topOffset=getTopOffset ();
    if (corner_radius>0)
        roundedBoxColor (getTopScreen(),topOffset.x+rect.origin.x,topOffset.y+rect.origin.y,topOffset.x+rect.origin.x+rect.size.w,topOffset.y+rect.origin.y+rect.size.h,corner_radius,getRawColor(ctx->fill_color));
    else
        boxColor (getTopScreen(),topOffset.x+rect.origin.x,topOffset.y+rect.origin.y,topOffset.x+rect.origin.x+rect.size.w,topOffset.y+rect.origin.y+rect.size.h,getRawColor(ctx->fill_color));
}
Example #2
0
void gpath_draw_filled(GContext *ctx, GPath *path) {
    Sint16* pointsX,* pointsY;
    _gpath_to_sdl (path,&pointsX,&pointsY);
    filledPolygonColor(getTopScreen(), pointsX, pointsY, path->num_points, getRawColor(ctx->fill_color));
    free(pointsX);
    free(pointsY);
}
Example #3
0
void gpath_draw_outline(GContext *ctx, GPath *path) {
    Sint16* pointsX,* pointsY;
    _gpath_to_sdl (path,&pointsX,&pointsY);
    polygonColor(getTopScreen(), pointsX, pointsY, path->num_points, getRawColor(ctx->stroke_color));
    free(pointsX);
    free(pointsY);
}
Example #4
0
void Screen::blitTopScreen() {
	SDL_FillRect(screen, NULL, SDL_MapRGB(getTopScreen()->format, 0, 0, 0));
	if(zoom == 1) SDL_BlitSurface(topScreen, NULL, screen, NULL);
	else {
		SDL_BlitSurface(topScreenRot, NULL, screen, &rectRot);
	}
	SDL_Flip(screen);
}
Example #5
0
void scroll_layer_shadow_layer_update_func (Layer* me,GContext* ctx) {
    ScrollLayer* scroll_layer=(ScrollLayer*)me->parent;
    SDL_Surface* scroll_shadow=getSimulatorImage(SIM_IMG_SCROLL_SHADOW);
    GPoint topOffset=getTopOffset();
    SDL_Surface* screen=getTopScreen ();
    GPoint offset=scroll_layer_get_content_offset (scroll_layer);
    GSize size=scroll_layer_get_content_size (scroll_layer);
    GSize frameSize=me->frame.size;
    SDL_Rect src,dst;
    if (offset.y<0) {
        src=(SDL_Rect){0,15,144,15};
        dst=(SDL_Rect){topOffset.x,topOffset.y,144,15};
        SDL_gfxBlitRGBA(scroll_shadow,&src,screen,&dst);
    }
    if (offset.y-((Layer*)scroll_layer)->frame.size.h!=-size.h) {
        src=(SDL_Rect){0,0,144,15};
        dst=(SDL_Rect){topOffset.x,topOffset.y+frameSize.h-15,144,15};
        SDL_gfxBlitRGBA(scroll_shadow,&src,screen,&dst);
    }
}
Example #6
0
void Screen::flipScreen() {
	SDL_Flip(getTopScreen());
}
Example #7
0
void Screen::fillScreen() {
	SDL_FillRect(getTopScreen(), NULL, SDL_MapRGB(getTopScreen()->format, 0, 0, 0));
}
Example #8
0
void graphics_draw_round_rect(GContext *ctx, GRect rect, int radius) {
    GPoint topOffset=getTopOffset ();
    roundedRectangleColor(getTopScreen(),topOffset.x+rect.origin.x,topOffset.y+rect.origin.y,topOffset.x+rect.origin.x+rect.size.w,topOffset.y+rect.origin.y+rect.size.h,radius,getRawColor(ctx->stroke_color));
}
Example #9
0
void graphics_fill_circle(GContext *ctx, GPoint p, int radius) {
    GPoint topOffset=getTopOffset ();
    filledCircleColor(getTopScreen(), topOffset.x+p.x, topOffset.y+p.y, radius, getRawColor(ctx->fill_color));
}
Example #10
0
void graphics_draw_circle(GContext *ctx, GPoint p, int radius) {
    GPoint topOffset=getTopOffset ();
    circleColor(getTopScreen(), topOffset.x+p.x, topOffset.y+p.y, radius, getRawColor(ctx->stroke_color));
}
Example #11
0
void graphics_draw_line(GContext *ctx, GPoint p0, GPoint p1) {
    GPoint topOffset=getTopOffset ();
    lineColor(getTopScreen(), topOffset.x+p0.x, topOffset.y+p0.y, topOffset.x+p1.x, topOffset.y+p1.y, getRawColor(ctx->stroke_color));
}
Example #12
0
void graphics_draw_pixel(GContext *ctx, GPoint point) {
    GPoint topOffset=getTopOffset ();
    pixelColor(getTopScreen(), topOffset.x+point.x, topOffset.y+point.y, getRawColor(ctx->stroke_color));
}
Example #13
0
//#verify #verify #verify !!!!!!!!!!
void graphics_text_draw(GContext *ctx, const char *text, const GFont font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, const GTextLayoutCacheRef layout) {
    char buffer [256]; //SHIT!! I need to mark the end of the string but I can't use the original parameter...
    TextWrapper textWrapper=(overflow_mode==GTextOverflowModeWordWrap?wrap_words:wrap_points);
    int lineHeight=0,usedHeight=0;
    SDL_Surface* lineSurface,*lineSurfaceTemp;
    SDL_Surface* textSurface=SDL_CreateRGBSurface (SDL_SWSURFACE|SDL_SRCALPHA,box.size.w,box.size.h,32,0xff000000,0x00ff0000,0x0000ff00,0x000000ff);
    SDL_FillRect (textSurface,0,0);
    SDL_Surface* pointsSurface=0; //this will only be initalised when it's needed
    SDL_Rect dstRect,srcRect;
    SDL_Color color=getColor(ctx->text_color);
    GPoint topOffset=getTopOffset ();
    _WrapResult wrap;
    if (text==0)
        return;
    while (*text!=0&&usedHeight<box.size.h) {
        wrap=textWrapper (text,box.size.w,font);
        memcpy(buffer,text,wrap.lineLen);
        buffer[wrap.lineLen]=0;
        text=wrap.newString;
        if (wrap.lineLen==0) {
            usedHeight+=lineHeight;
            continue;
        }
        lineSurfaceTemp=TTF_RenderText_Solid ((TTF_Font*)font,buffer,color);
        if (lineSurfaceTemp==0) {
            printf("[WARN] TTF_RenderText_Solid: %s\n",TTF_GetError ());
            return;
        }
        lineSurface=SDL_ConvertSurface(lineSurfaceTemp,textSurface->format,SDL_SWSURFACE|SDL_SRCALPHA);
        SDL_FreeSurface(lineSurfaceTemp);
        if (lineHeight==0)
            lineHeight=lineSurface->h;
        //prepare blitting
        srcRect=((SDL_Rect) {
            0,0,lineSurface->w,lineSurface->h
        });
        if (srcRect.h+usedHeight>box.size.h)
            srcRect.h=box.size.h-usedHeight;
        dstRect=srcRect;
        dstRect.y=usedHeight;
        //set text alignment
        if (alignment==GTextAlignmentCenter)
            dstRect.x=box.size.w/2-(dstRect.w+wrap.addPoints)/2;
        else if (alignment==GTextAlignmentRight)
            dstRect.x=box.size.w-(dstRect.w+wrap.addPoints);
        //else
        //  srcRect.x=0;
        //blit line to text
        SDL_gfxBlitRGBA(lineSurface,&srcRect,textSurface,&dstRect);
        SDL_FreeSurface(lineSurface);
        if (wrap.addPoints>0) {
            if (pointsSurface==0) {
                pointsSurface=TTF_RenderText_Solid ((TTF_Font*)font,"...",color);
                if (pointsSurface==0) {
                    printf("[WARN] TTF_RenderText_Solid: %s\n",TTF_GetError ());
                    return;
                }
            }
            srcRect.x=0;
            srcRect.w=pointsSurface->w;
            dstRect.x+=dstRect.w;
            dstRect.w=pointsSurface->w;
            SDL_BlitSurface(pointsSurface,&srcRect,textSurface,&dstRect);
        }
        usedHeight+=lineHeight;
    }
    srcRect=((SDL_Rect) {
        0,0,box.size.w,box.size.h
    });
    dstRect=((SDL_Rect) {
        box.origin.x+topOffset.x,box.origin.y+topOffset.y,box.size.w,box.size.h
    });
    SDL_gfxBlitRGBA(textSurface,&srcRect,getTopScreen(),&dstRect);
    SDL_FreeSurface(textSurface);
    if (pointsSurface!=0)
        SDL_FreeSurface(pointsSurface);
}
Example #14
0
void graphics_draw_surface_in_rect (GContext* ctx,SDL_Surface* sur,GRect rect) {
    graphics_draw_something_in_rect_to (ctx,sur,graphics_draw_surface_callback,rect,getTopScreen());
}
Example #15
0
void graphics_draw_bitmap_in_rect (GContext* ctx,const GBitmap* bitmap,GRect rect) {
    graphics_draw_something_in_rect_to (ctx,(void*)bitmap,graphics_draw_bitmap_callback,rect,getTopScreen ());
}