Esempio n. 1
0
void RecordMonitorGUI::
display_video_text(int x, int y, const char *text, int font,
	int bg_color, int color, int alpha, double secs, double scale)
{
	lock_window("RecordMonitorGUI::display_text");
	set_font(font);
	int ch = get_text_height(font);
	int h = get_text_height(font,text) + ch/2;
	int w = get_text_width(font, text) + ch;
	BC_Pixmap pixmap(this, w, h);
	set_opaque();
	set_color(bg_color);
	draw_box(0, 0, w, h, &pixmap);
	set_color(color);
	draw_text(ch/2, ch, text, strlen(text), &pixmap);
	BC_Bitmap bitmap(this, w, h, BC_RGB888, 0);
	VFrame in(&bitmap, w, h, BC_RGB888, -1);
	Drawable drawable = pixmap.get_pixmap();
	bitmap.read_drawable(drawable, 0, 0, &in);
	unlock_window();
	record->display_vframe(&in, x, y, alpha, secs, scale);
}
Esempio n. 2
0
void FontRenderer::print(const wchar_t* _str, euint32 _num_chars, vptr _target, euint32 _x, euint32 _y, euint32 _w)
{
    FT_GlyphSlot slot = m_ft_face->glyph;
    FT_UInt glyph_index;
    FT_UInt error;

    euint32 n;
    m_char_ptr = 0;
    for ( n = 0; n < _num_chars; n++ )
    {
        glyph_index = FT_Get_Char_Index( m_ft_face, _str[n] );

        error = FT_Load_Glyph( m_ft_face, glyph_index, FT_LOAD_DEFAULT );

        if ( error )
        {
            continue;
        }

        /// 加粗函数 FT_Outline_Embolden( &m_ft_face->glyph->outline, 100 );

        error = FT_Render_Glyph( m_ft_face->glyph, FT_RENDER_MODE_NORMAL );

        if ( error )
        {
            continue;
        }

        draw_text( &slot->bitmap, _target, _x, _y, _w);
        if (0xff00 & _str[n])
        {
            m_char_ptr += m_pixel_size;
        }
        else
        {
            m_char_ptr += m_pixel_size/2;
        }
    }
}
Esempio n. 3
0
//change the text appearing in the header
void change_text(int j, color_t c)
{
	//clear text
	fill_rect(61, 41, 518, 18, colors[5]);
	//if color is black, make it white
	if(c == colors[5])
		c = getColor(31, 63, 31);
	//draw new text
	switch(j)
	{
		case 0:
			draw_text(64, 44, "It'sa meeee!", c);
			break;
		case 1:
			draw_text(64, 44, "Princess in another castle.", c);
			break;
		case 2:
			draw_text(64, 44, "Stomp more goombas.", c);
			break;
		case 3:
			draw_text(64, 44, "Where's Luigi?", c);
			break;
		case 4:
			draw_text(64, 44, "I sure wish I had a gokart.", c);
			break;
		case 5:
			draw_text(64, 44, "It's dangerous to go alone.", c);
			break;
		case 6:
			draw_text(64, 44, "Bowser is a jerk.", c);
			break;
		case 7:
			draw_text(64, 44, "Have I ever done any actual plumbing?", c);
			break;
	}
}
Esempio n. 4
0
void
on_Suspend_clicked                     (GtkButton       *button,
                                       gpointer         user_data)
{
  char *cmd, buf[3], *name;
  int i, size;

  name = xmlGetProp(table[cur_pid].page.curr, "name");
  size = strlen(exec_path) + strlen(" -n ") + sizeof(cur_pid) + strlen(buf) + strlen(" ")
  	+ strlen(name) + strlen(" suspend ") + 1;
  cmd = (char *) malloc (size);

  strcpy (cmd, exec_path);
  strcat (cmd, " -n ");
  sprintf(buf, "%d", cur_pid);
  strcat (cmd, buf);
  strcat (cmd, " ");
  strcat (cmd, name);
  strcat (cmd, " suspend ");
  runPeos(cmd);
  free(cmd);
  cmd = NULL;

  freeAll_extra();

  draw_tree (cur_pid);
  for ( i = 0; i < counting_action; i++) {
	if (strcmp (xmlGetProp (linklist[cur_pid][i].cur, "state"), "SUSPEND") == 0) {
 		table[cur_pid].page.curr = linklist[cur_pid][i].cur;
		if((GTK_IS_WIDGET (table[cur_pid].page.tree1) && 
			GTK_IS_TREE (GTK_TREE (table[cur_pid].page.tree1))))
			gtk_tree_select_child ( GTK_TREE (table[cur_pid].page.tree1), linklist[cur_pid][i].item);
		break;	
	}
  }
  draw_text (table[cur_pid].page.curr);
  check_state();
}
Esempio n. 5
0
void d3d_control::render_frame(void)
{
    // clear the window to a deep blue
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
    d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

	//change wireframe mode
	if( fillmode_changed ){
		if( !is_solid ){
			d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
		}
		else{
			d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
		}
		is_solid = !is_solid;
		fillmode_changed=false;
	}

    d3ddev->BeginScene();    // begins the 3D scene

	// select which vertex format we are using
	d3ddev->SetFVF(CUSTOMFVF);

	//set transform
	view_transform();
    projection_transform();

    // set the world transform
	D3DXMATRIX matLocal;
	D3DXMatrixIdentity(&matLocal);
	draw_axis( matLocal );
	draw_text();
	
	rs.draw();

    d3ddev->EndScene();    // ends the 3D scene
	d3ddev->Present(NULL, NULL, NULL, NULL);   // displays the created frame on the screen
}
Esempio n. 6
0
void WormHoleRadioDevice::visualize() {
#ifdef WANT_GLUT
  if (parent->is_show_backoff) {
    glPushMatrix();
    container->text_scale(); // prepare to draw text
    char buf[20];
    palette->use_color(RadioSim::RADIO_BACKOFF);
    sprintf(buf, "N/A");
    draw_text(1, 1, buf);
    glPopMatrix();
  }

  if(parent->is_show_connectivity) { // draw network connections
    // setup line properties
    bool local_sharp=(parent->connect_display_mode==1 && 
                      container->is_selected);
    if(parent->connect_display_mode==2 || local_sharp) {
      palette->use_color(RadioSim::NET_CONNECTION_SHARP);
      glLineWidth(1);
    } else {
      palette->use_color(RadioSim::NET_CONNECTION_FUZZY);
      glLineWidth(4);
    }
    // do the actual draw
    glBegin(GL_LINES);
    const flo *me = container->body->position();
    for(typeof(nbrs.begin()) it = nbrs.begin(); it != nbrs.end(); it++) {
      if((local_sharp || (*it)->container->uid > container->uid)) {
        const flo *them = (*it)->container->body->position();
        glVertex3f(0,0,0);
        glVertex3f(them[0]-me[0], them[1]-me[1], them[2]-me[2]);
      }
    }
    glEnd();
    glLineWidth(1);
  }
#endif // WANT_GLUT
}
Esempio n. 7
0
void map_parcels_overlay::draw_cell(render_target* pCanvas, int iCanvasX,
                                   int iCanvasY, const level_map* pMap, int iNodeX,
                                   int iNodeY)
{
    const map_tile *pNode = pMap->get_tile(iNodeX, iNodeY);
    if(!pNode)
        return;
    if(font)
        draw_text(pCanvas, iCanvasX, iCanvasY, std::to_string((int)pNode->iParcelId));
    if(sprites)
    {
        uint16_t iParcel = pNode->iParcelId;
#define DIR(dx, dy, sprite) \
        pNode = pMap->get_tile(iNodeX + dx, iNodeY + dy); \
        if(!pNode || pNode->iParcelId != iParcel) \
            sprites->draw_sprite(pCanvas, sprite, iCanvasX, iCanvasY, 0)
        DIR( 0, -1, 18);
        DIR( 1,  0, 19);
        DIR( 0,  1, 20);
        DIR(-1,  0, 21);
#undef DIR
    }
}
Esempio n. 8
0
static void palette_draw_const(void)
{
        int n;

        draw_text("Predefined Palettes", 57, 25, 0, 2);

        for (n = 0; n < 7; n++) {
                draw_box(2, 13 + (5 * n), 8, 17 + (5 * n), BOX_THICK | BOX_INNER | BOX_INSET);
                draw_box(9, 13 + (5 * n), 19, 17 + (5 * n), BOX_THICK | BOX_INNER | BOX_INSET);
                draw_box(29, 13 + (5 * n), 35, 17 + (5 * n), BOX_THICK | BOX_INNER | BOX_INSET);
                draw_box(36, 13 + (5 * n), 46, 17 + (5 * n), BOX_THICK | BOX_INNER | BOX_INSET);
                draw_fill_chars(3, 14 + (5 * n), 7, 16 + (5 * n), n);
                draw_fill_chars(30, 14 + (5 * n), 34, 16 + (5 * n), n + 7);
        }

        draw_box(56, 13, 62, 17, BOX_THICK | BOX_INNER | BOX_INSET);
        draw_box(63, 13, 73, 17, BOX_THICK | BOX_INNER | BOX_INSET);
        draw_box(56, 18, 62, 22, BOX_THICK | BOX_INNER | BOX_INSET);
        draw_box(63, 18, 73, 22, BOX_THICK | BOX_INNER | BOX_INSET);
        draw_box(55, 26, 77, 47, BOX_THICK | BOX_INNER | BOX_INSET);
        draw_fill_chars(57, 14, 61, 16, 14);
        draw_fill_chars(57, 19, 61, 21, 15);
}
Esempio n. 9
0
static bool
draw_refs(struct view *view, struct view_column *column, const struct ref *refs)
{
	if (!column->opt.commit_title.refs || !refs)
		return false;

	for (; refs; refs = refs->next) {
		const struct ref *ref = refs;
		enum line_type type = get_line_type_from_ref(ref);
		const struct ref_format *format = get_ref_format(opt_reference_format, ref);

		if (!strcmp(format->start, "hide:") && !*format->end)
			continue;

		if (draw_formatted(view, type, "%s%s%s", format->start, ref->name, format->end))
			return true;

		if (draw_text(view, LINE_DEFAULT, " "))
			return true;
	}

	return false;
}
Esempio n. 10
0
File: text.c Progetto: sebseb7/oled
void draw_number(uint8_t x, uint8_t y, int32_t number, uint8_t length, uint8_t pad, uint8_t r, uint8_t g , uint8_t b)
{

	char s[10];
	sprintf(s, "%d", number);
	int len = strlen(s);

	if (length < len) {
		int i;
		for (i = 0; i < length; i++) {
			draw_char(x, y, '*', r,g,b);
			x+=6;
		}
		return;
	}
	int i;
	for (i = 0; i < length - len; i++) {
		draw_char(x, y, pad, r,g,b);
		x+=6;
	}
	draw_text(x, y, (char*)s, r,g,b);

}
Esempio n. 11
0
  void perform_rendering(VertexSource& vs) {
    pixfmt_type pixf(rbuf_window());

    typedef agg::pixfmt_amask_adaptor<pixfmt_type, alpha_mask_type>
        pixfmt_amask_type;
    typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type;

    pixfmt_amask_type pixfa(pixf, m_alpha_mask);
    amask_ren_type rbase(pixfa);
    agg::renderer_scanline_aa_solid<amask_ren_type> ren(rbase);

    ren.color(agg::rgba(0.5, 0.0, 0, 0.5));

    start_timer();
    m_ras.reset();
    m_ras.add_path(vs);
    agg::render_scanlines(m_ras, m_sl, ren);
    double t1 = elapsed_time();

    char buf[100];
    sprintf(buf, "Render with AlphaMask: %.3fms", t1);
    draw_text(250, 5, buf);
  }
