Ejemplo n.º 1
0
void main_draw_shape(struct template_t *tmp_tpl) {
	char *sval = NULL;
	if(template_get_setting_string(tmp_tpl, "shape", &sval) == 0) {
		int filled = 0, x = 0, y = 0, width = fb_width(), height = fb_height(), border = 0, fcolor = 0;
		int x1 = 0, x2 = 0, y1 = 0, y2 = 0, radius = 0, thickness = 1, zindex = 0;
		unsigned short *color = NULL;

		if(strcmp(sval, "rectangle") == 0 || strcmp(sval, "circle") == 0) {
			template_get_setting_number(tmp_tpl, "x", &x);
			template_get_setting_number(tmp_tpl, "y", &y);
			template_get_setting_number(tmp_tpl, "border", &border);
			template_get_setting_number(tmp_tpl, "filled", &filled);
		} else if(strcmp(sval, "line") == 0) {
			template_get_setting_number(tmp_tpl, "x1", &x1);
			template_get_setting_number(tmp_tpl, "x2", &x2);
			template_get_setting_number(tmp_tpl, "y1", &y1);
			template_get_setting_number(tmp_tpl, "y2", &y2);
			template_get_setting_number(tmp_tpl, "thickness", &thickness);
		}
		if(strcmp(sval, "rectangle") == 0) {
			template_get_setting_number(tmp_tpl, "width", &width);
			template_get_setting_number(tmp_tpl, "height", &height);
		} else if(strcmp(sval, "circle") == 0) {
			template_get_setting_number(tmp_tpl, "radius", &radius);
		}

		if(template_get_setting_color(tmp_tpl, "color", &color) != 0) {
			color = malloc(sizeof(unsigned short)*3);
			color[0] = 0, color[1] = 0, color[2] = 0;
			fcolor = 1;
		}

		template_get_setting_number(tmp_tpl, "z-index", &zindex);

		if(nodaemon == 0) {
			if(strcmp(sval, "rectangle") == 0) {
				if(filled) {
					draw_rectangle_filled(x, y, zindex, width, height, draw_color(color[0], color[1], color[2]));
				} else {
					draw_rectangle(x, y, zindex, width, height, border, draw_color(color[0], color[1], color[2]));
				}
			} else if(strcmp(sval, "circle") == 0) {
				if(filled) {
					draw_circle_filled(x, y, zindex, radius, draw_color(color[0], color[1], color[2]));
				} else {
					draw_circle(x, y, zindex, radius, border, draw_color(color[0], color[1], color[2]));
				}
			} else if(strcmp(sval, "line") == 0) {
				draw_line(x1, y1, x2, y2, zindex, thickness, draw_color(color[0], color[1], color[2]));
			}
		}
		if(fcolor) {
			free(color);
		}
	}
}
Ejemplo n.º 2
0
//--- colors to shift: blue, red,  green 
void Rainbowduino::draw_row(byte row, byte level, byte r, byte b, byte g) {
  disable_oe;
  enable_row(row);
  le_high;
  draw_color( (current_level < level) ? b : 0 );
  draw_color( (current_level < level) ? r : 0 );
  draw_color( (current_level < level) ? g : 0 );
  le_low;
  enable_oe;
}
Ejemplo n.º 3
0
//==============================================================
void Rainbowduino::draw_row(byte row, byte level, byte r, byte b, byte g) {
  enable_row(row);
  for(byte i = 0; i < 32; i++) {
    disable_oe;
    le_high;
    draw_color( (i < level) ? b : 0 );
    draw_color( (i < level) ? r : 0 );
    draw_color( (i < level) ? g : 0 );
    le_low;
    enable_oe;
  }
}
Ejemplo n.º 4
0
void		julia(t_env *e)
{
	int		x;
	int		y;
	int		i;
	double	tmp;

	x = -1;
	while (++x < e->img_x)
	{
		y = -1;
		while (++y < e->img_y)
		{
			e->j->z_r = x / e->j->zoom_x + e->j->min_x;
			e->j->z_i = y / e->j->zoom_y + e->j->min_y;
			i = 0;
			while (pow(e->j->z_r, 2) + pow(e->j->z_i, 2) <= 4 && i < EJ(i_max))
			{
				tmp = e->j->z_r;
				e->j->z_r = pow(e->j->z_r, 2) - pow(e->j->z_i, 2) + e->j->c_r;
				e->j->z_i = 2 * e->j->z_i * tmp + e->j->c_i;
				i++;
			}
			if (i != e->j->i_max)
				draw_color(e, i, x, y);
		}
	}
}
Ejemplo n.º 5
0
void	draw(t_display *d, int x, int color)
{
	if (d->map->map[d->ray->map_y][d->ray->map_x] == '1')
		draw_color(d, x, color);
	else
		draw_tex(d, x);
}
Ejemplo n.º 6
0
int main() {
     char filename[] = "cardioid.png";
     struct image *i;
     int x,y;
     double a, r;

     i = draw_create_image(300,300);

     draw_full(i, white);

     draw_color(i, black);
     for(x=-4;x<=4;x++) draw_textf(i, 150+x*30+3,150+3, 1, "%d", x);
     for(y=-4;y<=4;y++) draw_textf(i, 150+3,150-y*30+4, 1, "%d", y);

     draw_color(i,blue);
     for(x=0;x<300;x+=30) draw_line(i, x,0, x,i->height-1);
     for(y=0;y<300;y+=30) draw_line(i, 0,y, i->width-1,y);
     draw_box(i, 0,0, i->width-1,i->height-1);
     
     draw_color(i, black);

     for(x=-1;x<=1;x++)     
       draw_line(i, 150+x,0, 150+x,i->height-1);
     for(y=-1;y<=1;y++)     
       draw_line(i, 0,150+y, i->width-1,150+y);
     
     draw_color(i, green);
     
     /* Cardioid */
     for(a = 0.0; a < 360.0; a += 0.5) {
       r = 0.0 - sin(0.5*a/180*M_PI)*120.0;
       draw_pixel(i, 150+sin(a/180*M_PI)*r, 150+cos(a/180*M_PI)*r, red);
     }

     draw_color(i, black);
     draw_textf(i, 5,i->height-16-2, 2, "Cardioid");

     draw_write_png(i, filename);

     draw_free_image(i);

     return 0;
}
	System::Void DetailVisualization::Render(int detail_width,int detial_height){
			wglmakecur();

			windowWidth[2] = detail_width;
			windowHeight[2] = detial_height;

			glClearColor(0.0, 0.0, 0.0, 0.0);  //Set the cleared screen colour to black
			glViewport(0, 0, windowWidth[2], windowHeight[2]);   //This sets up the viewport so that the coordinates (0, 0) are at the top left of the window		
			glMatrixMode(GL_PROJECTION);
			glLoadIdentity();
			glOrtho(0, windowWidth[2], windowHeight[2], 0, -10, 10);

			//Back to the modelview so we can draw stuff 
			glMatrixMode(GL_MODELVIEW);
			glLoadIdentity();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the screen and depth buffer

			glTranslatef(0.0+move_x[2],0.0+move_y[2],0.0+move_z[2]);
			glScalef(scale_factor[2]+scale_x[2],scale_factor[2]+scale_y[2],scale_factor[2]+scale_z[2]);
			vector<float> color;
			color.resize(3);


			int x_position = 50;
			int y_position = 50;
			int t = 0;
			for(int i=0;i<6;i++)
			{
				if(preprocessing_data.data_dim_flag[i])
				{
					DrawTitle_FTGL(i,x_position,y_position);
					vector<float> draw_color(3);
					draw_color[0] = preprocessing_data.data_color[t][0];
					draw_color[1] = preprocessing_data.data_color[t][1];
					draw_color[2] = preprocessing_data.data_color[t][2];
					t++;
					RECTANGLE *rect;
					rect = new RECTANGLE();
					rect->h = 20.0;
					rect->w = 40.0;
					rect->x = x_position+50;
					rect->y = y_position+50;
					DrawRectWithOpenGL(rect,draw_color);	
					delete(rect);	

					y_position+=80;
				}
			}
			
			SwapOpenGLBuffers();
			
		}
