当前位置: 首页>>代码示例>>C++>>正文


C++ shade函数代码示例

本文整理汇总了C++中shade函数的典型用法代码示例。如果您正苦于以下问题:C++ shade函数的具体用法?C++ shade怎么用?C++ shade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了shade函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PixmapWidget

EqTitleBar::EqTitleBar(QWidget *parent)
        : PixmapWidget(parent)
{
    m_volumeBar = 0;
    m_balanceBar = 0;
    m_shade2 = 0;
    m_left = 0;
    m_right = 0;
    m_shaded = false;
    m_align = false;
    m_skin = Skin::instance();
    m_eq = parentWidget();
    m_mw = qobject_cast<MainWindow*>(m_eq->parent());
    m_close = new Button(this, Skin::EQ_BT_CLOSE_N, Skin::EQ_BT_CLOSE_P, Skin::CUR_EQCLOSE);
    connect(m_close, SIGNAL(clicked()),m_eq, SIGNAL(closed()));
    m_shade = new Button(this, Skin::EQ_BT_SHADE1_N, Skin::EQ_BT_SHADE1_P, Skin::CUR_EQNORMAL);
    connect(m_shade, SIGNAL(clicked()), SLOT(shade()));
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    if (settings.value("Skinned/eq_shaded", false).toBool())
        shade();
    m_align = true;
    setActive(false);
    setCursor(m_skin->getCursor(Skin::CUR_EQTITLE));
    connect(m_skin, SIGNAL(skinChanged()), SLOT(updateSkin()));
    updatePositions();
}
开发者ID:Greedysky,项目名称:qmmp,代码行数:26,代码来源:eqtitlebar.cpp

示例2: calculate_pixel_location

bool RayTracer::distribute_shade(int i, int j, SbVec3f *position, SbVec3f *color){
    SbVec3f pix_pos, d_vec;
    SbVec3f tempColor;
    float du;
    float dv;
    bool should_color ;
    int number_of_samples = 0;
    if(super_sampling_on == 0) {

        //std::cout<<"No Super sampling";
            //super sampling off
            pix_pos = calculate_pixel_location(i,j, 0.5, 0.5);
            d_vec  = pix_pos - *position;
            d_vec.normalize();
            should_color = shade(position, &d_vec, color, 1);
    }
    else{
        //super sampling on
        number_of_samples = NUMBER_OF_SAMPLES;
        for(int k =0; k< number_of_samples ; ++k){
            du = get_random_number();
            dv = get_random_number();
            pix_pos = calculate_pixel_location(i,j, du, dv);
            d_vec  = pix_pos - *position;
            d_vec.normalize();
            should_color = shade(position, &d_vec, &tempColor, 1);
            *color = *color + tempColor;
        }
        *color = *color/number_of_samples ;
    }
    return should_color;
}
开发者ID:tarunrs,项目名称:homework-fall-2011,代码行数:32,代码来源:raytracer.C

示例3: Vector

