예제 #1
0
파일: gdowait.cpp 프로젝트: bratkov/tmos
void GWait::draw_this(LCD_MODULE* lcd)
{
	uint8_t mask=1;
	if(R > 5)
	{
		POINT_T p;//, r(R-2,R-2);
		for(int i=0; i < 8; i++, mask <<=1)
		{
			p = PolarToDevXY(i*45, R-4, lcd);
			p += base;
			if(last_state & mask)
			{
				lcd->color = PIX_BLACK;
				fill_circle(p, 2);
				lcd->color = PIX_WHITE;
				draw_circle(p, 2);
				continue;
			}
			if(new_state & mask)
				fill_circle(p, 2);
			else
				draw_circle(p, 2);
		}
	}
}
예제 #2
0
// helper function for drawing - no more need to go mess with
// the main function when just want to change what to draw...
void draw() {

    int x;
    
    // some pixels
    for (x = 0; x < vinfo.xres; x+=5) {
        put_pixel(x, vinfo.yres / 2, WHITE);
    }

    // some lines (note the quite likely 'Moire pattern')
    for (x = 0; x < vinfo.xres; x+=20) {
        draw_line(0, 0, x, vinfo.yres - 1, GREEN);
    }
    
    // some rectangles
    draw_rect(vinfo.xres / 4, vinfo.yres / 2 + 10, vinfo.xres / 4, vinfo.yres / 4, PURPLE);    
    draw_rect(vinfo.xres / 4 + 10, vinfo.yres / 2 + 20, vinfo.xres / 4 - 20, vinfo.yres / 4 - 20, PURPLE);    
    fill_rect(vinfo.xres / 4 + 20, vinfo.yres / 2 + 30, vinfo.xres / 4 - 40, vinfo.yres / 4 - 40, YELLOW);    

    // some circles
    int d;
    for(d = 10; d < vinfo.yres / 6; d+=10) {
        draw_circle(3 * vinfo.xres / 4, vinfo.yres / 4, d, RED);
    }
    
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 6, ORANGE);
    fill_circle(3 * vinfo.xres / 4, 3 * vinfo.yres / 4, vinfo.yres / 8, RED);

}
예제 #3
0
int main(int argc, char *argv[]){
  
  // Initialize
  
  std::ofstream fout("data.raw",std::ios::binary);
  if( fout.fail() ){ return -1; }
  
  int width = DATA_WIDTH;
  int height = DATA_HEIGHT;
  
  // Create image data1 and draw circles
  
  float* data1 = new float[width*height];
   std::cout <<"In function: " << __FUNCTION__<< std::endl;
  fill_circle( data1, width, height, (1*width)/3, (5*height)/8, width/4 );
  fill_circle( data1, width, height, (4*width)/5, (6*height)/8, width/5 );
  fill_circle( data1, width, height, (2*width)/3, (1*height)/4, width/6 );
  // Create image data2 and draw circles
  
  float* data2 = new float[width*height];

  fill_circle( data2, width, height, width/2, height/2, width/5 );

  // Create a Gaussian filter
  
  int filt_width = FILT_WIDTH;
  int filt_height = FILT_HEIGHT;
  
  float* pfilt = new float[filt_width*filt_height];
  fill_gaussian_filter_data(pfilt,filt_width,filt_height);

  // Create result image data
  // TODO: why do I need sizeof(float) when float is used as type?
  float* data_res = new float[sizeof(float)*width*height];
  
  // Apply Gaussian filter to data1 -> data_res
  apply_filter(data_res, data1, width, height, pfilt, filt_width, filt_height);
  std::cout << "Line : "  << __LINE__ << std::endl;
  // Copy result (data_res) to data1
  memcpy(data1,data_res,width*height*sizeof(data_res)); // HERE IS PROBLEM, RABORT MID OR I FEED
  std::cout << "Line : "  << __LINE__ << std::endl;
  // Take larges pixel value from data1 and data2 and store in data_res
  copy_max_value(data_res, data1, data2, width, height);
  std::cout << "Line : "  << __LINE__ << std::endl;
  // Save result to file and clean up
  
  fout.write(reinterpret_cast<char*>(data_res),width*height*sizeof(data_res));
  if( fout.fail() ){ return -1; }
  fout.close();
  std::cout << "Line : "  << __LINE__ << std::endl;
  delete[] data1;
  delete[] data2;
  delete[] pfilt;
  delete[] data_res;
  std::cout << "Line : "  << __LINE__ << std::endl;
  return 0;
}
예제 #4
0
int main(int argc, char **argv)
{
	struct fb fb;
	struct pt p;
	struct sigaction sa;
	sa.sa_handler = &sighandler;
	sigaction(SIGINT, &sa, NULL);
	srand(time(NULL));
	fb_init(&fb);
	int w = fb.vinfo.xres;
	int h = fb.vinfo.yres;
	int min_r = 5;
	int max_r = 200;
	while (running) {
		set_color(&fb, rand());
		p.x = rand() % w;
		p.y = rand() % h;
		double radius = rand() % (max_r - min_r) + min_r;
		if (p.x - radius < 0 || p.x + radius >= w ||
		    p.y - radius < 0 || p.y + radius >= h) {
			continue;
		}
		fill_circle(&fb, p, radius);
		buffer_swap(&fb);
		refresh(&fb);
		usleep(100);
	}
	fb_uninit(&fb);
	return 0;
}
예제 #5
0
파일: xapp.cpp 프로젝트: Mokosha/COMP590
    TestWindow(int w, int h,
               char const* const* files, int fileCount,
               bool doCircles, bool doFade, ShapeFactory fact,
               int repeat) : GXWindow(w, h) {
        fDoOpaque = true;
        fStartTime = GTime::GetMSec();
        fCounter = 0;

        GRandom rand;

        fBitmapCount = 0;
        fBitmaps = new GBitmap[fileCount];
        for (int i = 0; i < fileCount; ++i) {
            if (GReadBitmapFromFile(files[i], &fBitmaps[i])) {
                fBitmapCount += 1;
                
                if (doCircles) {
                    fill_circle(fBitmaps[i]);
                }
            } else {
                fprintf(stderr, "failed to decode %s\n", files[i]);
            }
        }

        fShapeCount = fBitmapCount * repeat;
        fShapes = new Shape*[fShapeCount];

        float speed = 300;
        for (int i = 0; i < fShapeCount; ++i) {
            fShapes[i] = fact(fBitmaps[i % fBitmapCount], w/2, h/2);
            fShapes[i]->setup(rand.nextF() * speed,
                              rand.nextF() * speed,
                              doFade ? rand.nextF() : 0);
        }
    }