Ejemplo n.º 8
0
void main_draw_text(struct template_t *tmp_tpl, char *ntext) {
	int x = 0, y = 0, size = 0, spacing = 0, ftext = 0, fcolor = 0, zindex = 0;
	int align = ALIGN_RIGHT, decoration = NONE;
	unsigned short *color = NULL;
	char *font = NULL, *text = NULL;

	template_get_setting_number(tmp_tpl, "x", &x);
	template_get_setting_number(tmp_tpl, "y", &y);
	template_get_setting_number(tmp_tpl, "spacing", &spacing);
	template_get_setting_number(tmp_tpl, "size", &size);
	template_get_setting_number(tmp_tpl, "z-index", &zindex);
	template_get_setting_string(tmp_tpl, "font", &font);
	if(!ntext) {
		template_get_setting_string(tmp_tpl, "text", &text);
	} else {
		text = malloc(strlen(ntext)+1);
		strcpy(text, ntext);
		ftext = 1;
	}

	template_get_setting_number(tmp_tpl, "align", &align);
	template_get_setting_number(tmp_tpl, "decoration", &decoration);

	if(template_get_setting_color(tmp_tpl, "color", &color) != 0) {
		color = malloc(sizeof(unsigned short)*3);
		color[0] = 255, color[1] = 255, color[2] = 255;
		fcolor = 1;
	}

	if(text) {
		prevMessage = realloc(prevMessage, strlen(text)+1);
		strcpy(prevMessage, text);
		if(nodaemon == 0) {
			draw_txt(x, y, zindex, font, (FT_UInt)size, text, draw_color(color[0], color[1], color[2]), spacing, decoration, align);
		}
	}

	if(fcolor) {
		free(color);
	}
	if(ftext) {
		free(text);
	}
}
void display()
{
	glClearColor(0.0, 0.0, 0.0, 0.0);  //Set the cleared screen colour to black
	glViewport(0, 0, windowSize[0], windowSize[1]);   //This sets up the viewport so that the coordinates (0, 0) are at the top left of the window

	//Set up the orthographic projection so that coordinates (0, 0) are in the top left
	//and the minimum and maximum depth is -10 and 10. To enable depth just put in
	//glEnable(GL_DEPTH_TEST)
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, windowSize[0], windowSize[1], 0, -10, 10);

	//Back to the modelview so we can draw stuff 
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the screen and depth buffer

	// draw histogram visualization
	glTranslatef(0.0+x_amount,0.0+y_amount,0.0+z_amount);
	glScalef(0.6+scale_amount,0.6+scale_amount,0.6+scale_amount);

	
	int y_coord = 1400;
	int pixels;
	int current_hour;
	int last_hour = -1;
	int t=0;
	//for(int i=0;i<preprocessing_data.histogram.rows;++i)
	for(int i=0;i<preprocessing_data.histogram.rows;++i)
	{
		//current_hour = preprocessing_data.hour_data[i];
		current_hour = preprocessing_data.month_vec[i].this_year;
		if(current_hour!=last_hour)
		{
			vector<float> draw_color(3);
			draw_color[0] = 1; 
			draw_color[1] = 1; 
			draw_color[2] = 1;
			RECTANGLE *line;
			line = new RECTANGLE();
			line->h = 3;
			line->w = 1050;
			line->x = 0;
			line->y = y_coord - 5;
			DrawRectWithOpenGL(line,draw_color);
			//DrawText_FTGL(current_hour,20,y_coord-15);
			draw_color.clear();
			delete(line);
			t++;
			y_coord-=10;
		}		

		int start = 0;
		for(int k=0;k<preprocessing_data.histogram.cols;++k)
		{   
			vector<float> draw_color(3);
			if(preprocessing_data.histogram.at<int>(i,k)!=0)
			{
				pixels = preprocessing_data.histogram.at<int>(i,k);
				draw_color[0] = preprocessing_data.rgb_mat2.at<float>(k,0); 
				draw_color[1] = preprocessing_data.rgb_mat2.at<float>(k,1); 
				draw_color[2] = preprocessing_data.rgb_mat2.at<float>(k,2);
				for(int u=start;u<start+pixels;++u)
				{
					RECTANGLE *rect;
					rect = new RECTANGLE();
					rect->h = 5.0;
					rect->w = 2.0;
					rect->x = 110 + preprocessing_data.position.at<double>(i,0)/10.0 + (double)u*2.0;
					rect->y = y_coord;
					DrawRectWithOpenGL(rect,draw_color);	
					delete(rect);
				}			
				start += pixels;
			}	
			draw_color.clear();
		}

		y_coord-=5;

		last_hour = current_hour;
	}
	
	glutSwapBuffers(); // Swap front and back buffers
	
} 
Ejemplo n.º 10
0
void monitor_tools(int n,int t)
{
	getmousepos(&button,&mousex,&mousey);
	for(;mousey<20;getmousepos(&button,&mousex,&mousey))
	{
	       if((mousex/20>0)&&(mousex/20)<=n&&(mousex/20)!=button_track)
	       {
			button_track=mousex/20;
			top_panel_buttons(n,button_track,2);
			if(t==0)
			{
				hidemouseptr();
				settextstyle(0,0,1);
				if(cur_color==0)
					setcolor(WHITE);
				else
					setcolor(BLACK);
				hover_text(mousex/20);
				showmouseptr();
			}
	       }
	       else if(mousex<20&&button==1&&t!=0)
	       {
			cur_panel=0;
			t=0;
			cur_style=1;
			n=tool_but_num;
			button_hover(2,2,18,18);
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
		   }
		   else if(t==0&&mousex>619&&button==1)
			{
				button_hover(620,2,638,18);
				ask_exit();
			}
	       else if(((mousex/20)==0||(mousex/20>(n+1)))&&button_track!=-1)
			{
			button_track=-1;
			top_panel_buttons(n,0,2);
			if(t==0)
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
			else if(t==1)
			button_click((2+cur_style*20),2,(18+cur_style*20),18);
			}
		   if((mousex/20>0)&&(mousex/20)<=n&&button==1)
	       {
			if(t==0)
			{
			if(button_track!=18)
			cur_tool=button_track;
			button_hover((2+button_track*20),2,(18+button_track*20),18);
			if(button_track==18)
			{
			cur_panel=2;
		   draw_color();
			}
			draw_style();
			break;
			}
			else
			{
			cur_style=button_track;
			button_hover((2+cur_style*20),2,(18+cur_style*20),18);
			}
	       }

	}
}
Ejemplo n.º 11
0
Archivo: etchy.c Proyecto: uiri/etchy
int main(void) {
	int ch, xc, yc, max_y, max_x, color;
	color = 1;

	init(); /* initialize curses */
	getmaxyx(stdscr, max_y, max_x);

	xc = yc = 0; /* Set initial position */
	while(1) {
		
		/* ch = key pressed */
		ch = getch(); 

		switch(ch) {
			/*
			 * Movement keys
			 * Draws a coloured box
			 */
			case KEY_UP:
				if(yc > 0) {
					draw_color(color);
					move(--yc, xc);
				}
				break;
			case KEY_DOWN:
				if(yc < max_y - 1) {
					draw_color(color);
					move(++yc, xc);
				}
				break;
			case KEY_LEFT:
				if(xc > 0) {
					draw_color(color);
					move(yc, --xc);
				}
				break;
			case KEY_RIGHT:
				if(xc < max_x - 1) {
					draw_color(color);
					move(yc, ++xc);
				}
				break;

			/*
			 * Color keys
			 * 
			 * Macro for f-key case statement below
			 */
			#define F_MACRO(i) case KEY_F(i):color = i;break;

			F_MACRO(1);
			F_MACRO(2);
			F_MACRO(3);
			F_MACRO(4);
			F_MACRO(5);
			F_MACRO(6);
			F_MACRO(7);
			F_MACRO(8);

			default:
				/* Printable ascii chars */
				if(ch >= ' ' && ch <= '~') {
					if(xc < max_x - 1) {
						attron(COLOR_PAIR(color));
						addch(ch);
						attroff(COLOR_PAIR(color));
						move(yc, ++xc);
					} else if(yc < max_y - 1) {
						attron(COLOR_PAIR(color));
						addch(ch);
						attroff(COLOR_PAIR(color));
						/* set coords to beginning of next line */
						xc = 0;
						move(++yc, xc);
					}
				}
		}

		/* redraw ncurses screen */
		refresh();
	}
}
Ejemplo n.º 12
0
void main_draw_black(void) {
	if(nodaemon == 0) {
		draw_rectangle_filled(0, 0, -1, fb_width(), fb_height(), draw_color(0, 0, 0));
	}
}
Ejemplo n.º 13
0
static void draw_camera(int i, int j, int f, float a)
{
    struct camera *c = get_camera(i);

    init_camera(i);

    if (c->frame)
    {
        /* Apply a basic projection for offscreen rendering. */

        glMatrixMode(GL_PROJECTION);
        {
            glPushMatrix();
            glLoadIdentity();

            if (c->type == CAMERA_ORTHO)
                glOrtho  (c->l, c->r, c->b, c->t, c->n, c->f);
            else
                glFrustum(c->l, c->r, c->b, c->t, c->n, c->f);
        }
        glMatrixMode(GL_MODELVIEW);
        {
            glPushMatrix();
            glLoadIdentity();
        }

        /* Render the scene to the offscreen buffer. */

        glPushAttrib(GL_VIEWPORT_BIT | GL_SCISSOR_BIT);
        {
            int w = get_image_w(c->image);
            int h = get_image_h(c->image);

            glViewport(0, 0, w, h);
            glScissor (0, 0, w, h);

            opengl_push_framebuffer(c->frame);
            {
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                draw_scene(j, f, a);
            }
            opengl_pop_framebuffer();
        }
        glPopAttrib();

        /* Revert the projection. */

        glMatrixMode(GL_PROJECTION);
        glPopMatrix();

        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
    }
    else
    {
        int eye;
        int tile;
        int pass;

        /* Iterate over all tiles of this host. */

        for (tile = 0; tile < (int) get_tile_count(); ++tile)
        {
            float d[2][3];

            /* Iterate over the eyes. */

            get_eye_pos(d[0], c, 0, tile);
            get_eye_pos(d[1], c, 1, tile);

            for (eye = 0; eye < (c->mode ? 2 : 1); ++eye)
            {
                camera_eye = eye;
                
                if (draw_tile(c, eye, tile, d[eye]))
                {
                    pass = 0;

                    /* Iterate over all passes of this eye and tile. */
                    
                    while ((pass = draw_pass(c->mode, eye, tile, pass, d)))
                    {
                        if      (get_tile_flags(tile) & TILE_TEST_COLOR)
                            draw_color(j, eye);
                        else if (get_tile_flags(tile) & TILE_TEST_GHOST)
                            draw_ghost(j, eye);
                        else
                            draw_scene(j, f, a);
                    }
                }
            }
        }

        /* HACK */

        if (c->mode != STEREO_VARRIER_00)
            opengl_set_fence();
    }
}
Ejemplo n.º 14
0
void ColorShades::onPaint(ui::PaintEvent& ev)
{
  auto theme = skin::SkinTheme::instance();
  ui::Graphics* g = ev.graphics();
  gfx::Rect bounds = clientBounds();

  theme->paintWidget(g, this, style(), bounds);

  bounds.shrink(3*ui::guiscale());

  gfx::Rect box(bounds.x, bounds.y, m_boxSize*ui::guiscale(), bounds.h);

  Shade colors = getShade();
  if (colors.size() >= 2) {
    gfx::Rect hotBounds;

    int j = 0;
    for (int i=0; box.x<bounds.x2(); ++i, box.x += box.w) {
      // Make the last box a little bigger to just use all
      // available size
      if (i == int(colors.size())-1) {
        if (bounds.x+bounds.w-box.x <= m_boxSize+m_boxSize/2)
          box.w = bounds.x+bounds.w-box.x;
      }

      app::Color color;

      if (m_dragIndex >= 0 &&
          m_hotIndex == i) {
        color = colors[m_dragIndex];
      }
      else {
        if (j == m_dragIndex) {
          ++j;
        }
        if (j < int(colors.size()))
          color = colors[j++];
        else
          color = app::Color::fromMask();
      }

      draw_color(g, box, color,
                 (doc::ColorMode)app_get_current_pixel_format());

      if (m_hotIndex == i)
        hotBounds = box;
    }

    if (!hotBounds.isEmpty() &&
        isHotEntryVisible()) {
      hotBounds.enlarge(3*ui::guiscale());

      ui::PaintWidgetPartInfo info;
      theme->paintWidgetPart(
        g, theme->styles.shadeSelection(), hotBounds, info);
    }
  }
  else {
    g->fillRect(theme->colors.editorFace(), bounds);
    g->drawAlignedUIText(text(), theme->colors.face(), gfx::ColorNone, bounds,
                         ui::CENTER | ui::MIDDLE);
  }
}