bool Raytracer::trace(Ray const &ray,
                      int &rayDepth,
                      Scene const &scene,
                      Vector &outColor, double &depth)
{
    // Increment the ray depth.
    rayDepth++;
    
    // - iterate over all objects calling Object::intersect.
    // - don't accept intersections not closer than given depth.
    // - call Raytracer::shade with the closest intersection.
    // - return true iff the ray hits an object.
    if (scene.objects.empty())
    {
        // no objects in the scene, then we render the default scene:
        // For default, we assume there's a cube centered on (0, 0, 1280 + 160) with side length 320 facing right towards the camera
        // test intersection:
        double x = 1280 / ray.direction[2] * ray.direction[0] + ray.origin[0];
        double y = 1280 / ray.direction[2] * ray.direction[1] + ray.origin[1];
        if ((x <= 160) && (x >= -160) && (y <= 160) && (y >= -160))
        {
            //if intersected:
            Material m; m.emission = Vector(16.0, 0, 0); m.reflect = 0; //just for default material, you should use the intersected object's material
            Intersection intersection;	//just for default, you should pass the intersection found by calling Object::intersect()
            outColor = shade(ray, rayDepth, intersection, m, scene);
            depth = 1280;	//the depth should be set inside each Object::intersect()
        }
    }
    else
    {
        // @@@@@@ YOUR CODE HERE
        // Note that for Object::intersect(), the parameter hit is the current hit
        // your intersect() should be implemented to exclude intersection far away than hit.depth
        
        Intersection hit;
        hit.depth = depth;
        double minDepth = depth;
        int index;
        for (int x=0 ; x<scene.objects.size(); x++) {
            if (scene.objects[x]->intersect(ray,hit)){
                if(hit.depth <minDepth){
                    minDepth = hit.depth;
                    index=x;
                }
                outColor = shade(ray, rayDepth, hit, scene.objects[index]->material, scene);
            }
        }
        
        depth = minDepth;
        return true;
    }
    
    // Decrement the ray depth.
    rayDepth--;
    
    return false;
}
开发者ID:buyunwang,项目名称:CS314,代码行数:57,代码来源:raytracer.cpp

示例4: t

//===============================
//DEFERRED IMPLEMENTATION
//===============================
void LLDrawPoolWater::renderDeferred(S32 pass)
{
	LLFastTimer t(FTM_RENDER_WATER);
	deferred_render = TRUE;
	shade();
	deferred_render = FALSE;
}
开发者ID:HyangZhao,项目名称:NaCl-main,代码行数:10,代码来源:lldrawpoolwater.cpp

示例5: p

/**
 * @brief shaderWidget::paintEvent
 *        Overload of QWidget paint event - Used to redraw widget
 */
void shaderWidget::paintEvent(QPaintEvent *)
{
    // If no palette selected, widget is "blank"
    if (mCurrentPalette == 0)
    {
        QPainter p(this);
        p.setPen(QColor(146, 146, 146));
        p.drawRect(0, 0, width() - 1, height() - 1);
        return;
    }

    if (mShadeImg.isNull() || mShadeImg.size() != size())
    {
        mShadeImg = QImage(size(), QImage::Format_RGB32);
        QLinearGradient shade(0, height(), 0, 0);
        for (int i=0; i < mCurrentPalette->mSections.length(); i++)
        {
            double pos = mCurrentPalette->mSections.at(i)->start;
            QColor col = mCurrentPalette->mSections.at(i)->color;
            shade.setColorAt(pos, col);
        }
        QPainter p(&mShadeImg);
        p.fillRect(rect(), shade);
    }

    QPainter p(this);
    p.drawImage(0, 0, mShadeImg);

    p.setPen(QColor(146, 146, 146));
    p.drawRect(0, 0, width() - 1, height() - 1);
}
开发者ID:Agilack,项目名称:vle-plugins,代码行数:35,代码来源:shaderwidget.cpp

示例6: raytracer

t_vec	raytracer(t_rayparams *params)
{
	t_raytracer *ray;

	ray = init_ray(params->over.l);
	first_loop(ray, params->dir, params->o);
	if (!ray->ret)
		return (ray->color);
	*(params->distance) = ray->ret2;
	if (ray->ret->light == TRUE)
		return (set_vec(1, 1, 1));
	ray->pi = add_vec(params->o, mul_vec(params->dir, ray->ret2));
	ray->tmp = params->over.l;
	while (ray->tmp)
	{
		if (ray->tmp->light == TRUE)
		{
			set_nray(ray, params->over.l, params->dir, params->o);
			shade(ray, params->dir);
		}
		ray->tmp = ray->tmp->next;
	}
	reflexion(ray, params);
	refraction(ray, params);
	return (ray->color);
}
开发者ID:the-only-ahmed,项目名称:RT-Final,代码行数:26,代码来源:ray.c

示例7: window_refresh_callback