Esempio n. 12
0
void
Font::draw(Renderer *renderer, const std::string& text, const Vector& pos_,
           FontAlignment alignment, DrawingEffect drawing_effect, Color color,
           float alpha) const
{
  float x = pos_.x;
  float y = pos_.y;

  std::string::size_type last = 0;
  for(std::string::size_type i = 0;; ++i)
  {
    if (text[i] == '\n' || i == text.size())
    {
      std::string temp = text.substr(last, i - last);

      // calculate X positions based on the alignment type
      Vector pos = Vector(x, y);

      if(alignment == ALIGN_CENTER)
        pos.x -= get_text_width(temp) / 2;
      else if(alignment == ALIGN_RIGHT)
        pos.x -= get_text_width(temp);

      // Cast font position to integer to get a clean drawing result and
      // no blurring as we would get with subpixel positions
      pos.x = static_cast<int>(pos.x);

      draw_text(renderer, temp, pos, drawing_effect, color, alpha);

      if (i == text.size())
        break;

      y += char_height + 2;
      last = i + 1;
    }
  }
}
Esempio n. 13
0
void draw_osd(SDL_Surface *surface)
{
	char buffer[1024];
	snprintf(buffer, sizeof buffer,
			"[a]   - wave animation: %s\n" //toggle wave animation
			"[f]   - shading: %s\n" //smooth/flat
			"[g]   - model: %s\n" //torus, wave
			"[H/h] - shininess: %d\n" //increase/decrease
			"[l]   - lighting: %s\n" //toggle
			"[m]   - specular mode: %s\n" //Blinn-Phong or Phong
			"[n]   - normals: %s\n" //enabled/disabled
			"[o]   - OSD option: %s\n" //cycle through
			"[p]   - per pixel lighting: %s\n" //per vertex/per pixel
			"[s]   - shaders: %s\n"
			"[T/t] - tessellation: %d\n" //increase/decrease
			"[v]   - local viewer: %s\n"
			"[w]   - wireframe: %s\n" //enabled/disabled
			"[k]   - light type: %s\n", //directional/point
			renderstate.animate ? "enabled" : "disabled", // shaders, // wave animation
			renderstate.shading ? "Smooth" : "Flat",   // shading
			object_names[renderstate.object],   // model
			(int) material_shininess,          // shininess
			renderstate.lighting ? "enabled" : "disabled",
			renderstate.specularMode ? "Phong" : "Blinn-Phong",
			"todo", // normals
			"enabled", // OSD option
			renderstate.perPixel ? "enabled" : "disabled", // lighting mode
			/* shaders */
			renderstate.shaders ? "enabled" : "disabled", // shaders
			tessellation,
			renderstate.lightModel ? "enabled" : "disabled", // local viewer
			/* wireframe */
			renderstate.wireframe ? "enabled" : "disabled",
			renderstate.lightType ? "directional" : "point"); // lighting mode
	draw_text(surface, buffer, 0, 30);
}
Esempio n. 14
0
static void replayview_draw_stagemenu(MenuData *m) {
	float alpha = 1 - m->fade;
	int i;
	
	float height = (1+m->ecount) * 20;
	float width  = 100;
	
	glPushMatrix();
	glTranslatef(SCREEN_W*0.5, SCREEN_H*0.5, 0);
	glScalef(width, height, 1);
	glColor4f(0.1, 0.1, 0.1, 0.7 * alpha);
	draw_quad();
	glPopMatrix();
	
	glPushMatrix();
	glTranslatef(SCREEN_W*0.5, (SCREEN_H-(m->ecount-1)*20)*0.5, 0);
	
	for(i = 0; i < m->ecount; ++i) {
		MenuEntry *e = &(m->entries[i]);
		float a = e->drawdata += 0.2 * ((i == m->cursor) - e->drawdata);
		
		if(e->action == NULL)
			glColor4f(0.5, 0.5, 0.5, 0.5 * alpha);
		else {
			float ia = 1-a;
			glColor4f(0.9 + ia * 0.1, 0.6 + ia * 0.4, 0.2 + ia * 0.8, (0.7 + 0.3 * a) * alpha);
		}
		
		if(i == m->cursor)
			pickedstage = i;
		
		draw_text(AL_Center, 0, 20*i, e->name, _fonts.standard);
	}
	
	glPopMatrix();
}
Esempio n. 15
0
void backlight_main()
{
  InputEvent  ev;

  counter3_overflow_hook = when_counter3_overflows;

  draw_text( FONT_WIDTH*(50-20)/2, FONT_HEIGHT*(17-1)/2, WHITE, 1, "Backlight-experiment");

  value = 0;
  target_value = 100;
  while ( value != target_value)
  {
    __WFE(); // Go to low-power mode until counter3 overflows
    __Set( BEEP_VOLUME, value);
  }
  target_value = 0;
  while ( value != target_value)
  {
    __WFE();
    __Set( BEEP_VOLUME, value);
  }

  while( should_run)
  {
    check_event( &ev);
    if ( BUTTON4 == ev.input)
      should_run = false;

    while ( value != target_value)
    {
      __WFE();
      __Set( BACKLIGHT, value);
    }
    target_value = (100 == value) ? 0 : 100;
  }
}
Esempio n. 16
0
void TextCanvas::draw(QPainter & p) {
    if (! visible()) return;

    QColor bgcolor = p.backgroundColor();
    QPen fgcolor = p.pen();

    if (bg_c == UmlTransparent)
        p.setBackgroundMode(::Qt::TransparentMode);
    else {
        p.setBackgroundMode(::Qt::OpaqueMode);
        p.setBackgroundColor(color(bg_c));
    }

    if (fg_c != UmlTransparent)
        p.setPen(color(fg_c));

    QRect r = rect();

    p.setFont(the_canvas()->get_font(itsfont));
    p.drawText (r.left(), r.top(), r.width(), r.height(),
                ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::WordBreak, text);

    FILE * fp = svg();

    if (fp != 0)
        draw_text (r.left(), r.top(), r.width(), r.height(),
                   ::Qt::AlignLeft + ::Qt::AlignTop + ::Qt::WordBreak,
                   text, p.font(), fp, fg_c, bg_c);

    p.setFont(the_canvas()->get_font(UmlNormalFont));
    p.setBackgroundColor(bgcolor);
    p.setPen(fgcolor);

    if (selected())
        show_mark(p, r);
}
Esempio n. 17
0
int main(int argc, char **argv)
{
	cairo_t *cr;
	char *filename;
	cairo_status_t status;
	cairo_surface_t *surface;

	if (argc != 2)
	{
		g_printerr("Usage: cairosimple OUTPUT_FILENAME\n");
		return 1;
	}

	filename = argv[1];

	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
		2 * RADIUS, 2 * RADIUS);
	cr = cairo_create(surface);


	cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
	cairo_paint(cr);
	draw_text(cr);
	cairo_destroy(cr);

	status = cairo_surface_write_to_png(surface, filename);
	cairo_surface_destroy(surface);

	if (status != CAIRO_STATUS_SUCCESS)
	{
		g_printerr("Could not save png to '%s'\n", filename);
		return 1;
	}

	return 0;
}
Esempio n. 18
0
void Display::update_gps()
{
    switch (AP_Notify::flags.gps_status) {
    case AP_GPS::NO_GPS:
        draw_text(COLUMN(0), ROW(3), "GPS:    no GPS");
        break;
    case AP_GPS::NO_FIX:
        draw_text(COLUMN(0), ROW(3), "GPS:    no fix");
        break;
    case AP_GPS::GPS_OK_FIX_2D:
        draw_text(COLUMN(0), ROW(3), "GPS:    2D    ");
        break;
    case AP_GPS::GPS_OK_FIX_3D:
        draw_text(COLUMN(0), ROW(3), "GPS:    3D    ");
        break;
    case AP_GPS::GPS_OK_FIX_3D_DGPS:
        draw_text(COLUMN(0), ROW(3), "GPS:    DGPS  ");
        break;
    case AP_GPS::GPS_OK_FIX_3D_RTK:
        draw_text(COLUMN(0), ROW(3), "GPS:    RTK   ");
        break;
    }
}
Esempio n. 19
0
int main(int argc, char **argv)
{
    struct GModule *module;
    struct
    {
	struct Option *text;
	struct Option *size;
	struct Option *fgcolor;
	struct Option *bgcolor;
	struct Option *line;
	struct Option *at;
	struct Option *rotation;
	struct Option *align;
	struct Option *linespacing;
	struct Option *font;
	struct Option *path;
	struct Option *charset;
	struct Option *input;
    } opt;
    struct
    {
	struct Flag *p;
	struct Flag *g;
	struct Flag *b;
	struct Flag *r;
	struct Flag *s;
    } flag;

    /* options and flags */
    char *text;
    double size;
    double x, y;
    int line;
    double rotation;
    char align[3];
    double linespacing;

    char bold;

    /* window info */
    struct rectinfo win;

    /* command file */
    FILE *cmd_fp;

    char buf[512];

    int first_text;
    int linefeed;
    int set_l;
    double orig_x, orig_y;
    double prev_x, prev_y;
    double set_x, set_y;
    double east, north;
    int do_background, fg_color, bg_color;

    /* initialize the GIS calls */
    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("display"));
    G_add_keyword(_("cartography"));
    module->description =
	_("Draws text in the active display frame on the graphics monitor using the current font.");

    opt.text = G_define_option();
    opt.text->key = "text";
    opt.text->type = TYPE_STRING;
    opt.text->required = NO;
    opt.text->description = _("Text to display");
    opt.text->guisection = _("Input");

    opt.input = G_define_standard_option(G_OPT_F_INPUT);
    opt.input->required = NO;
    opt.input->description = _("Input file");
    opt.input->guisection = _("Input");

    opt.fgcolor = G_define_option();
    opt.fgcolor->key = "color";
    opt.fgcolor->type = TYPE_STRING;
    opt.fgcolor->answer = DEFAULT_COLOR;
    opt.fgcolor->required = NO;
    opt.fgcolor->description =
	_("Text color, either a standard GRASS color or R:G:B triplet");
    opt.fgcolor->gisprompt = "old_color,color,color";
    opt.fgcolor->guisection = _("Text");

    opt.bgcolor = G_define_option();
    opt.bgcolor->key = "bgcolor";
    opt.bgcolor->type = TYPE_STRING;
    opt.bgcolor->required = NO;
    opt.bgcolor->description =
        _("Text background color, either a standard GRASS color or R:G:B triplet");
    opt.bgcolor->gisprompt = "old_color,color,color";
    opt.bgcolor->guisection = _("Text");

    opt.rotation = G_define_option();
    opt.rotation->key = "rotation";
    opt.rotation->type = TYPE_DOUBLE;
    opt.rotation->required = NO;
    opt.rotation->answer = "0";
    opt.rotation->description =
    _("Rotation angle in degrees (counter-clockwise)");
    opt.rotation->guisection = _("Text");

    opt.linespacing = G_define_option();
    opt.linespacing->key = "linespacing";
    opt.linespacing->type = TYPE_DOUBLE;
    opt.linespacing->required = NO;
    opt.linespacing->answer = "1.25";
    opt.linespacing->description = _("Line spacing");
    opt.linespacing->guisection = _("Text");

    opt.at = G_define_option();
    opt.at->key = "at";
    opt.at->key_desc = "x,y";
    opt.at->type = TYPE_DOUBLE;
    opt.at->required = NO;
    opt.at->description =
	_("Screen position at which text will begin to be drawn (percentage, [0,0] is lower left)");
    opt.at->guisection = _("Position");

    opt.line = G_define_option();
    opt.line->key = "line";
    opt.line->required = NO;
    opt.line->type = TYPE_INTEGER;
    opt.line->options = "1-1000";
    opt.line->description =
	_("The screen line number on which text will begin to be drawn");
    opt.line->guisection = _("Position");

    opt.align = G_define_option();
    opt.align->key = "align";
    opt.align->type = TYPE_STRING;
    opt.align->required = NO;
    opt.align->answer = "ll";
    opt.align->options = "ll,lc,lr,cl,cc,cr,ul,uc,ur";
    opt.align->description = _("Text alignment");
    opt.align->guisection = _("Position");

    opt.font = G_define_option();
    opt.font->key = "font";
    opt.font->type = TYPE_STRING;
    opt.font->required = NO;
    opt.font->description = _("Font name");
    opt.font->guisection = _("Font settings");

    opt.size = G_define_option();
    opt.size->key = "size";
    opt.size->type = TYPE_DOUBLE;
    opt.size->required = NO;
    opt.size->answer = "5";
    opt.size->options = "0-100";
    opt.size->description =
    _("Height of letters in percentage of available frame height");
    opt.size->guisection = _("Font settings");

    opt.path = G_define_standard_option(G_OPT_F_INPUT);
    opt.path->key = "path";
    opt.path->required = NO;
    opt.path->description = _("Path to font file");
    opt.path->gisprompt = "old,font,file";
    opt.path->guisection = _("Font settings");

    opt.charset = G_define_option();
    opt.charset->key = "charset";
    opt.charset->type = TYPE_STRING;
    opt.charset->required = NO;
    opt.charset->description =
	_("Text encoding (only applicable to TrueType fonts)");
    opt.charset->guisection = _("Font settings");

    flag.p = G_define_flag();
    flag.p->key = 'p';
    flag.p->description = _("Screen position in pixels ([0,0] is top left)");
    flag.p->guisection = _("Position");

    flag.g = G_define_flag();
    flag.g->key = 'g';
    flag.g->description = _("Screen position in geographic coordinates");
    flag.g->guisection = _("Position");

    flag.b = G_define_flag();
    flag.b->key = 'b';
    flag.b->description = _("Use bold text");
    flag.b->guisection = _("Text");

    flag.r = G_define_flag();
    flag.r->key = 'r';
    flag.r->description = _("Use radians instead of degrees for rotation");
    flag.r->guisection = _("Text");

    flag.s = G_define_flag();
    flag.s->key = 's';
    flag.s->description = _("Font size is height in pixels");
    flag.s->guisection = _("Font settings");


    /* check command line */
    if (G_parser(argc, argv))
	exit(1);

    /* parse and check options and flags */

    if ((opt.line->answer && opt.at->answer) ||
	(flag.p->answer && flag.g->answer))
	G_fatal_error(_("Please choose only one placement method"));

    text = opt.text->answer;

    line = (opt.line->answer ? atoi(opt.line->answer) : 1);

    /* calculate rotation angle in radian */
    rotation = atof(opt.rotation->answer);
    if (!flag.r->answer)
	rotation *= M_PI / 180.0;
    rotation = fmod(rotation, 2.0 * M_PI);
    if (rotation < 0.0)
	rotation += 2.0 * M_PI;

    strncpy(align, opt.align->answer, 2);
    linespacing = atof(opt.linespacing->answer);

    bold = flag.b->answer;

    D_open_driver();
    
    if (opt.font->answer)
	D_font(opt.font->answer);
    else if (opt.path->answer)
	D_font(opt.path->answer);

    if (opt.charset->answer)
	D_encoding(opt.charset->answer);

    D_setup_unity(0);

    /* figure out where to put text */
    D_get_src(&win.t, &win.b, &win.l, &win.r);

    if (flag.s->answer)
	size = atof(opt.size->answer);
    else