예제 #6
0
파일: utils.cpp 프로젝트: poseidon4o/NN-aim
SDL_Surface *  drawCircle(const float radius, const char red, const char green, const char blue)
{
	const int size = static_cast<int>((radius + 0.5f) * 2);
	SDL_Surface * result = SDL_CreateRGBSurface(0, size, size, 32, 0, 0, 0, 0);
	fill_circle(result, size / 2, size / 2, size/2, SDL_MapRGB(result->format, red, green, blue));

	return result;
}
예제 #7
0
int main(int argc, char** argv) {
  init_graphics();
  clear_screen();

  int x, y;
  fill_circle(120, 120, 100, GREEN_COLOR);

  exit_graphics();
  return 0;
}
예제 #8
0
int main()
{
  int  xc, yc, r, ny, nc, k, j;
  unsigned char  val_fill, val_erode;
  void  fill_circle(), erode();


/* Values (i.e. VLT index) for filling the circles and erosion replacement. */
  val_fill = 8;
  val_erode = 1;

/* Allocate space initialized to zero for the test frame buffer:  */
  ny = YMAX - YMIN + 1;			/* number of rasters */
  Pt_Frame = (unsigned char *)calloc(STRIDE * ny, sizeof(unsigned char));

/* Obtain user input and loop through circles filling each one. */
  printf(" Number of circles: ");
  scanf("%d", &nc);				/* try:  3 */
   for(k=0; k<nc; k++) {
    printf(" center (x,y) and radius:  ");
    scanf("%d%d%d", &xc, &yc, &r);	   /* try:  5 5 6,  15 12 7,  28 6 5 */

/* Check for total clipping before filling circle:  */
     if(xc+r < XMIN || xc-r > XMAX || yc+r < YMIN || yc-r > YMAX) {
      printf("Circle x,y,r:  %d  %d  %d  total clip.\n", xc, yc, r);
     }
     else {
      fill_circle(xc, yc, r, val_fill);
     }
   }			/* end for loop through circles */

/* Print the Upper Left corner of the buffer after filling circles:  */
  printf("UL corner of filled buffer.\n");
   for(k=0; k<23; k++) {
    printf("%2d: ",k);
     for(j=0; j<35; j++) {
      printf("%2d", *(Pt_Frame + j + k * STRIDE));
     }
    printf("\n");
   }

  erode(val_fill, val_erode);		/* erode the filled circles */

/* Print the Upper Left corner of the buffer after eroding filled circles:  */
  printf("UL corner of eroded buffer.\n");
   for(k=0; k<23; k++) {
    printf("%2d: ",k);
     for(j=0; j<35; j++) {
      printf("%2d", *(Pt_Frame + j + k * STRIDE));
     }
    printf("\n");
   }

  free((char*) Pt_Frame);		/* free the frame buffer memory */
}
예제 #9
0
파일: canvas.cpp 프로젝트: punkkeks/ClanLib
void Canvas::fill_ellipse(const Pointf &center, float radius_x, float radius_y, const Gradient &gradient)
{
	float max_radius = max(radius_x, radius_y);
	if (max_radius == 0)
		return;

	const Mat4f original_transform = get_transform();
	mult_transform(Mat4f::translate(center.x, center.y, 0));
	mult_transform(Mat4f::scale(radius_x / max_radius, radius_y / max_radius, 1.0f));
	fill_circle(Pointf(0, 0), max_radius, gradient);
	set_transform(original_transform);
}
예제 #10
0
void ArcballHelper::update_rim(Arcball const & arcball)
{
    std::vector<glm::vec3> positions;

    if (!override_rim) {
        auto & material = rim_node->get_material();
        material.get_uniform("diffuse") = glm::vec3(0.3f, 0.3f, 0.3f);
        fill_circle(arcball, positions);
    }

    auto & mesh = rim_node->get_mesh();
    mesh.set_positions(positions);
}
예제 #11
0
파일: test.c 프로젝트: Janesak1977/j4cDAC
int main(int argc, char **argv) {
	etherdream_lib_start();

	/* Sleep for a bit over a second, to ensure that we see broadcasts
	 * from all available DACs. */
	usleep(1200000);

	int cc = etherdream_dac_count();
	if (!cc) {
		printf("No DACs found.\n");
		return 0;
	}

	int mode;
	if (argc > 1)
		mode = atoi(argv[1]);
	else
		mode = 0;

	int i;
	for (i = 0; i < cc; i++) {
		printf("%d: Ether Dream %06lx\n", i,
			etherdream_get_id(etherdream_get(i)));
	}

	struct etherdream *d = etherdream_get(0);

	printf("Connecting...\n");
	if (etherdream_connect(d) < 0)
		return 1;

	i = 0;
	while (1) {
		fill_circle((float)i / 50, mode);
		int res = etherdream_write(d, circle, CIRCLE_POINTS, 30000, 1);
		if (res != 0) {
			printf("write %d\n", res);
		}
		etherdream_wait_for_ready(d);
		i++;
	}

	printf("done\n");
	return 0;
}
예제 #12
0
    void UnitTest_ConvexHull::TestFindMax()
    {
        // Test with empty hull
        {
            using Point = Point2<int>;
            const std::vector<Point> convex_hull{};
            auto res = ConvexHull<int>::FindMax(convex_hull.cbegin(), convex_hull.cend(), [](const Point& p1, const Point& p2) { return p1.y() < p2.y(); });
            CHECK_TRUE(res == convex_hull.cend());
        }

        // Test with small hull
        {
            using Point = Point2<int>;
            const std::vector<Point> convex_hull{ Point(0,0), Point(1,0), Point(2,0), Point(1,1) };
            auto res = ConvexHull<int>::FindMax(convex_hull.cbegin(), convex_hull.cend(), [](const Point& p1, const Point& p2) { return p1.y() < p2.y(); });
            const Point expected(1, 1);
            CHECK_EQUAL(*res, expected);
        }

        // Test with large hull
        {
            using Point = Point2<float>;
            std::vector<Point> convex_hull;
            const int vertices_count = 60;
            convex_hull.reserve(vertices_count);
            fill_circle(vertices_count, 1.f, std::back_inserter(convex_hull));

            const int shift_size = 10;
            const int iters_count = vertices_count / shift_size - 1;
            for (int i = 0; i < iters_count; ++i)
            {
                auto res = ConvexHull<float>::FindMax(convex_hull.cbegin(), convex_hull.cend(), [](const Point& p1, const Point& p2) { return p1.y() < p2.y(); });
                CHECK_TRUE(AlmostEqualAbsolute(res->x(), 0, 0.00001f));
                CHECK_TRUE(AlmostEqualRelative(res->y(), 1, 0.00001f));
                std::rotate(convex_hull.begin(), convex_hull.begin() + shift_size, convex_hull.end());
            }
        }
    }
