void set_pixel(SDL_Surface *surface, int x, int y, uint8_t color)
{
    LOCK(surface);
    Uint8 *target_pixel = (Uint8 *)(surface->pixels + y * surface->pitch + x * 4);
    *(Uint32 *)target_pixel = getRawColor(color);
    UNLOCK(surface);
}
void gpath_draw_outline(GContext *ctx, GPath *path) {
  LOCK(screen);
  SDL_Point *points = _gpath_to_sdl(path);
  SDL_DrawPolygon(screen, points, path->num_points, getRawColor(ctx->stroke_color));
  free(points);
  UNLOCK(screen);
}
示例#3
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);
}
示例#4
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);
}
void gpath_draw_filled(GContext *ctx, GPath *path) {
  LOCK(screen);
  SDL_Point *points = _gpath_to_sdl(path);
  SDL_FillPolygon(screen, points, path->num_points, getRawColor(ctx->fill_color));
  free(points);
  UNLOCK(screen);
}
void graphics_fill_rect(GContext *ctx, GRect rect, uint8_t corner_radius, GCornerMask corner_mask) {
  //TODO: corner_radius and corner_mask
  //TODO: is stroke color meaningful?
  LOCK(screen);

  uint32_t color = getRawColor(ctx->fill_color);

  SDL_Rect srect = {rect.origin.x, rect.origin.y, rect.size.w, rect.size.h};
  SDL_FillRect(screen, &srect, color);
  UNLOCK(screen);
}
void graphics_fill_circle(GContext *ctx, GPoint p, int radius) {
  LOCK(screen);
  SDL_FillCircle(screen, p.x, p.y, radius, getRawColor(ctx->fill_color));
  UNLOCK(screen);
}
void graphics_draw_line(GContext *ctx, GPoint p0, GPoint p1) {
  LOCK(screen);
  SDL_DrawLine(screen, p0.x, p0.y, p1.x, p1.y, getRawColor(ctx->stroke_color));
  UNLOCK(screen);
}
void graphics_draw_pixel(GContext *ctx, GPoint point) {
  LOCK(screen);
  SDL_DrawPixel(screen, point.x, point.y, getRawColor(ctx->stroke_color));
  UNLOCK(screen);

}
示例#10
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));
}
示例#11
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));
}
示例#12
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));
}
示例#13
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));
}
示例#14
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));
}
示例#15
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));
}
示例#16
0
void window_set_background_color(Window *window, GColor background_color) {
  uint32_t color = getRawColor(background_color);

  SDL_FillRect(screen, NULL, color);
}
示例#17
0
Color CubeAnalyzer::reconizeColor(unsigned x ,unsigned y) const {
    vector<Vec3b> colors;
    Size cubeSize = cubeMat.size();
    Color color = UNDEF;
    if (isInMatrixBounds(x, y, cubeSize.width, cubeSize.height)){
        colors.push_back(getRawColor(x, y));
        colors.push_back(getRawColor(x + radius, y));
        colors.push_back(getRawColor(x - radius, y));
        colors.push_back(getRawColor(x, y + radius));
        colors.push_back(getRawColor(x, y - radius));
        colors.push_back(getRawColor(x + radius / 2, y));
        colors.push_back(getRawColor(x - radius / 2, y));
        colors.push_back(getRawColor(x, y + radius / 2));
        colors.push_back(getRawColor(x, y - radius / 2));
        colors.push_back(getRawColor(x + radius / 2, y + radius / 2));
        colors.push_back(getRawColor(x - radius / 2, y - radius / 2));
        colors.push_back(getRawColor(x - radius / 2, y + radius / 2));
        colors.push_back(getRawColor(x + radius / 2, y - radius / 2));
        Vec3b avgColor = avgColors(colors);
        color = classifyColor(avgColor);
    }
    return color;
}