#ifdef BACKWARD_COMPATIBILITY
	size = atof(opt.size->answer) / 100.0 * (win.b - win.t) / linespacing;
#else
	size = atof(opt.size->answer) / 100.0 * (win.b - win.t);
#endif

    fg_color = D_parse_color(opt.fgcolor->answer, TRUE);
    if (opt.bgcolor->answer) {
	do_background = 1;
	bg_color = D_parse_color(opt.bgcolor->answer, TRUE);
	if (bg_color == 0) /* ie color="none" */
	    do_background = 0;
    } else
	do_background = 0;
    set_color(opt.fgcolor->answer);

    orig_x = orig_y = 0;

    if (opt.at->answer) {
	if (get_coordinates(&x, &y, &east, &north,
			    win, opt.at->answers,
			    flag.p->answer, flag.g->answer))
	    G_fatal_error(_("Invalid coordinates"));
	orig_x = x;
	orig_y = y;
    }
    else {
	x = win.l + (size * linespacing + 0.5) - size;	/* d.text: +5 */
	y = win.t + line * (size * linespacing + 0.5);
    }

    prev_x = x;
    prev_y = y;

    D_text_size(size, size);
    D_text_rotation(rotation * 180.0 / M_PI);

    if (text) {
	double x2, y2;

	x2 = x;
	y2 = y;

	if (text[0])
	    draw_text(text, &x2, &y2, size, align, rotation, bold, do_background, fg_color, bg_color);

	/* reset */
	D_text_size(5, 5);
	D_text_rotation(0.0);

	D_save_command(G_recreate_command());
	D_close_driver();

	exit(EXIT_SUCCESS);
    }

    if (!opt.input->answer || strcmp(opt.input->answer, "-") == 0)
	cmd_fp = stdin;
    else {
	cmd_fp = fopen(opt.input->answer, "r");
	if (!cmd_fp)
	    G_fatal_error(_("Unable to open input file <%s>"), opt.input->answer);
    }

    if (isatty(fileno(cmd_fp)))
	fprintf(stderr,
		_("\nPlease enter text instructions.  Enter EOF (ctrl-d) on last line to quit\n"));

    set_x = set_y = set_l = 0;
    first_text = 1;
    linefeed = 1;
    /* do the plotting */
    while (fgets(buf, sizeof(buf), cmd_fp)) {
	int buf_len;
	char *buf_ptr, *ptr;

	buf_len = strlen(buf) - 1;
	for (; buf[buf_len] == '\r' || buf[buf_len] == '\n'; buf_len--) ;
	buf[buf_len + 1] = 0;

	if (buf[0] == '.' && buf[1] != '.') {
	    int i;
	    double d;

	    G_squeeze(buf);	/* added 6/91 DBS @ CWU */
	    for (buf_ptr = buf + 2; *buf_ptr == ' '; buf_ptr++) ;
	    buf_len = strlen(buf_ptr);

	    switch (buf[1] & 0x7f) {
	    case 'F':
		/* font */
		if ((ptr = strchr(buf_ptr, ':')))
		    *ptr = 0;
		D_font(buf_ptr);
		if (ptr)
		    D_encoding(ptr + 1);
		break;
	    case 'C':
		/* color */
		set_color(buf_ptr);
		fg_color = D_parse_color(buf_ptr, 1);
		break;
	    case 'G':
		/* background color */
		bg_color = D_parse_color(buf_ptr, 1);
		do_background = 1;
		break;
	    case 'S':
		/* size */
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] != 'p')
#ifdef BACKWARD_COMPATIBILITY
		    d *= (win.b - win.t) / 100.0 / linespacing;
#else
		    d *= (win.b - win.t) / 100.0;
#endif
		size = d + (i ? size : 0);
		D_text_size(size, size);
		break;
	    case 'B':
		/* bold */
		bold = (atoi(buf_ptr) ? 1 : 0);
		break;
	    case 'A':
		/* align */
		strncpy(align, buf_ptr, 2);
		break;
	    case 'R':
		/* rotation */
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] != 'r')
		    d *= M_PI / 180.0;
		d += (i ? rotation : 0.0);
		rotation = fmod(d, 2.0 * M_PI);
		if (rotation < 0.0)
		    rotation += 2.0 * M_PI;
		D_text_rotation(rotation * 180.0 / M_PI);
		break;
	    case 'I':
		/* linespacing */
		linespacing = atof(buf_ptr);
		break;
	    case 'X':
		/* x */
		set_l = 0;
		set_x = 1;
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] == '%')
		    /* percentage */
		    d *= (win.r - win.l) / 100.0;
		else if (buf_ptr[buf_len - 1] != 'p')
		    /* column */
		    d = (d - 1) * size * linespacing + 0.5;
		x = prev_x = d + (i ? x : orig_x);
		break;
	    case 'Y':
		/* y */
		set_l = 0;
		set_y = 1;
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] == '%')
		    /* percentage */
		    d = win.b - d * (win.b - win.t) / 100.0;
		else if (buf_ptr[buf_len - 1] != 'p')
		    /* row */
		    d *= size * linespacing + 0.5;
		y = prev_y = d + (i ? y : orig_y);
		break;
	    case 'L':
		/* linefeed */
		set_l = 1;
		linefeed = (atoi(buf_ptr) ? 1 : 0);
		break;
	    case 'E':
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] == '%')
		    d *= (win.r - win.l) / 100.0;
		else if (buf_ptr[buf_len - 1] != 'p')
		    d = D_u_to_d_col(d);
		x = prev_x = orig_x = d + (i ? orig_x : win.l);
		break;
	    case 'N':
		i = 0;
		if (strchr("+-", buf_ptr[0]))
		    i = 1;
		d = atof(buf_ptr);
		if (buf_ptr[buf_len - 1] == '%')
		    d *= (win.b - win.t) / 100.0;
		else if (buf_ptr[buf_len - 1] != 'p')
		    d = D_u_to_d_row(d);
		y = prev_y = orig_y = d + (i ? orig_y : win.t);
		break;
	    }
	}
	else {
	    buf_ptr = buf;
	    if (buf[0] == '.' && buf[1] == '.')
		buf_ptr++;

	    if (!first_text && (linefeed || set_l)) {
		/* if x is not given, increment x */
		if (!set_x)
		    x = prev_x +
			(size * linespacing + 0.5) * sin(rotation);
		/* if y is not given, increment y */
		if (!set_y)
		    y = prev_y +
			(size * linespacing + 0.5) * cos(rotation);
		prev_x = x;
		prev_y = y;
	    }
	    set_x = set_y = set_l = first_text = 0;

	    draw_text(buf_ptr, &x, &y, size, align, rotation, bold, do_background, fg_color, bg_color);
	}
    }

    if (cmd_fp != stdin)
	fclose(cmd_fp);

    /* reset */
    D_text_size(5, 5);
    D_text_rotation(0.0);

    D_close_driver();

    exit(EXIT_SUCCESS);
}
int main(int argc, char * argv[]) try
{
    // Create a simple OpenGL window for rendering:
    window app(1280, 720, "RealSense Post Processing Example");
    ImGui_ImplGlfw_Init(app, false);

    // Construct objects to manage view state
    glfw_state original_view_orientation{};
    glfw_state filtered_view_orientation{};

    // Declare pointcloud objects, for calculating pointclouds and texture mappings
    rs2::pointcloud original_pc;
    rs2::pointcloud filtered_pc;

    // Declare RealSense pipeline, encapsulating the actual device and sensors
    rs2::pipeline pipe;
    rs2::config cfg;
    // Use a configuration object to request only depth from the pipeline
    cfg.enable_stream(RS2_STREAM_DEPTH, 640, 480, RS2_FORMAT_Z16, 30);
    // Start streaming with the above configuration
    pipe.start(cfg);

    // Declare filters
    rs2::decimation_filter dec_filter;  // Decimation - reduces depth frame density
    rs2::spatial_filter spat_filter;    // Spatial    - edge-preserving spatial smoothing
    rs2::temporal_filter temp_filter;   // Temporal   - reduces temporal noise

                                        // Declare disparity transform from depth to disparity and vice versa
    const std::string disparity_filter_name = "Disparity";
    rs2::disparity_transform depth_to_disparity(true);
    rs2::disparity_transform disparity_to_depth(false);

    // Initialize a vector that holds filters and their options
    std::vector<filter_options> filters;

    // The following order of emplacement will dictate the orders in which filters are applied
    filters.emplace_back("Decimate", dec_filter);
    filters.emplace_back(disparity_filter_name, depth_to_disparity);
    filters.emplace_back("Spatial", spat_filter);
    filters.emplace_back("Temporal", temp_filter);

    // Declaring two concurrent queues that will be used to push and pop frames from different threads
    rs2::frame_queue original_data;
    rs2::frame_queue filtered_data;

    // Declare depth colorizer for pretty visualization of depth data
    rs2::colorizer color_map;

    // Atomic boolean to allow thread safe way to stop the thread
    std::atomic_bool stopped(false);

    // Create a thread for getting frames from the device and process them
    // to prevent UI thread from blocking due to long computations.
    std::thread processing_thread([&]() {
        while (!stopped) //While application is running
        {
            rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera
            rs2::frame depth_frame = data.get_depth_frame(); //Take the depth frame from the frameset
            if (!depth_frame) // Should not happen but if the pipeline is configured differently
                return;       //  it might not provide depth and we don't want to crash

            rs2::frame filtered = depth_frame; // Does not copy the frame, only adds a reference

            /* Apply filters.
            The implemented flow of the filters pipeline is in the following order:
            1. apply decimation filter
            2. transform the scence into disparity domain
            3. apply spatial filter
            4. apply temporal filter
            5. revert the results back (if step Disparity filter was applied
            to depth domain (each post processing block is optional and can be applied independantly).
            */
            bool revert_disparity = false;
            for (auto&& filter : filters)
            {
                if (filter.is_enabled)
                {
                    filtered = filter.filter.process(filtered);
                    if (filter.filter_name == disparity_filter_name)
                    {
                        revert_disparity = true;
                    }
                }
            }
            if (revert_disparity)
            {
                filtered = disparity_to_depth.process(filtered);
            }

            // Push filtered & original data to their respective queues
            // Note, pushing to two different queues might cause the application to display
            //  original and filtered pointclouds from different depth frames
            //  To make sure they are synchronized you need to push them together or add some
            //  synchronization mechanisms
            filtered_data.enqueue(filtered);
            original_data.enqueue(depth_frame);
        }
    });


    // Declare objects that will hold the calculated pointclouds and colored frames
    // We save the last set of data to minimize flickering of the view
    rs2::frame colored_depth;
    rs2::frame colored_filtered;
    rs2::points original_points;
    rs2::points filtered_points;


    // Save the time of last frame's arrival
    auto last_time = std::chrono::high_resolution_clock::now();
    // Maximum angle for the rotation of the pointcloud
    const double max_angle = 15.0;
    // We'll use rotation_velocity to rotate the pointcloud for a better view of the filters effects
    float rotation_velocity = 0.3f;

    while (app)
    {
        float w = static_cast<float>(app.width());
        float h = static_cast<float>(app.height());

        // Render the GUI
        render_ui(w, h, filters);

        // Try to get new data from the queues and update the view with new texture
        update_data(original_data, colored_depth, original_points, original_pc, original_view_orientation, color_map);
        update_data(filtered_data, colored_filtered, filtered_points, filtered_pc, filtered_view_orientation, color_map);

        draw_text(10, 50, "Original");
        draw_text(static_cast<int>(w / 2), 50, "Filtered");

        // Draw the pointclouds of the original and the filtered frames (if the are available already)
        if (colored_depth && original_points)
        {
            glViewport(0, h / 2, w / 2, h / 2);
            draw_pointcloud(w / 2, h / 2, original_view_orientation, original_points);
        }
        if (colored_filtered && filtered_points)
        {
            glViewport(w / 2, h / 2, w / 2, h / 2);
            draw_pointcloud(w / 2, h / 2, filtered_view_orientation, filtered_points);
        }
        // Update time of current frame's arrival
        auto curr = std::chrono::high_resolution_clock::now();

        // Time interval which must pass between movement of the pointcloud
        const std::chrono::milliseconds rotation_delta(40);

        // In order to calibrate the velocity of the rotation to the actual displaying speed, rotate
        //  pointcloud only when enough time has passed between frames
        if (curr - last_time > rotation_delta)
        {
            if (fabs(filtered_view_orientation.yaw) > max_angle)
            {
                rotation_velocity = -rotation_velocity;
            }
            original_view_orientation.yaw += rotation_velocity;
            filtered_view_orientation.yaw += rotation_velocity;
            last_time = curr;
        }
    }

    // Signal the processing thread to stop, and join
    // (Not the safest way to join a thread, please wrap your threads in some RAII manner)
    stopped = true;
    processing_thread.join();

    return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
    std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n    " << e.what() << std::endl;
    return EXIT_FAILURE;
}
catch (const std::exception& e)
{
    std::cerr << e.what() << std::endl;
    return EXIT_FAILURE;
}
Esempio n. 21
0
File: scv.c Progetto: Ilgrim/MAMEHub
UINT32 scv_state::screen_update_scv(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int x, y;
	UINT8 fg = m_videoram[0x1403] >> 4;
	UINT8 bg = m_videoram[0x1403] & 0x0f;
	UINT8 gr_fg = m_videoram[0x1401] >> 4;
	UINT8 gr_bg = m_videoram[0x1401] & 0x0f;
	int clip_x = ( m_videoram[0x1402] & 0x0f ) * 2;
	int clip_y = m_videoram[0x1402] >> 4;

	/* Clear the screen */
	bitmap.fill(gr_bg , cliprect);

	/* Draw background */
	for ( y = 0; y < 16; y++ )
	{
		int text_y = 0;

		if ( y < clip_y )
		{
			text_y = ( m_videoram[0x1400] & 0x80 ) ? 0 : 1;
		}
		else
		{
			text_y = ( m_videoram[0x1400] & 0x80 ) ? 1 : 0;
		}

		for ( x = 0; x < 32; x++ )
		{
			int text_x = 0;
			UINT8 d = m_videoram[ 0x1000 + y * 32 + x ];

			if ( x < clip_x )
			{
				text_x = ( m_videoram[0x1400] & 0x40 ) ? 0 : 1;
			}
			else
			{
				text_x = ( m_videoram[0x1400] & 0x40 ) ? 1 : 0;
			}

			if ( text_x && text_y )
			{
				/* Text mode */
				UINT8 *char_data = m_charrom->base() + ( d & 0x7f ) * 8;
				draw_text( bitmap, x * 8, y * 16, char_data, fg, bg );
			}
			else
			{
				switch ( m_videoram[0x1400] & 0x03 )
				{
				case 0x01:      /* Semi graphics mode */
					draw_semi_graph( bitmap, x * 8    , y * 16     , d & 0x80, gr_fg );
					draw_semi_graph( bitmap, x * 8 + 4, y * 16     , d & 0x40, gr_fg );
					draw_semi_graph( bitmap, x * 8    , y * 16 +  4, d & 0x20, gr_fg );
					draw_semi_graph( bitmap, x * 8 + 4, y * 16 +  4, d & 0x10, gr_fg );
					draw_semi_graph( bitmap, x * 8    , y * 16 +  8, d & 0x08, gr_fg );
					draw_semi_graph( bitmap, x * 8 + 4, y * 16 +  8, d & 0x04, gr_fg );
					draw_semi_graph( bitmap, x * 8    , y * 16 + 12, d & 0x02, gr_fg );
					draw_semi_graph( bitmap, x * 8 + 4, y * 16 + 12, d & 0x01, gr_fg );
					break;

				case 0x03:      /* Block graphics mode */
					draw_block_graph( bitmap, x * 8, y * 16    , d >> 4 );
					draw_block_graph( bitmap, x * 8, y * 16 + 8, d & 0x0f );
					break;

				default:        /* Otherwise draw nothing? */
					break;
				}
			}
		}
	}

	/* Draw sprites if enabled */
	if ( m_videoram[0x1400] & 0x10 )
	{
		UINT8 screen_start_sprite_line = ( ( ( m_videoram[0x1400] & 0xf7 ) == 0x17 ) && ( ( m_videoram[0x1402] & 0xef ) == 0x4f ) ) ? 21 + 32 : 0 ;
		int i;

		for ( i = 0; i < 128; i++ )
		{
			UINT8 spr_y = m_videoram[ 0x1200 + i * 4 ] & 0xfe;
			UINT8 y_32 = m_videoram[ 0x1200 + i * 4 ] & 0x01;       /* Xx32 sprite */
			UINT8 clip = m_videoram[ 0x1201 + i * 4 ] >> 4;
			UINT8 col = m_videoram[ 0x1201 + i * 4 ] & 0x0f;
			UINT8 spr_x = m_videoram[ 0x1202 + i * 4 ] & 0xfe;
			UINT8 x_32 = m_videoram[ 0x1202 + i * 4 ] & 0x01;       /* 32xX sprite */
			UINT8 tile_idx = m_videoram[ 0x1203 + i * 4 ] & 0x7f;
			UINT8 half = m_videoram[ 0x1203 + i * 4] & 0x80;
			UINT8 left = 1;
			UINT8 right = 1;
			UINT8 top = 1;
			UINT8 bottom = 1;

			if ( !col )
			{
				continue;
			}

			if ( !spr_y )
			{
				continue;
			}

			if ( half )
			{
				if ( tile_idx & 0x40 )
				{
					if ( y_32 )
					{
						spr_y -= 8;
						top = 0;
						bottom = 1;
						y_32 = 0;
					}
					else
					{
						top = 1;
						bottom = 0;
					}
				}
				if ( x_32 )
				{
					spr_x -= 8;
					left = 0;
					right = 1;
					x_32 = 0;
				}
				else
				{
					left = 1;
					right = 0;
				}
			}

			/* Check if 2 color sprites are enabled */
			if ( ( m_videoram[0x1400] & 0x20 ) && ( i & 0x20 ) )
			{
				/* 2 color sprite handling */
				draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip, screen_start_sprite_line );
				if ( x_32 || y_32 )
				{
					static const UINT8 spr_2col_lut0[16] = { 0, 15, 12, 13, 10, 11,  8, 9, 6, 7,  4,  5, 2, 3,  1,  1 };
					static const UINT8 spr_2col_lut1[16] = { 0,  1,  8, 11,  2,  3, 10, 9, 4, 5, 12, 13, 6, 7, 14, 15 };

					draw_sprite( bitmap, spr_x, spr_y, tile_idx ^ ( 8 * x_32 + y_32 ), ( i & 0x40 ) ? spr_2col_lut1[col] : spr_2col_lut0[col], left, right, top, bottom, clip, screen_start_sprite_line );
				}
			}
			else
			{
				/* regular sprite handling */
				draw_sprite( bitmap, spr_x, spr_y, tile_idx, col, left, right, top, bottom, clip, screen_start_sprite_line );
				if ( x_32 )
				{
					draw_sprite( bitmap, spr_x + 16, spr_y, tile_idx | 8, col, 1, 1, top, bottom, clip, screen_start_sprite_line );
				}

				if ( y_32 )
				{
					clip = ( clip & 0x08 ) ? ( clip & 0x07 ) : 0;
					draw_sprite( bitmap, spr_x, spr_y + 16, tile_idx | 1, col, left, right, 1, 1, clip, screen_start_sprite_line );
					if ( x_32 )
					{
						draw_sprite( bitmap, spr_x + 16, spr_y + 16, tile_idx | 9, col, 1, 1, 1, 1, clip, screen_start_sprite_line );
					}
				}
			}
		}
	}