예제 #13
0
void ArcballHelper::fill_constraint(Arcball const & arcball, unsigned int index)
{
    std::vector<glm::vec3> positions;
    auto & mesh = constraint_nodes[index]->get_mesh();
    auto & material = constraint_nodes[index]->get_material();

    mesh.set_draw_mode(gst::DrawMode::LINE_STRIP);
    material.get_uniform("diffuse") = axis_index_color(index);
    material.get_uniform("opacity") = arcball.constraint.nearest == index ? 1.0f : 0.4f;

    auto axis = arcball.constraint.available[index];
    if (axis.z == 1.0f) {
        // we are looking down through the z-axis
        mesh.set_draw_mode(gst::DrawMode::LINE_LOOP);
        fill_circle(arcball, positions);
        // we signal to not draw our rim to avoid color conflicts when drawing
        override_rim = true;
    } else {
        fill_half_arc(arcball, positions, axis);
    }

    mesh.set_positions(positions);
}
예제 #14
0
static void repaint_halftone(halftone_screen *halftone)
{
  int x, y;
  /*
  int x_offset = halftone->spacing / 2;
  int y_offset = halftone->spacing / 2;
  */
  int x_offset = 0;
  int y_offset = 0;

  
  /* Fill buffer with background color */
  XSetForeground (halftone->dpy, halftone->buffer_gc,
                  halftone->colors[halftone->color0].pixel);
  XFillRectangle(halftone->dpy, halftone->buffer, halftone->buffer_gc, 0, 0, halftone->buffer_width, halftone->buffer_height);

  /* Draw dots on buffer */
  XSetForeground (halftone->dpy, halftone->buffer_gc,
                  halftone->colors[halftone->color1].pixel);

  if (halftone->color_tick++ >= halftone->cycle_speed)
    {
      halftone->color_tick = 0;
      halftone->color0 = (halftone->color0 + 1) % halftone->ncolors;
      halftone->color1 = (halftone->color1 + 1) % halftone->ncolors;
    }

  for (x = 0; x < halftone->dots_width; x++)
    for (y = 0; y < halftone->dots_height; y++)
      fill_circle(halftone->dpy, halftone->buffer, halftone->buffer_gc,
		  x_offset + x * halftone->spacing, y_offset + y * halftone->spacing, 
		  halftone->max_dot_size * halftone->dots[x + y * halftone->dots_width]);

  /* Copy buffer to window */
  if (halftone->buffer != halftone->window)
    XCopyArea(halftone->dpy, halftone->buffer, halftone->window, halftone->gc, 0, 0, halftone->buffer_width, halftone->buffer_height, 0, 0);
}
예제 #15
0
    void UnitTest_ConvexHull::TestCompute()
    {
        // Test with empty vector
        {
            std::vector<Point2<int>> points;
            std::vector<int> hull;
            ConvexHull<int>::ComputeNlgH(points.cbegin(), points.cend(), &hull);
            CHECK_EQUAL((int)hull.size(), 0);
        }

        // Test with all points in line
        {
            using Point = Point2<int>;
            std::vector<Point> points{ Point(0,1), Point(0,2), Point(0,3), Point(0,4) };
            std::vector<int> hull;
            ConvexHull<int>::ComputeNlgH(points.cbegin(), points.cend(), &hull);
            CHECK_EQUAL((int)hull.size(), 2);
            CHECK_EQUAL(hull[0], 0);
            CHECK_EQUAL(hull.back(), (int)points.size() - 1);
        }

        // Test circle
        {
            using Point = Point2<float>;
            std::vector<Point> points;
            const int vertices_count = 60;
            points.reserve(vertices_count);
            fill_circle(vertices_count, 1.f, std::back_inserter(points));

            std::vector<int> hull;
            ConvexHull<float>::ComputeNlgH(points.cbegin(), points.cend(), &hull);

            CHECK_EQUAL((int)hull.size(), vertices_count);
            bool zero_index_met = false;
            for (int i = 1; i < vertices_count; ++i)
            {
                if (hull[i - 1] == 0)
                    zero_index_met = true;
                CHECK_TRUE(hull[i] == hull[i - 1] + 1 || !zero_index_met && hull[i] == 0);
            }
        }

        // Test circle with circle inside
        {
            using Point = Point2<float>;
            std::vector<Point> points;
            const int vertices_count = 60;
            points.reserve(vertices_count * 2);
            fill_circle(vertices_count, 2.f, std::back_inserter(points));
            fill_circle(vertices_count, 1.f, std::back_inserter(points));

            std::vector<int> hull;
            ConvexHull<float>::ComputeNlgH(points.cbegin(), points.cend(), &hull);

            std::vector<int> expected_hull(vertices_count);
            std::iota(expected_hull.begin(), expected_hull.end(), 0);
            bool zero_index_met = false;
            for (int i = 1; i < vertices_count; ++i)
            {
                if (hull[i - 1] == 0)
                    zero_index_met = true;
                CHECK_TRUE(hull[i] < 60 && hull[i] == hull[i - 1] + 1 || !zero_index_met && hull[i] == 0);
            }
        }

        // Rotated wedding rings
        {
            using Point = Point2<float>;
            std::vector<Point> points;
            const int vertices_count = 60;
            points.reserve(vertices_count * 2);
            fill_circle(vertices_count, 2.f, std::back_inserter(points));
            fill_circle(vertices_count, 2.f, std::back_inserter(points));
            // Move second circle along y axis a bit
            std::transform(points.begin() + vertices_count, points.end(), points.begin() + vertices_count, [](const Point& p) { return p + Point(0.f, 1.f); });

            std::vector<int> hull;
            ConvexHull<float>::ComputeNlgH(points.cbegin(), points.cend(), &hull);

            std::vector<int> expected_hull(vertices_count + 2);
            expected_hull[0] = 0; // Rightmost vertex of the lowest circle
            std::iota(expected_hull.begin() + 1, expected_hull.begin() + 32, 60);
            std::iota(expected_hull.begin() + 32, expected_hull.end(), 30);
            utilities::unit_tests::UnitTestHelper::CheckVectorsForEquality(hull, expected_hull);
        }
    }