void window_refresh_callback(GLFWwindow* window) {
    view_params* view = (view_params*)glfwGetWindowUserPointer(window);

    char title[4096];
    sprintf(title, "ysym | %s | %.3g | %d", view->filename.c_str(), view->time,
            view->frame);
    glfwSetWindowTitle(window, title);

    // begin frame
    ym_vec4f background = view->backgrounds[view->background];
    glClearColor(background[0], background[1], background[2], background[3]);
    glEnable(GL_DEPTH_TEST);
    glClearDepth(1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // draw
    shade(view->scene, view->cur_camera, view->shade_prog,
          view->shade_txt.data(), view->exposure, view->gamma, view->view_edges,
          view->camera_lights);

    // draw hull
    if (view->view_hull)
        draw_hull(view->rigid_scene, view->scene, 1, view->cur_camera,
                  view->shade_prog);

    // end frame
    glfwSwapBuffers(window);
}
开发者ID:finger563,项目名称:yocto-gl,代码行数:28,代码来源:ysym.cpp

示例8: cl_draw_menuitem_gradient

void cl_draw_menuitem_gradient (GdkDrawable *window, GtkWidget *widget, GtkStyle *style,
                                GdkRectangle *area, GtkStateType state_type, 
                                int x, int y, int width, int height, CLRectangle *r)
{
	ClearlooksStyle *clearlooks_style = (ClearlooksStyle*)style;
	gboolean menubar  = (widget->parent && GTK_IS_MENU_BAR(widget->parent)) ? TRUE : FALSE;
	GdkColor tmp;
	GdkColor lower_color;
	
	shade (&style->base[GTK_STATE_SELECTED], &lower_color, 0.8);
	
	cl_rectangle_set_corners (r, CL_CORNER_NARROW, CL_CORNER_NARROW,
	                             CL_CORNER_NARROW, CL_CORNER_NARROW);
	                             
	cl_rectangle_set_gradient (&r->fill_gradient,
	                           &style->base[GTK_STATE_SELECTED], &lower_color);

	r->gradient_type = CL_GRADIENT_VERTICAL;
	
	tmp = cl_gc_set_fg_color_shade (style->black_gc, style->colormap,
	                                &style->base[GTK_STATE_PRELIGHT], 0.8);

	r->bordergc = style->black_gc;
	r->fillgc = style->base_gc[GTK_STATE_PRELIGHT];
	
	if (menubar) height++;

	cl_rectangle_set_clip_rectangle (r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, r);
	cl_rectangle_reset_clip_rectangle (r);
	
	gdk_gc_set_foreground (style->black_gc, &tmp);
}
开发者ID:DanielAeolusLaude,项目名称:ardour,代码行数:33,代码来源:clearlooks_draw.c

示例9: p

void RazorCpuLoad::paintEvent ( QPaintEvent * )
{
	QPainter p(this);
	QPen pen;
	pen.setWidth(2);
	p.setPen(pen);
	p.setRenderHint(QPainter::Antialiasing, true);
	const double w = 20;

	p.setFont(m_font);
	QRectF r = rect();

	float vo = r.height()*(1-m_avg*0.01);
	float ho = (r.width() - w )/2.0;
	QRectF r1(r.left()+ho, r.top()+vo, r.width()-2*ho, r.height()-vo );

	QLinearGradient shade(0, 0, r1.width(), 0);
	shade.setSpread(QLinearGradient::ReflectSpread);
	shade.setColorAt(0, QColor(0, 196, 0, 128));
	shade.setColorAt(0.5, QColor(0, 128, 0, 255) );
	shade.setColorAt(1, QColor(0, 196, 0 , 128));


	p.fillRect(r1, shade);

	if( m_showText )
		p.drawText(rect(), Qt::AlignCenter, QString::number(m_avg));
}
开发者ID:Devoter,项目名称:razor-qt,代码行数:28,代码来源:razorcpuload.cpp

示例10: QImage

void ShadeWidget::generateShade()
{
    if (m_shade.isNull() || m_shade.size() != size()) {

        if (m_shade_type == ARGBShade) {
            m_shade = QImage(size(), QImage::Format_ARGB32_Premultiplied);
            m_shade.fill(0);

            QPainter p(&m_shade);
            p.fillRect(rect(), m_alpha_gradient);

            p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
            QLinearGradient fade(0, 0, 0, height());
            fade.setColorAt(0, QColor(0, 0, 0, 255));
            fade.setColorAt(1, QColor(0, 0, 0, 0));
            p.fillRect(rect(), fade);

        } else {
            m_shade = QImage(size(), QImage::Format_RGB32);
            QLinearGradient shade(0, 0, 0, height());
            shade.setColorAt(1, Qt::black);

            if (m_shade_type == RedShade)
                shade.setColorAt(0, Qt::red);
            else if (m_shade_type == GreenShade)
                shade.setColorAt(0, Qt::green);
            else
                shade.setColorAt(0, Qt::blue);

            QPainter p(&m_shade);
            p.fillRect(rect(), shade);
        }
    }
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:34,代码来源:gradients.cpp

示例11: color

//Ray Tracing
glm::vec3 RayTracing::rayTracing(Ray ray, int depth, float ior){
	glm::vec3 normal;
	glm::vec3 point;
	glm::vec3 color(0);

	//Objecto mais proximo
	Object * oB = Scene::getInstance().GetNearestObject(ray, point, normal);

	//Se nao existir uma intercepcao deve ser dada a cor do background
	if (oB == NULL)
		return Scene::getInstance().GetBckgColor();

	//Se ainda nao atingimos o limite temos de calcular os raios secundarios
	if (depth < MAX_DEPTH){

		//Refleccao
		glm::vec3 r1Color;
		calculateReflection(ray, oB, point, normal, depth, ior, r1Color);

		//Refraccao
		glm::vec3 r2Color;
		calculateRefraction(ray, oB, point, normal, depth, ior, r2Color);

		color += r1Color + r2Color;
	}

	//Cor final
	return color + shade(oB, normal, point);
}
开发者ID:davidcalimero,项目名称:PSJ2,代码行数:30,代码来源:RayTracing.cpp

示例12: getHeight

void Bitmap::drawShadow(Bitmap & where, int x, int y, int intensity, Color color, double scale, bool facingRight) const {
    const double newheight = getHeight() * scale;
    Bitmap shade(getWidth(), (int) fabs(newheight));
    Stretch(shade);

    /* Could be slow, but meh, lets do it for now to make it look like a real shadow */
    for (int h = 0; h < shade.getHeight(); ++h){
        for (int w = 0; w < shade.getWidth(); ++w){
            Color pix = shade.getPixel(w, h);
            if (pix != MaskColor()){
                shade.putPixel(w, h, color);
            }
        }
    }

    transBlender(0, 0, 0, intensity);

    if (scale > 0){
        if (facingRight){
            shade.translucent().drawVFlip(x, y, where);
        } else { 
            shade.translucent().drawHVFlip(x, y, where);
        }
    } else if (scale < 0){
        y -= fabs(newheight);
        if (facingRight){
            shade.translucent().draw(x + 3, y, where);
        } else { 
            shade.translucent().drawHFlip(x - 3, y, where);
        }
    }
}
开发者ID:marstau,项目名称:shinsango,代码行数:32,代码来源:bitmap.cpp

示例13: rayTrace

void rayTrace( Scene* scene, double *eye, double *ray, int depth, float *out_color )
{
	Object* object;
	double distance;

	double point[VECTOR], normal[VECTOR];

	/* Calcula o primeiro objeto a ser atingido pelo raio */
	getNearestObject( scene, eye, ray, &object, &distance );

	/* Se o raio n�o interceptou nenhum objeto... */
	if( distance == DBL_MAX )
	{
		sceGetBackgroundColor( scene, eye, ray, out_color );
		return;
	}

	/* Calcula o ponto de interse��o do raio com o objeto */
	algScale( distance, ray, point );
	algAdd( eye, point, point );

	/* Obt�m o vetor normal ao objeto no ponto de interse��o */
	objNormalAt( object, point, normal );

	shade( scene, eye, ray, object, point, normal, depth, out_color );
}
开发者ID:lfmachadodasilva,项目名称:raytracing,代码行数:26,代码来源:raytracing.c

示例14: a4_trace_ray_set

void * a4_trace_ray_set(void * render_directive)
{
    RenderDirective *rd = static_cast<RenderDirective*>(render_directive);

    // calculate change of basis
    Vector3D w = (*rd->world->view);
    w.normalize();
    Vector3D u = rd->world->up->cross(w);
    u.normalize();
    Vector3D v = w.cross(u);

    // for each pixel requested to render
    for (int i = rd->start_pixel; i < rd->num_pixels + rd->start_pixel; i++) {
        // determine which pixel to render based on index
        int x = i % rd->img->get_width();
        int y = i/rd->img->get_width();

        // DEFER: extend to non-axis aligned rendering

        // create ray using perspective
        Ray ray;
        // origin is the eye
        ray.origin = rd->world->get_eye();

        // Calculate view-plane-height = 2 * d * tan ( fovy / 2 )
        double view_plane_height = 2.0*rd->world->view->z()*tan((rd->world->get_fov()*M_PI/180.0)/2);
        double view_plane_width  = view_plane_height * rd->img->get_width()/rd->img->get_height();

        // direction is 
        // DEFER: not sure if this calculate is quite correct ...
        ray.direction = Vector3D(
                -(view_plane_width/rd->img->get_width())*((double)x - 0.5 * rd->img->get_width()),
                (view_plane_height/rd->img->get_height())*((double)y - 0.5 * rd->img->get_height()),
                rd->world->view->z());

        ray.direction.normalize();

        // trace the ray onto given image
        Shading shade(*rd->world);
        shade.ray = ray;
        double tmin = 10E24;
        rd->world->scene->hit(ray, tmin, shade);

        if (shade.hit_object) {
            // use the material to apply shading
            Colour point_colour = shade.material->shade(shade);

            // set the colour on image
            rd->img->set(x, y, point_colour.R(), point_colour.G(), point_colour.B());
        } else {
            // clear pixel to background color
            Colour bg_pixel = background(x,y,rd->img->get_width(),rd->img->get_height());
            rd->img->set(x,y,bg_pixel.R(), bg_pixel.G(), bg_pixel.B());
        }

        increase_pixel_count(rd->img->get_width()*rd->img->get_height());
    }

    return NULL;
}
开发者ID:AlexRiedler,项目名称:cs488raytracer,代码行数:60,代码来源:a4.cpp

示例15: mix_bg_fg

gchar *
mix_bg_fg (GtkWidget * win, const gchar * state, float alpha, float beta)
{
    GdkColor color, bgColor, fgColor;
    GtkStyle *style;
    gchar *s;
    gint n;

    TRACE ("entering mix_bg_fg_ui");

    g_return_val_if_fail (win != NULL, NULL);
    g_return_val_if_fail (GTK_IS_WIDGET (win), NULL);
    g_return_val_if_fail (GTK_WIDGET_REALIZED (win), NULL);

    style = get_ui_style (win);
    n = state_value (state);

    bgColor = query_color (win, style->bg[n]);
    fgColor = query_color (win, style->fg[n]);
    color = shade (mix (bgColor, fgColor, alpha), beta);
    s = print_color (win, color);

    TRACE ("mix_bg_fg[%s]=%s", state, s);
    return (s);
}
开发者ID:cedl38,项目名称:xfce4-windowck-plugin,代码行数:25,代码来源:ui_style.c


注:本文中的shade函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。