Esempio n. 22
0
/*
 * Main program.
 */
int main()
{

    int appid,rlist;
    int xwork_id,text_id,box_id,data_id;
    int dataspec;
    int i;

    char text[6];

    float xdra[] = {0.0, 0.1, 0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0};
    float ydra[] = {0.5, 0.9, 1.0, 0.9, 0.5, 0.1, 0.0, 0.1, 0.5};
    float xpos,ypos;

/*
 * Define a simple color map (index 0 defines the background color).
 */
    float cmap[4][3] = { { 1.0, 1.0, 1.0 },
                 { 0.0, 0.0, 1.0 },
                 { 0.0, 1.0, 0.0 },
                 { 1.0, 0.0, 0.0 } };
    ng_size_t dims[] = {4,3};
/*
 * Set the display. Default is to display output to an X workstation.
 */
    char const *wks_type = "x11";

/*
 * Initialize the high level utility library and create application.
 */
    NhlInitialize();

        rlist = NhlRLCreate(NhlSETRL);
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNappUsrDir,"./");
        NhlCreate(&appid,"basic06",NhlappClass,NhlDEFAULT_APP,rlist);


    if (!strcmp(wks_type,"ncgm") || !strcmp(wks_type,"NCGM")) {
    /*
     * Create a meta file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkMetaName,"./basic06c.ncgm");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlncgmWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"x11") || !strcmp(wks_type,"X11")) {
    /*
     * Create an X workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetInteger(rlist,NhlNwkPause,True);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoWindowWorkstationClass,
                          NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldps") || !strcmp(wks_type,"OLDPS")) {
    /*
     * Create a PS file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPSFileName,"./basic06c.ps");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlpsWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"oldpdf") || !strcmp(wks_type,"OLDPDF")) {
    /*
     * Create a PS file workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkPDFFileName,"./basic06c.pdf");
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlpdfWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"pdf") || !strcmp(wks_type,"PDF") ||
             !strcmp(wks_type,"ps") || !strcmp(wks_type,"PS")) {
    /*
     * Create a cairo PS/PDF workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./basic06c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoDocumentWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }
    else if (!strcmp(wks_type,"png") || !strcmp(wks_type,"PNG")) {
    /*
     * Create a cairo PNG workstation.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNwkFileName,"./basic06c");
        NhlRLSetString(rlist,NhlNwkFormat,(char*)wks_type);
        NhlRLSetMDFloatArray(rlist,NhlNwkColorMap,&cmap[0][0],2,dims);
        NhlCreate(&xwork_id,"simple",NhlcairoImageWorkstationClass,
              NhlDEFAULT_APP,rlist);
    }

/*
 * Create data object for an XyPlot
 */
    NhlRLClear(rlist);
    NhlRLSetFloatArray(rlist,NhlNcaXArray,xdra,NhlNumber(xdra));
    NhlRLSetFloatArray(rlist,NhlNcaYArray,ydra,NhlNumber(ydra));
    NhlCreate(&data_id,"xyData",NhlcoordArraysClass,NhlDEFAULT_APP,rlist);

/*
 * Create a simple XyPlot object with no labels or borders.  The
 * parent for this object is xwork_id, hence it will be sent to
 * the workstation identified by xwork_id when the draw procedure
 * is invoked on it.
 */
    NhlRLClear(rlist);
    NhlRLSetString(rlist,NhlNtmXBBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmXTBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmYLBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmYRBorderOn,"False");
    NhlRLSetString(rlist,NhlNtmXBOn,"False");
    NhlRLSetString(rlist,NhlNtmXTOn,"False");
    NhlRLSetString(rlist,NhlNtmYLOn,"False");
    NhlRLSetString(rlist,NhlNtmYROn,"False");
    NhlRLSetFloat(rlist,NhlNvpXF,0.0);
    NhlRLSetFloat(rlist,NhlNvpYF,1.0);
    NhlRLSetFloat(rlist,NhlNvpWidthF,1.0);
    NhlRLSetFloat(rlist,NhlNvpHeightF,1.0);
    NhlCreate(&box_id,"Box",NhlxyPlotClass,xwork_id,rlist);

/*
 * Create a TextItem object.
 */
    NhlRLClear(rlist);
    NhlRLSetFloat(rlist,NhlNtxPosXF,0.5);
    NhlRLSetFloat(rlist,NhlNtxPosYF,0.5);
    NhlRLSetInteger(rlist,NhlNtxFont,26);
        NhlCreate(&text_id,"Text",NhltextItemClass,xwork_id,rlist);

/*
 * Add the data identified by data_id to the XyPlot.
 */
    dataspec = NhlAddData(box_id,"xyCoordData",data_id);

/*
 * Draw three labeled boxes at different sizes and in different positions
 * and with different colors.
 */
    for(i=1;i<=3;++i)
    {
        xpos = -0.05*i*i + 0.5*i - 0.20;
        ypos = 1.0-xpos;
        sprintf(text,"%s %d","Box",i);  

    /*
     * Specify a text string and its color.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNtxString,text);
        NhlRLSetInteger(rlist,NhlNtxFontColor,4-i);
        NhlSetValues(text_id,rlist);

    /*
     * Set the XyPlot curve color.
     */
        NhlRLClear(rlist);
        NhlRLSetString(rlist,NhlNxyMonoLineColor,"True");
        NhlRLSetInteger(rlist,NhlNxyLineColor,i);
        NhlSetValues(dataspec,rlist);

    /*
     * Draw box and text.
     */
        draw_plot(box_id, xpos, ypos, 0.36-0.09*(i-1));
        draw_text(text_id, xpos, ypos, 0.08-0.02*(i-1));
    }

    NhlFrame(xwork_id);

    NhlDestroy(xwork_id);
        NhlClose();
    exit (0);
}
Esempio n. 23
0
static void file_list_draw(void)
{
	int n, pos, fg, bg, i;
	char buf[8];
	char sbuf[32];
	dmoz_file_t *file;

	/* there's no need to have if (files) { ... } like in the load-module page,
	   because there will always be at least "/" in the list */
	if (top_file < 0) top_file = 0;
	if (current_file < 0) current_file = 0;
	for (n = top_file, pos = 13; n < flist.num_files && pos < 48; n++, pos++) {
		file = flist.files[n];

		if (n == current_file && ACTIVE_PAGE.selected_widget == 0) {
			fg = 0;
			bg = 3;
		} else {
			fg = get_type_color(file->type);
			bg = 0;
		}

		draw_text(numtostr(3, n, buf), 2, pos, 0, 2);
		draw_text_len((file->title ? file->title : ""),
						25, 6, pos, fg, bg);
		draw_char(168, 31, pos, 2, bg);
		draw_text_len((file->base ? file->base : ""),
						18, 32, pos, fg, bg);

		if (file->base && slash_search_mode > -1) {
			if (strncasecmp(file->base,slash_search_str,slash_search_mode) == 0) {
				for (i = 0 ; i < slash_search_mode; i++) {
					if (tolower(((unsigned)file->base[i]))
					!= tolower(((unsigned)slash_search_str[i]))) break;
					draw_char(file->base[i], 32+i, pos, 3,1);
				}
			}
		}

		if (file->sampsize > 1) {
			sprintf(sbuf, "%u Samples", file->sampsize);
			draw_text_len(sbuf, 10, 51, pos, fg, bg);
		} else if (file->sampsize == 1) {
			draw_text("1 Sample  ", 51, pos, fg, bg);
		} else if (file->type & TYPE_MODULE_MASK) {
			draw_text("\x9a\x9a""Module\x9a\x9a", 51, pos, fg, bg);
		} else {
			draw_text("          ", 51, pos, fg, bg);
		}
		if (file->filesize > 1048576) {
			sprintf(sbuf, "%lum", (unsigned long)(file->filesize / 1048576));
		} else if (file->filesize > 1024) {
			sprintf(sbuf, "%luk", (unsigned long)(file->filesize / 1024));
		} else if (file->filesize > 0) {
			sprintf(sbuf, "%lu", (unsigned long)(file->filesize));
		} else {
			*sbuf = 0;
		}
		draw_text_len(sbuf, 6, 62, pos, fg, bg);
	}

	/* draw the info for the current file (or directory...) */

	while (pos < 48)
		draw_char(168, 31, pos++, 2, 0);
}
Esempio n. 24
0
	void graphics_context::draw_text(const point& aPoint, const string& aText, const font& aFont, const colour& aColour, bool aUseCache) const
	{
		draw_text(aPoint, aText.begin(), aText.end(), aFont, aColour, aUseCache);
	}