예제 #16
0
파일: canvas.cpp 프로젝트: punkkeks/ClanLib
void Canvas::fill_circle(const Pointf &center, float radius, const Gradient &gradient)
{
	fill_circle(center, center, radius, gradient);
}
예제 #17
0
파일: Canvas.cpp 프로젝트: niesteszeck/Cosa
void
Canvas::run(uint8_t ix, const void_P* tab, uint8_t max)
{
    if (ix >= max) return;
    const uint8_t* ip = (const uint8_t*) pgm_read_word(tab + ix);
    uint8_t x, y, r, g, b, w, h, s;
    int8_t dx, dy;
    char c;
    while (1) {
        switch (pgm_read_byte(ip++)) {
        case END_SCRIPT:
            return;
        case CALL_SCRIPT:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            run(ix, tab, max);
            break;
        case SET_CANVAS_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_canvas_color(color(r, b, g));
            break;
        case SET_PEN_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_pen_color(color(r, g, b));
            break;
        case SET_TEXT_COLOR:
            r = pgm_read_byte(ip++);
            g = pgm_read_byte(ip++);
            b = pgm_read_byte(ip++);
            set_text_color(color(r, g, b));
            break;
        case SET_TEXT_SCALE:
            set_text_scale(pgm_read_byte(ip++));
            break;
        case SET_TEXT_FONT:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            set_text_font((Font*) pgm_read_word(tab + ix));
            break;
        case SET_CURSOR:
            x = pgm_read_byte(ip++);
            y = pgm_read_byte(ip++);
            set_cursor(x, y);
            break;
        case MOVE_CURSOR:
            dx = pgm_read_byte(ip++);
            dy = pgm_read_byte(ip++);
            move_cursor(dx, dy);
            break;
        case DRAW_BITMAP:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            s = pgm_read_byte(ip++);
            draw_bitmap((const uint8_t*) pgm_read_word(tab + ix), w, h, s);
            break;
        case DRAW_ICON:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_icon((const uint8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_PIXEL:
            draw_pixel();
            break;
        case DRAW_LINE:
            x = pgm_read_byte(ip++);
            y = pgm_read_byte(ip++);
            draw_line(x, y);
            break;
        case DRAW_POLY:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_poly_P((const int8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_STROKE:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            s = pgm_read_byte(ip++);
            draw_stroke_P((const int8_t*) pgm_read_word(tab + ix), s);
            break;
        case DRAW_RECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            draw_rect(w, h);
            break;
        case FILL_RECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            fill_rect(w, h);
            break;
        case DRAW_ROUNDRECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            r = pgm_read_byte(ip++);
            draw_roundrect(w, h, r);
            break;
        case FILL_ROUNDRECT:
            w = pgm_read_byte(ip++);
            h = pgm_read_byte(ip++);
            r = pgm_read_byte(ip++);
            fill_roundrect(w, h, r);
            break;
        case DRAW_CIRCLE:
            r = pgm_read_byte(ip++);
            draw_circle(r);
            break;
        case FILL_CIRCLE:
            r = pgm_read_byte(ip++);
            fill_circle(r);
            break;
        case DRAW_CHAR:
            c = pgm_read_byte(ip++);
            draw_char(c);
            break;
        case DRAW_STRING:
            ix = pgm_read_byte(ip++);
            if (ix >= max) return;
            draw_string_P((const char*) pgm_read_word(tab + ix));
            break;
        case FILL_SCREEN:
            fill_screen();
            break;
        default:
            return;
        }
    }
}
예제 #18
0
int main (int argc, char** argv)
{
   printf("\nPress \"1\" to draw a non-filled rectangle.\n");
   printf("Press \"2\" to draw a filled circle.\n");
   printf("Press \"3\" to display a string.\n");
   printf("**Select shape. Use the \"WASD\" keys to move the shape around.\n");
   printf("**Press the \"q\" at any point to termiante the program.\n");

   char key;
   int x = (640-20)/2;
   int y = (480-20)/2;
   int choice;
   scanf("%d", &choice);

   /**
   * Draw a non-filled rectangle.
   * Move around with 'WASD' keys.
   * Terminate with 'q' key.
   */
   {
   if(choice == 1)
      init_graphics();
      clear_screen();
      draw_rect(x, y, 200, 100, 20);
      do
      {
         key = getkey();
         if(key == 'w') y-=10;
         else if(key == 's') y+=10;
         else if(key == 'a') x-=10;
         else if(key == 'd') x+=10;
         clear_screen();
         draw_rect(x, y, 200, 100, 20);
         sleep_ms(20);
      } while(key != 'q');
      clear_screen();
      exit_graphics();
   }

   /**
   * Draw a filled circle with the midpoint circle algorithm.
   * Move around with 'WASD' keys.
   * Terminate with 'q' key.
   */
   if(choice == 2)
   {
      init_graphics();
      clear_screen();
      fill_circle(x, y, 75, 20);
      do
      {
         key = getkey();
         if(key == 'w') y-=10;
         else if(key == 's') y+=10;
         else if(key == 'a') x-=10;
         else if(key == 'd') x+=10;
         clear_screen();
         fill_circle(x, y, 75, 20);
         sleep_ms(20);
      } while(key != 'q');
         clear_screen();
         exit_graphics();
   }

   /**
   * Write a string usign the iso_font.h header file.
   * Move around with 'WASD' keys.
   * Terminate with 'q' key.
   */
   if(choice == 3)
   {
      const char *text_input = "Hello World!";
      init_graphics();
      clear_screen();
      draw_text(x, y, text_input, 20);
   do
   {
      key = getkey();
      if(key == 'w') x-=10;
      else if(key == 's') x+=10;
      else if(key == 'a') y-=10;
      else if(key == 'd') y+=10;
      clear_screen();
      draw_text(x, y, text_input, 20);
      sleep_ms(20);
   } while(key != 'q');
      clear_screen();
      exit_graphics();
   }

   return 0;
}
예제 #19
0
파일: main.c 프로젝트: Spooky4672/RayTracer
// MAIN
int main(int argc, char ** argv) {
	int scene_id = 0;
	bool use_octree = false;
	char basename[256] = "";
	if (argc > 1)
		scene_id = atoi(argv[1]);
	if (argc > 2)
		strcpy(basename, argv[2]);

	// scene_id 0, 1, 2, 3 is for tp 1 tests;
	switch (scene_id) {
	case 0:
		fill_red(output_image);
		break;
	case 1:
		fill(output_image, vector_init(0.7, 0.3, 0.1));
		fill_rect(output_image, vector_init(0.2, 0.6, 0.7), vector_init(WIDTH / 4, HEIGHT / 5, 0), vector_init(WIDTH / 3, HEIGHT / 4, 0));
		break;
	case 2:
		horizontal_gradient(output_image, vector_init(0, 0, 1), vector_init(1, 1, 1));
		break;
	case 3:
		horizontal_gradient(output_image, vector_init(0, 0, 1), vector_init(1, 1, 1));
		fill_circle(output_image, WIDTH / 20, vector_init(4 * WIDTH / 5, 4 * HEIGHT / 5, 0), vector_init(1, 1, 0));
		fill_rect(output_image, vector_init(0.1, 0.8, 0.4), vector_init(0, 0, 0), vector_init(WIDTH, HEIGHT / 4, 0));
		break;
	case 4:
		horizontal_gradient(output_image, vector_init(0.5, 0.8, 1), vector_init(1, 1, 1));
		fill_circle(output_image, WIDTH / 20, vector_init(4 * WIDTH / 5, 4 * HEIGHT / 5, 0), vector_init(1, 1, 0));
		fill_circle(output_image, WIDTH / 21, vector_init(3 * WIDTH / 5, 3 * HEIGHT / 5, 0), vector_init(1, 0.3, 0.1));
		fill_rect(output_image, vector_init(0.85, 0.85, 0.3), vector_init(0, 0, 0), vector_init(WIDTH, HEIGHT / 4, 0));
		break;
	default:
		setup_scene(scene_id - 5);
		raytrace();
		break;
	}

#ifdef USE_FREEIMAGE
	FreeImage_Initialise();
	FIBITMAP *bitmap = FreeImage_Allocate(WIDTH, HEIGHT, 32, FI_RGBA_RED_MASK,
			FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
	if (bitmap) {
		// bitmap successfully created!

		// Calculate the number of bytes per pixel (3 for 24-bit or 4 for 32-bit)
		color *ptr = output_image;
		int bytespp = FreeImage_GetLine(bitmap) / FreeImage_GetWidth(bitmap);
		for(unsigned y = 0; y < FreeImage_GetHeight(bitmap); y++) {
			BYTE *bits = FreeImage_GetScanLine(bitmap, y);
			for(unsigned x = 0; x < FreeImage_GetWidth(bitmap); x++) {
				// Set pixel color to green with a transparency of 128
				*ptr = vector_clamp(*ptr, 0.f, 1.f);
				bits[FI_RGBA_RED] = ptr->x*255;
				bits[FI_RGBA_GREEN] = ptr->y*255;
				bits[FI_RGBA_BLUE] = ptr->z*255;
				bits[FI_RGBA_ALPHA] = 255;
				// jump to next pixel
				bits += bytespp;
				ptr++;
			}
		}

		// FreeImage_Save(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, const char *filename, int flags FI_DEFAULT(0));
		char filename[256];
		strcpy(filename, basename);
		strcat(filename, ".png");
		if (FreeImage_Save(FIF_PNG, bitmap, filename, 0)) {
			// bitmap successfully saved!
		}
		FreeImage_Unload(bitmap);
	}

	FreeImage_DeInitialise();
#endif
	// le code ci dessous crée et sauvegarde une image sous le nom output.png dans le repertoire d'execution
	{
		FILE *fp = NULL;
		char filename[256];
		strcpy(filename, basename);
		strcat(filename, ".ppm");

		fp = fopen(filename, "w");

		if (fp) {
			// création réussi

			fprintf(fp, "P3\n");
			fprintf(fp, "%d %d\n255\n", WIDTH, HEIGHT);
			// La c'est pour faire la boucle

			for (unsigned y = 0; y < HEIGHT; y++) {
				color *ptr = &(output_image[(HEIGHT - y - 1) * WIDTH]);
				for (unsigned x = 0; x < WIDTH; x++) {
					*ptr = vector_clamp(*ptr, 0.f, 1.f);
					unsigned char r = ptr->x * 255;
					unsigned char g = ptr->y * 255;
					unsigned char b = ptr->z * 255;
					ptr++;
					fprintf(fp, "%d %d %d  ", r, g, b);
				}
				fprintf(fp, "\n");
			}
			fclose(fp);
		}
	}

	return 0;
}
예제 #20
0
void generic_fill_ellipse(u32 x, u32 y, u32 a, u32 b, pixel_t pixel)
{
    if (a == b)
	fill_circle(x, y, a, pixel);
    else {
	u32 a2 = a*a;
	u32 b2 = b*b;
	if (a <= b) {
	    u32 x1 = 0;
	    u32 y1 = b;
	    int S = a2*(1-2*b)+2*b2;
	    int T = b2-2*a2*(2*b-1);
	    int dT1 = 4*b2;
	    int dS1 = dT1+2*b2;
	    int dS2 = -4*a2*(b-1);
	    int dT2 = dS2+2*a2;

	    while (1) {
		if (S < 0) {
		    S += dS1;
		    T += dT1;
		    dS1 += 4*b2;
		    dT1 += 4*b2;
		    x1++;
		} else if (T < 0) {
		    fill_ellipse_points(x, y, x1, y1, pixel);
		    if (y1 == 0)
			break;
		    S += dS1+dS2;
		    T += dT1+dT2;
		    dS1 += 4*b2;
		    dT1 += 4*b2;
		    dS2 += 4*a2;
		    dT2 += 4*a2;
		    x1++;
		    y1--;
		} else {
		    fill_ellipse_points(x, y, x1, y1, pixel);
		    if (y1 == 0)
			break;
		    S += dS2;
		    T += dT2;
		    dS2 += 4*a2;
		    dT2 += 4*a2;
		    y1--;
		}
	    }
	} else {
	    u32 x1 = a;
	    u32 y1 = 0;
            int S = b2*(1-2*a)+2*a2;
            int T = a2-2*b2*(2*a-1);
            int dT1 = 4*a2;
            int dS1 = dT1+2*a2;
            int dS2 = -4*b2*(a-1);
            int dT2 = dS2+2*b2;

	    fill_ellipse_points(x, y, x1, y1, pixel);
	    do {
		if (S < 0) {
		    S += dS1;
		    T += dT1;
		    dS1 += 4*a2;
		    dT1 += 4*a2;
		    y1++;
		    fill_ellipse_points(x, y, x1, y1, pixel);
		} else if (T < 0) {
		    S += dS1+dS2;
		    T += dT1+dT2;
		    dS1 += 4*a2;
		    dT1 += 4*a2;
		    dS2 += 4*b2;
		    dT2 += 4*b2;
		    x1--;
		    if (x1 < 0)
			break;
		    y1++;
		    fill_ellipse_points(x, y, x1, y1, pixel);
		} else {
		    S += dS2;
		    T += dT2;
		    dS2 += 4*b2;
		    dT2 += 4*b2;
		    x1--;
		}
	    } while (x1 > 0);
	}
    }
}
예제 #21
0
파일: circtri.c 프로젝트: benroque/SecProj
int main(){
//Standard start to triangle

  struct triangulateio in;
  struct triangulateio out;
  struct triangulateio *vorout = (struct triangulateio *) NULL;
  char Switches[] = "pq30a0.1z";

//Initialize the the arrays that will be used to pass data to triangle and to
//take data from triangle

  init_triangleio( &in);
  init_triangleio( &out);

//fill the circle for points

  fill_circle( &in, 50, 3.0);

//Execute triangulate

  triangulate( Switches, &in, &out, vorout);

//Initialize the variable for the the final summation

  tripoint triangle;
  double element;

//Print he triangle, the nodes associated with that triangle and the moving sum
//  of the elements

  printf("Number of Triangles: %i\n", out.numberoftriangles);
  for(int i = 0; i < out.numberoftriangles; i++){
    printf("Triangle %i: ",i);

    for(int j = 0; j < out.numberofcorners; j++){
      printf("\t %d", out.trianglelist[i*out.numberofcorners + j]);

      if(j % 3 == 0){
        triangle.a = out.trianglelist[i*out.numberofcorners + j];
      } else if(j % 3 == 1){
        triangle.b = out.trianglelist[i*out.numberofcorners + j];
      } else {
        triangle.c = out.trianglelist[i*out.numberofcorners + j];
      }
    }

    printf("\n");
    printf("\t %d %d %d \n", triangle.a, triangle.b, triangle.c);
    element += passPoints(triangle, out.pointlist, 3.0);
    printf("Element: %f", element);
    printf("\n");
  }

  printf("The integration over this mesh is %f \n", element);

//Freeing the arrays

  free_circle( &in);
  free_circle( &out);
//  trifree( &out);

  return 0;
}
예제 #22
0
/* Remplit un cercle de centre (x, y) et de rayon r */
void CerclePlein(int x, int y, int r) {
   fill_circle(fenetreCourante, x, y, r);
}
예제 #23
0
파일: canvas.cpp 프로젝트: punkkeks/ClanLib
void Canvas::fill_circle(float center_x, float center_y, float radius, const Colorf &color)
{
	fill_circle(Pointf(center_x, center_y), Pointf(center_x, center_y), radius, Gradient(color, color));
}
예제 #24
0
파일: canvas.cpp 프로젝트: punkkeks/ClanLib
void Canvas::fill_circle(const Pointf &center, float radius, const Colorf &color)
{
	fill_circle(center, center, radius, Gradient(color, color));
}
예제 #25
0
파일: sdl.cpp 프로젝트: RobertSzkutak/kmcv
void draw_points(point *points, int numpoints, int *cluster_centersx, int *cluster_centersy, int clusters)
{
  	SDL_Rect rect = {0, 0, WINW, WINH};
    SDL_FillRect(screen, &rect, WHITE);

    //Draw axis
    #ifdef WANT_AXIS_DRAWN
        #ifdef WANT_MEAN_AXIS
            int totx = 0, toty = 0;    
            for(int i = 0; i < numpoints; i++)
            {
                totx += points[i].x;
                toty += points[i].y;
            }
            debug("Drawing axis...");
            #ifdef MIRROR_Y
                SDL_Rect xaxis = {0, toty/numpoints*-1+offset_y, WINW, 1};
            #else
                SDL_Rect xaxis = {0, toty/numpoints+offset_y, WINW, 1};
            #endif
            SDL_Rect yaxis = {totx/numpoints+offset_x, 0, 1, WINH};
            SDL_FillRect(screen, &xaxis, BLACK);
            SDL_FillRect(screen, &yaxis, BLACK);
        #endif
        #ifdef WANT_SPLIT_AXIS
            int avgx = 0, avgy = 0, greatx=points[0].x, lowx=points[0].x, greaty=points[0].y, lowy=points[0].y;
            for(int i = 0; i < numpoints; i++)
            {
                if(points[i].x > greatx)
                    greatx = points[i].x;
                if(points[i].x < lowx)
                    lowx = points[i].x;
                if(points[i].y > greaty)
                    greaty = points[i].y;
                if(points[i].y < lowy)
                    lowy = points[i].y;
            }
            avgx = (greatx + lowx) / 2;
            avgy = (greaty + lowy) / 2;
            #ifdef MIRROR_Y
                SDL_Rect xaxis = {0, avgy*-1+offset_y, WINW, 1};
            #else
                SDL_Rect xaxis = {0, avgy+offset_y, WINW, 1};
            #endif
            SDL_Rect yaxis = {avgx+offset_x, 0, 1, WINH};
            SDL_FillRect(screen, &xaxis, BLACK);
            SDL_FillRect(screen, &yaxis, BLACK);
        #endif
        #ifdef WANT_ORIGIN_AXIS
            SDL_Rect xaxis = {0, 0+offset_y, WINW, 1};
            SDL_Rect yaxis = {0+offset_x, 0, 1, WINH};
            SDL_FillRect(screen, &xaxis, BLACK);
            SDL_FillRect(screen, &yaxis, BLACK);
        #endif
    #endif

    //TODO : Generate a random color for each cluster

    debug("Plotting points...");
    //Draw points
    for(int i = 0; i < numpoints; i++)
    {
        #ifdef MIRROR_Y
            SDL_Rect pixel = {points[i].x-2+offset_x, points[i].y*-1-2+offset_y, 5, 5};
        #else
            SDL_Rect pixel = {points[i].x-2+offset_x, points[i].y-2+offset_y, 5, 5};//Offset of -3 makes center pixel of 5x5 appear at x,y 
        #endif
        switch(points[i].cluster)
        {
            case 0:
              SDL_FillRect(screen, &pixel, RED);
              break;
            case 1:
              SDL_FillRect(screen, &pixel, GREEN);
              break;
            case 2:
              SDL_FillRect(screen, &pixel, BLUE);
              break;
            case 3:
              SDL_FillRect(screen, &pixel, PINK);
              break;
            default:
              SDL_FillRect(screen, &pixel, BLACK);
              break;
        }
    }

    //Draw Cluster Centers
    #ifdef WANT_CENTERS_DRAWN
        debug("Drawing cluster centers...");
        for(int i = 0; i < clusters; i++)
        {
            #ifdef MIRROR_Y
            if(cluster_centersy[i]*-1 + offset_y - 10  >= 0 && cluster_centersy[i]*-1 + offset_y + 10  <= WINH && cluster_centersx[i] + offset_x - 10  >= 0 && cluster_centersx[i] + offset_x + 10  <= WINW)
            {
            #else
            if(cluster_centersy[i] + offset_y - 10  >= 0 && cluster_centersy[i] + offset_y + 10  <= WINH && cluster_centersx[i] + offset_x - 10  >= 0 && cluster_centersx[i] + offset_x + 10  <= WINW)
            {//Causes a crash if a circle is drawn off the screen partially. I need a better circle function..
            #endif
                Uint32 col = 0;
                if(i == 0)
                    col = (ALPHA | RED);
                if(i == 1)
                    col = (ALPHA | GREEN);
                if(i == 2)
                    col = (ALPHA | BLUE);
                if(i >= 3)
                    col = (ALPHA | PINK);

                #ifdef MIRROR_Y
                    fill_circle(screen, cluster_centersx[i]+offset_x, (cluster_centersy[i]*-1+offset_y), 10, col);
                    //std::cout << "(" << cluster_centersx[i]+offset_x << "," << (cluster_centersy[i]*-1+offset_y) << ")\n";
                #else
                    fill_circle(screen, cluster_centersx[i]+offset_x, cluster_centersy[i]+offset_y, 10, col);
                #endif
            }
        }
    #endif			
}

/*
* SDL_Surface 32-bit circle-fill algorithm without using trig
*
* While I humbly call this "Celdecea's Method", odds are that the 
* procedure has already been documented somewhere long ago.  All of
* the circle-fill examples I came across utilized trig functions or
* scanning neighbor pixels.  This algorithm identifies the width of
* a semi-circle at each pixel height and draws a scan-line covering
* that width.  
*
* The code is not optimized but very fast, owing to the fact that it
* alters pixels in the provided surface directly rather than through
* function calls.
*
* WARNING:  This function does not lock surfaces before altering, so
* use SDL_LockSurface in any release situation.
*/
void fill_circle(SDL_Surface *surface, int cx, int cy, int radius, Uint32 pixel) {
   // Note that there is more to altering the bitrate of this 
   // method than just changing this value.  See how pixels are
   // altered at the following web page for tips:
   //   http://www.libsdl.org/intro.en/usingvideo.html
   static const int BPP = 4;

   double r = (double)radius;

   for (double dy = 1; dy <= r; dy += 1.0)
   {
       // This loop is unrolled a bit, only iterating through half of the
       // height of the circle.  The result is used to draw a scan line and
       // its mirror image below it.
       // The following formula has been simplified from our original.  We
       // are using half of the width of the circle because we are provided
       // with a center and we need left/right coordinates.
       double dx = floor(sqrt((2.0 * r * dy) - (dy * dy)));       
       int x = cx - dx;
       // Grab a pointer to the left-most pixel for each half of the circle
       Uint8 *target_pixel_a = (Uint8 *)surface->pixels + ((int)(cy + r - dy)) * surface->pitch + x * BPP;
       Uint8 *target_pixel_b = (Uint8 *)surface->pixels + ((int)(cy - r + dy)) * surface->pitch + x * BPP;
               
       for (; x <= cx + dx; x++)
       {
           *(Uint32 *)target_pixel_a = pixel;
           *(Uint32 *)target_pixel_b = pixel;
           target_pixel_a += BPP;
           target_pixel_b += BPP;
       }
   }
}
예제 #26
0
int main(int argc, char** argv)
{
	color_t pikachu[24][28] = {	
		{BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA},
		{BLA, BLA, BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA, BLA, BLA},
		{BLA, BLA, BLA, YEL, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, YEL, BLA, BLA, BLA},
		{BLA, BLA, BLA, YEL, YEL, BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA, YEL, YEL, BLA, BLA, BLA},
		{WHI, BLA, BLA, YEL, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, YEL, BLA, BLA, WHI},
		{WHI, BLA, BLA, YEL, YEL, YEL, YEL, YEL, BLA, BLA, WHI, WHI, BLA, BLA, BLA, BLA, WHI, WHI, BLA, BLA, YEL, YEL, YEL, YEL, YEL, BLA, BLA, WHI},
		{WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI},
		{WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI},
		{WHI, WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, YEL, BLA, WHI, BLA, BLA, YEL, YEL, YEL, YEL, YEL, YEL, BLA, BLA, WHI, BLA, YEL, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, YEL, BLA, BLA, BLA, BLA, YEL, YEL, YEL, YEL, YEL, YEL, BLA, BLA, BLA, BLA, YEL, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, BLA, YEL, YEL, RED, RED, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, YEL, RED, RED, YEL, YEL, BLA, WHI, WHI, WHI},
		{WHI, WHI, WHI, BLA, YEL, RED, RED, RED, RED, YEL, YEL, BLA, YEL, BLA, BLA, YEL, BLA, YEL, YEL, RED, RED, RED, RED, YEL, BLA, WHI, WHI, WHI},
		{WHI, WHI, WHI, BLA, YEL, RED, RED, RED, RED, YEL, YEL, YEL, BLA, BLA, BLA, BLA, YEL, YEL, YEL, RED, RED, RED, RED, YEL, BLA, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, BLA, YEL, RED, RED, YEL, YEL, YEL, YEL, BLA, RED, RED, BLA, YEL, YEL, YEL, YEL, RED, RED, YEL, BLA, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, BLA, YEL, YEL, YEL, YEL, YEL, YEL, BLA, RED, RED, BLA, YEL, YEL, YEL, YEL, YEL, YEL, BLA, WHI, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA, YEL, YEL, YEL, YEL, YEL, BLA, BLA, YEL, YEL, YEL, YEL, YEL, BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA, BLA, YEL, YEL, YEL, YEL, YEL, YEL, BLA, BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI},
		{WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, BLA, BLA, BLA, BLA, BLA, BLA, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI, WHI}
	};
	char key;
	char *dance = "Let's dance!!";
	char *exit = "n => EXIT";
	int swip = 0;
	int pika = 0;

	init_graphics();


	sleep_ms(20);

	char* s = "Hello PIKACHU!!!";
	draw_text(50, 30, s, YEL);
	clear_screen();	
	int i, j;
/*
	for (i = 0; i < 24; i++)
	{
		for (j = 0; j < 28; j++)
		{
			draw_rect((50+j*8), (50+i*8), 8, 8, pikachu[i][j]);
			fill_circle((350+j*8), (50+i*8), 4, pikachu[i][j]);
		}
	}
*/
	sleep_ms(200000000);
	char* start = "Want to see pikachu dance? (y => YES; n => EXIT)";
	draw_text(50, 30, s, BLA);
	draw_text(50, 30, start, YEL);
	
	for (i = 0; i < 24; i++)
			{
				for (j = 0; j < 28; j++)
				{
					draw_rect((50+j*8), (50+i*8), 8, 8, pikachu[i][j]);
					fill_circle((350+j*8), (50+i*8), 4, pikachu[i][j]);
				}
			}
	
	do
	{

		key = getkey();
		if(key == 'y')
			pika = 1;
		if(key == 'n')
			pika = 0;

		if (pika == 1)
		{
			clear_screen();
			fill_rect(50, 30, 400, 16, BLA);
			fill_rect(40, 30, 600, 400, BLA);

			if (swip == 0)
			{
				for (i = 0; i < 24; i++)
				{
					for (j = 0; j < 28; j++)
					{
						fill_circle((350+j*8), (50+i*8), 8, pikachu[i][j]);
					}
				}
				swip = 1;
			}
			else
			{
				for (i = 23; i >= 0; i--)
				{
					for (j = 27; j >= 0; j--)
					{
						fill_circle((50+j*8), (50+i*8), 8, pikachu[i][j]);
					}
				}
				swip = 0;
			}
			sleep_ms(900000000000000);

			draw_text(50, 350, exit, YEL);
		}


	} while(key != 'n');

/*
	int i, j;
	for (i = 0; i < 24; i++)
	{
		for (j = 0; j < 28; j++)
		{
			draw_rect((50+j*8), (50+i*8), 8, 8, pikachu[i][j]);
			fill_circle((350+j*8), (50+i*8), 4, pikachu[i][j]);
		}
	}
*/

	char *gb = "Goodbye!! PIKAPIKACHU!!";
//	draw_text(50, 30, start, BLA);
//	draw_text(50, 30, dance, BLA);
	draw_text(50, 350, exit, BLA);
//	fill_rect(50, 30, 400, 16, BLA);
	fill_rect(50, 30, 400, 16, BLA);
	fill_rect(30, 20, 600, 400, BLA);
	draw_text(50, 30, gb, YEL);
	exit_graphics();	

	return 0;
}