static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
    //此为canvas的save操作
	//在超过了作用域之后,会自动调用restore函数
    SkAutoCanvasRestore acr(canvas, true);

    SkPaint paint;
    SkScalar x = 0;
    const int scale = 64;

    //开启抗锯齿 : 见百度百科
    paint.setAntiAlias(true); 
    //绘制行首文字 : 见结果图每行行头文字
    const char* name = gConfigNames[bm.config()];
    canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8,
                     paint);

    //平移到(48, 0)???为何是48--牛群
    canvas->translate(SkIntToScalar(192), 0);
    //缩放 : x,y轴乘各乘以一个系数, 进行放大或缩小.: 此处因为4个像素很小,所以进行了放大.
    canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));
    
    /*逐个画每行的6个方块*/
    //画前三个, 正常的, 滤镜的, 滤镜+防抖动的.
    x += draw_set(canvas, bm, 0, &paint);
    //画笔复原
    paint.reset();
    /*开启透明, 画后三个, 正常的, 滤镜的, 滤镜+防抖动的. */
    paint.setAlpha(0x80);
    draw_set(canvas, bm, x, &paint);
    return x * scale / 3;
}
Exemple #2
0
static void	*start_fractal(void *data)
{
	t_thread_info		ti;
	int					frac_set;

	frac_set = (int)data;
	ti.blk.r = 0;
	ti.blk.g = 0;
	ti.blk.b = 0;
	ti.blk.alpha = 0;
	ti.c = (t_co *)ft_memalloc(sizeof(t_co));
	init_co_img(ti.c);
	ti.lock = 0;
	ti.show = 2;
	choose_set(frac_set, &ti);
	draw_set(ti.c->img, &ti.frac);
	IMG_TO_WINDOW(ti.c->mlx_ptr, ti.c->win_ptr, ti.c->img_ptr);
	mlx_hook(ti.c->win_ptr, KEYPRESS, 3, &handler_key, (void *)&ti);
	if (ti.frac.fract == JULIA)
		mlx_hook(ti.c->win_ptr, MOTNOTY, 1L << 6, &handler_julia, (void *)&ti);
	mlx_mouse_hook(ti.c->win_ptr, &handler_mouse, (void *)&ti);
	menu(ti.c);
	mlx_loop(ti.c->mlx_ptr);
	return (NULL);
}
static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
    SkAutoCanvasRestore acr(canvas, true);

    SkPaint paint;
    SkScalar x = 0;
    const int scale = 32;

    paint.setAntiAlias(true);
    const char* name = gConfigNames[bm.config()];
    canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8,
                     paint);
    canvas->translate(SkIntToScalar(48), 0);

    canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));
    
    x += draw_set(canvas, bm, 0, &paint);
    paint.reset();
    paint.setAlpha(0x80);
    draw_set(canvas, bm, x, &paint);
    return x * scale / 3;
}
Exemple #4
0
int
main(int argc, char **argv)
{
	int COLS, ROWS;

	if (GrOpen() == -1)
		exit(1);

	COLS = 480;
	ROWS = 300;

	load_pixmap();

	g_main = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, "tsdemo",
		    GR_ROOT_WINDOW_ID, 100, 50, COLS - 120, ROWS - 60, GRAY);

	GrSelectEvents(g_main,
		       GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ);
	GrMapWindow(g_main);

	while (1) {
		GR_EVENT event;

		GrGetNextEvent(&event);

		switch (event.type) {
		case GR_EVENT_TYPE_EXPOSURE:
			g_x = 5;
			draw_set("GR_FILL_STIPPLE", GR_FILL_STIPPLE);
			draw_set("GR_FILL_OPAQUE_STIPPLE", GR_FILL_OPAQUE_STIPPLE);
			draw_set("GR_FILL_TILE", GR_FILL_TILE);
			break;

		case GR_EVENT_TYPE_CLOSE_REQ:
			GrClose();
			exit(0);
		}
	}
}
Exemple #5
0
static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
    SkAutoCanvasRestore acr(canvas, true);

    SkPaint paint;
    SkScalar x = 0;
    const int scale = 32;

    paint.setAntiAlias(true);
    sk_tool_utils::set_portable_typeface(&paint);
    const char* name = sk_tool_utils::colortype_name(bm.colorType());
    canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8,
                     paint);
    canvas->translate(SkIntToScalar(48), 0);

    canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));

    x += draw_set(canvas, bm, 0, &paint);
    paint.reset();
    paint.setAlpha(0x80);
    draw_set(canvas, bm, x, &paint);
    return x * scale / 3;
}
Exemple #6
0
static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) {
    SkAutoCanvasRestore acr(canvas, true);

    SkPaint paint;
    paint.setAntiAlias(true);

    SkScalar x = 0;
    const int scale = 32;

    SkFont      font(ToolUtils::create_portable_typeface());
    const char* name = ToolUtils::colortype_name(bm.colorType());
    canvas->drawString(name, x, SkIntToScalar(bm.height())*scale*5/8,
                       font, paint);
    canvas->translate(SkIntToScalar(48), 0);

    canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale));

    x += draw_set(canvas, bm, 0, &paint);
    paint.reset();
    paint.setAlphaf(0.5f);
    draw_set(canvas, bm, x, &paint);
    return x * scale / 3;
}
Exemple #7
0
void
step()
{
    // printf("\nSTEP %d\n", PROGRAM->frame);
    draw_set(COLOR_BLACK);

    Entity *entity;
    memi i;

    player_step(GAME->player);

    //
    // Update entities
    //

    entity = GAME->entities;
    for (i = 0;
         i != GAME->entities_count;
         ++i, ++entity)
    {
        if (!equalf(entity->vx, 0, 0.1) || !equalf(entity->vy, 0, WORLD_COLLISION_EPSILON))
        {
            world_test_move(&GAME->world,
                            entity->collider,
                            entity->vx, entity->vy,
                            CollisionTestMask_All,
                            &collision,
                            on_collision);

            if (!equalf(collision.end_x, entity->collider->x, WORLD_COLLISION_EPSILON) ||
                !equalf(collision.end_y, entity->collider->y, WORLD_COLLISION_EPSILON))
            {
                world_move(&GAME->world,
                           entity->collider,
                           collision.end_x,
                           collision.end_y);
            }
        }
    }

    player_camera_step(GAME->player, &GAME->camera);

    PROGRAM->tx = -GAME->camera.x + (SCREEN_WIDTH >> 1);
    PROGRAM->ty = -GAME->camera.y + (SCREEN_HEIGHT >> 1);

    //
    // Update animations
    //

    if ((PROGRAM->frame % 3) == 0)
    {
        Animation *ani = GAME->animations;
        for (i = 0;
             i != GAME->animations_count;
             ++i, ++ani)
        {
            ani->sprite++;
            if (ani->sprite == ani->end) {
                ani->sprite = ani->begin;
            }
        }
    }

    //
    // Draw
    //

    tilemap_draw(res_level_0_layer1, res_image_set_main, 0, 0);

    Collider *collider;
    entity = GAME->entities;
    for (i = 0;
         i != GAME->entities_count;
         ++i, ++entity)
    {
        collider = entity->collider;
        rect_draw(v4i_make_size(roundf(collider->x - collider->w),
                                roundf(collider->y - collider->h),
                                collider->w * 2,
                                collider->h * 2), COLOR_SHADE_3);
//        image_set_draw(collider->x + entity->sprite_ox, collider->y + entity->sprite_oy,
//                 entity->animation->set,
//                 entity->animation->sprite,
//                 entity->animation->sprite_mode, 0);
    }

    //
    // Debug
    //

    debug_world_colliders_count(&GAME->world);

    PROGRAM->tx = 0;
    PROGRAM->ty = 0;
    debug_buttons(4, SCREEN_HEIGHT - res_icons->ch - 4);
    debug_fps(SCREEN_WIDTH - (7 * res_font->cw) - 4,
              SCREEN_HEIGHT - res_font->ch - 4,
              PROGRAM->time_step);
    debug_world_bucket_stats(&GAME->world, 4, 4);
    debug_world_bucket_cells(&GAME->world, SCREEN_WIDTH - 4 - 16, 4);
}