Esempio n. 25
0
void draw_textf(const char *fstr, int left, int top, ...)
{
    defvformatstring(str, top, fstr);
    draw_text(str, left, top);
}
Esempio n. 26
0
File: decor.c Progetto: damaru/zwm
void zwm_decor_update(Client *c)
{

	if(super_on){
		decor_win_follow(c);
		return;
	}

	int bcolor = c->root_user?config.xcolor_root:config.xcolor_fborder;
	int fill = c->root_user?config.xcolor_root:config.xcolor_fbg;
	int shadow = config.xcolor_fshadow;
	int tcolor = config.xcolor_ftitle;

	if(!c->hastitle){
		return;
	}

	if(c->focused == False && !super_on){
		bcolor = config.xcolor_nborder;
		fill = config.xcolor_nbg;
		shadow = config.xcolor_nshadow;
		tcolor = config.xcolor_ntitle;
	}

	if(c->isfloating){
		fill = config.xcolor_flbg;
		bcolor = config.xcolor_flbg;
	}

	if (c->frame) {
		int iw= c->w - (config.button_width*config.button_count) - 4*c->border;
		int vx = 4*c->border;
		const char* vtxt = config.viewnames[c->view];
		int tx = vx + config.button_width;
		int ty = config.title_y;
		char n[256];

		XSetWindowBackground(dpy, c->frame, fill);
		XSetWindowBorder(dpy, c->frame, bcolor);

		XSetForeground(dpy, gc, fill);
		XFillRectangle (dpy, c->frame, gc, 0, 0, c->w, c->h);

		draw_text(c, xfont, fill, tcolor, shadow, vx, ty, vtxt); 
		sprintf(n, "%s %s", c->isfloating?"▬":views[c->view].layout->symbol, c->name );
		draw_text(c, xfont, fill, tcolor, shadow, tx, ty, n); 
//		draw_text(c, xfont, fill, tcolor, shadow, tx + config.button_width, ty, c->name); 
		if(c->focused){
			get_status(title, 1024);
			char tmp[256];
			char cap[32];

			sprintf(tmp, "%s[%lu]",title, c->ucount/60);
			strcpy(title,tmp);
			draw_text(c, xfont, fill, tcolor, shadow, iw - date_width - 20 - char_width, ty, title); 
			draw_text(c, ifont, fill, tcolor, shadow, iw, config.icon_y, icons); 

			FILE *b = fopen("/sys/class/power_supply/BAT0/capacity", "r");
			if(b) {
				fgets(cap, 32, b);
				cap[3] = 0;
				int p = atoi(cap) ;
				if(p != 100) {
					//int x = iw - date_width - 20 - char_width - 15;
					int x = iw - config.button_width;
					XSetForeground(dpy, gc, config.xcolor_ftitle);
					XFillRectangle (dpy, c->frame, gc, x, 2, 8, ty);
					XSetForeground(dpy, gc, config.xcolor_nborder);
					XFillRectangle (dpy, c->frame, gc, x, 2, 8, (ty) * (100-p) / 100 );
				}
				fclose(b);
			}
		}
	}
}
Esempio n. 27
0
void ActivityPartitionCanvas::draw(QPainter & p) {
  if (! visible()) return;
  p.setRenderHint(QPainter::Antialiasing, true);
  
  QRect r = rect();
  FILE * fp = svg();
  QColor bckgrnd = p.backgroundColor();
  QColor co = color(used_color);
  
  p.setBackgroundMode((used_color == UmlTransparent)
		      ? ::Qt::TransparentMode
		      : ::Qt::OpaqueMode);

  
  p.setBackgroundColor(co);
  
  if (used_color != UmlTransparent)
    p.fillRect(r, co);
    
  p.setFont(the_canvas()->get_font(UmlNormalFont));
  
  QFontMetrics fm(p.font());
  int h = 3*fm.height();
    
  if (fp != 0) {
    fprintf(fp, "<g>\n\t<rect fill=\"%s\" stroke=\"black\" stroke-width=\"1\" stroke-opacity=\"1\""
	    " x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" />\n",
	    svg_color(used_color), 
	    r.x(), r.y(), r.width() - 1, r.height() - 1);
  }
  
  p.drawRect(r);

  if (horiz) {
    if (! str.isEmpty()) { 
      p.save();
      p.rotate(-90);
      p.drawText(-r.y(), r.x(), -r.height(), h,
		 ::Qt::AlignCenter, str);
      p.restore();
      
      if (fp != 0) {
	int index = str.find('\n');
	
	if (index == -1)
	  draw_rotate_text(r.x() + h/2, r.y() + r.height()/2,
			   270, str, p.font(), fp);
	else {
	  int vc = r.y() + r.height()/2;
	  
	  draw_rotate_text(r.x() + h/4, vc,
			   270, str.left(index), p.font(), fp);
	  draw_rotate_text(r.x() + (h*3)/4, vc,
			   270, str.mid(index + 1), p.font(), fp);
	}
      }
    }
    
    r.setLeft(r.left() + h);
    p.drawLine(r.topLeft(), r.bottomLeft());
    
    if (fp) {
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.left(), r.bottom());
      fputs("</g>\n", fp);
    }
  }
  else {
    if (! str.isEmpty()) { 
      p.drawText(r.x(), r.y(), r.width(), h,
		 ::Qt::AlignCenter, str);
      
      if (fp != 0)
	draw_text(r.x(), r.y(), r.width(), h,
		  ::Qt::AlignCenter, str, p.font(), fp);
    }
    
    r.setTop(r.top() + h);
    p.drawLine(r.topLeft(), r.topRight());
    
    if (fp) {
      fprintf(fp, "\t<line stroke=\"black\" stroke-opacity=\"1\""
	      " x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" />\n",
	      r.left(), r.top(), r.right(), r.top());
      fputs("</g>\n", fp);
    }
  }
  
  p.setBackgroundColor(bckgrnd);
  
  if (selected())
    show_mark(p, rect());
}
Esempio n. 28
0
void flash_palette(uint8_t value){
	draw_rectangle(0, 0, MATRIX_WIDTH - 1, MATRIX_HEIGHT - 1, DRAW_FILLED, value, OVERLAY_REPLACE);
	draw_text(2, 5, (char*) "START", 3, 5, ORIENTATION_NORMAL, font_3x5, codepage_ascii_caps, GRN_3, OVERLAY_REPLACE);
	matrix_write_buffer();
}
Esempio n. 29
0
void render_item_head(screen_item &item, bool selected) {
  draw_text(0,0,"                ",header_color);
}
Esempio n. 30
0
text_layout bitmap_font::draw_text_wrapped(render_target* pCanvas, const char* sMessage,
        size_t iMessageLength, int iX, int iY, int iWidth,
        int iMaxRows, int iSkipRows, text_alignment eAlign) const
{
    text_layout oDrawArea = {};
    int iSkippedRows = 0;
    if(iMessageLength != 0 && sheet != nullptr)
    {
        const unsigned int iFirstASCII = 31;
        unsigned int iLastASCII = static_cast<unsigned int>(sheet->get_sprite_count()) + iFirstASCII;
        const char* sMessageEnd = sMessage + iMessageLength;

        while(sMessage != sMessageEnd && oDrawArea.row_count < iMaxRows)
        {
            const char* sBreakPosition = sMessageEnd;
            const char* sLastGoodBreakPosition = sBreakPosition;
            int iMsgWidth = -letter_spacing;
            int iMsgBreakWidth = iMsgWidth;
            unsigned int iTallest = 0;
            const char* s;
            bool foundNewLine = false;
            unsigned int iNextChar = 0;

            for(s = sMessage; s != sMessageEnd; )
            {
                const char* sOld = s;
                unsigned int iChar = unicode_to_codepage_437(next_utf8_codepoint(s));
                iNextChar = unicode_to_codepage_437(static_cast<unsigned char>(*s));
                if((iChar == '\n' && iNextChar == '\n') || (iChar == '/' && iNextChar == '/'))
                {
                    foundNewLine = true;
                    iMsgBreakWidth = iMsgWidth;
                    sBreakPosition = sOld;
                    break;
                }
                unsigned int iCharWidth = 0, iCharHeight = 0;
                if(iFirstASCII <= iChar && iChar <= iLastASCII)
                {
                    sheet->get_sprite_size_unchecked(iChar - iFirstASCII, &iCharWidth, &iCharHeight);
                }
                iMsgWidth += letter_spacing + iCharWidth;
                if(iChar == ' ')
                {
                    sLastGoodBreakPosition = sOld;
                    iMsgBreakWidth = iMsgWidth - iCharWidth;
                }

                if(iMsgWidth > iWidth)
                {
                    sBreakPosition = sLastGoodBreakPosition;
                    break;
                }
                if(iCharHeight > iTallest)
                    iTallest = iCharHeight;
            }

            if(s == sMessageEnd)
                iMsgBreakWidth = iMsgWidth;
            if(iMsgBreakWidth > oDrawArea.width)
                oDrawArea.width = iMsgBreakWidth;

            if(iSkippedRows >= iSkipRows)
            {
                if(pCanvas)
                {
                    int iXOffset = 0;
                    if(iMsgBreakWidth < iWidth)
                        iXOffset = (iWidth - iMsgBreakWidth) * static_cast<int>(eAlign) / 2;
                    draw_text(pCanvas, sMessage, sBreakPosition - sMessage, iX + iXOffset, iY);
                }
                iY += static_cast<int>(iTallest) + line_spacing;
                oDrawArea.end_x = iMsgWidth;
                oDrawArea.row_count++;
                if (foundNewLine) {
                    iY += static_cast<int>(iTallest) + line_spacing;
                    oDrawArea.row_count++;
                }
            }
            else
            {
              iSkippedRows++;
              if(foundNewLine)
              {
                  if(iSkippedRows == iSkipRows)
                  {
                      iY += static_cast<int>(iTallest) + line_spacing;
                      oDrawArea.row_count++;
                  }
                  iSkippedRows++;
              }
            }
            sMessage = sBreakPosition;
            if(sMessage != sMessageEnd)
            {
                next_utf8_codepoint(sMessage);
                if(foundNewLine)
                {
                    next_utf8_codepoint(sMessage);
                }
            }
            foundNewLine = 0;
        }
    }
    oDrawArea.end_x = iX + oDrawArea.end_x;
    oDrawArea.end_y = iY;
    return oDrawArea;
}