void TestController::onInputValueChanged() {
    //        FL_LOG("-----------------------");
    QColor from_color(Qt::white);
    QColor to_color(0, 200, 0);
    for (int i = 0; i < getModel().numberOfOutputLVars(); ++i) {
        getModel().outputLVar(i)->output().clear();
    }
    for (int i = 0; i < getModel().ruleBlock(0)->numberOfRules(); ++i) {
        fl::FuzzyRule& rule = *getModel().ruleBlock(0)->rule(i);
        fl::flScalar degree = rule.firingStrength();

        int red, green, blue, alpha;
        GuiCanvas::ColorGradient(from_color.red(), from_color.green(),
                                 from_color.blue(), from_color.alpha(), to_color.red(), to_color.green(),
                                 to_color.blue(), to_color.alpha(), (int) (degree * 255), red, green, blue, alpha);

        QColor color = QColor(red, green, blue, alpha);

        getView().getUi().lsw_test_rules->item(i)->setBackground(QBrush(color));
        getView().getUi().lsw_test_rules_activation->item(i)->setBackground(QBrush(
                    color));
        getView().getUi().lsw_test_rules_activation->item(i)->setText(
            QString::number(degree, 'f', 3));
        rule.fire(degree);
    }
    emit forceUpdate();
}
Example #2
0
/* Procedural texture function */
int ptex_fun(float u_start, float v_start, GzColor color)
{
	/*
	if (proc_reset) {          // create texture
		proc_reset = 0;
		xs = 200;
		ys = 200;
		image = (GzColor*)malloc(sizeof(GzColor)*(xs+1)*(ys+1));
		if (image == NULL) {
			fprintf (stderr, "malloc for texture image failed\n");
			exit(-1);
		}
		for (int i = 0; i < xs*ys; i++) {	// create array of GzColor values 
			start_u = ((int)(i - ((int)i / (int)ys) * ys)) / (double)xs;
			start_v = ((int)((int)i / (int)ys)) / (double)ys;
			double u,v;
			julia(&u, &v);
			double length = sqrt(u * u + v * v) / 100.0;
			to_color(length, color);

			image[i][RED] =	color[RED]	;
			image[i][GREEN] = color[GREEN];
			image[i][BLUE]  = color[BLUE]	;
		}
	}

	return interpolate(u_start, v_start, color);
	*/
	start_u = (u_start > 0.5) ? u_start : (1.0 - u_start );
	start_v = (v_start > 0.5) ? v_start : (1.0 - v_start );
	double u,v;
	julia(&u, &v);
	double length = sqrt(u * u + v * v);
	to_color(length, color);
	return GZ_SUCCESS; 
	
}
Example #3
0
      static color pixel_read( vector p ){
	      LCD_SetCursor( p.x_get(), p.y_get() );                                              
	      Write_Cmd( 0x22 ); // write RAM prepare                                          
	      return to_color( LCD_ReadDat() ); 	         
      }
Example #4
0
	void Engine::rendering()
	{
                timer.Start();

                unsigned int w = scene->get_cam()->get_width();
                unsigned int h = scene->get_cam()->get_height();

                unsigned int i, j;

                Camera * cam = scene->get_cam();
                int aa = cam->get_aa();

                #ifndef use_tbb

                        #pragma omp parallel for private(i, j) firstprivate(aa) schedule(static, grainsize)
                        for (j = 0; j < h; j++)
                                for (i = 0; i < w; i++)
                                {
                                        vec4 color_total;
                                        for (unsigned int s = 0; s < aa; s++)
                                        {
                                                color_total += ray_tracing(cam->get_ray(i, j, s), depth);
                                        }
                                        color_total /= static_cast<float>(aa);
                                        vbuf[j * w + i] = to_color(color_total);
                                }

                #else

                        //static tbb::task_scheduler_init init ( threads );
                        //static tbb::affinity_partitioner ap;

                        tbb::parallel_for
                        (
                                tbb::blocked_range<size_t> ( static_cast<size_t>(0), w * h, grainsize),
                                [&]( const tbb::blocked_range<size_t> & range )
                                {
                                        size_t i, j;
                                        for ( size_t ind = range.begin(); ind < range.end(); ++ind)
                                        {
                                                i = ind / w;
                                                j = ind - i * w;

                                                vec4 color_total;
                                                for (size_t s = 0; s < aa; ++s)
                                                {
                                                        color_total += ray_tracing(cam->get_ray(i, j, s), depth);
                                                }
                                                color_total /= static_cast<float>(aa);
                                                vbuf[ind] = to_color(color_total);
                                        }
                                }//, ap
                                //, tbb::auto_partitioner()
                        );

                #endif

                timer.Stop();
                fps = static_cast<float>(timer.OperationPerSecond());
		num_frame++;
	}