예제 #1
0
int grey(int n, int k) {
    if(n == 0)  return 0;
    if(k >= N2[n-1])
        return N2[n-1]|(grey(n-1, N2[n]-k-1));
    else
        return grey(n-1, k);
}
예제 #2
0
파일: tcolors.c 프로젝트: 00001/plan9port
ulong
grey(int i)
{
	if(i < 0)
		return grey(0);
	if(i > 255)
		return grey(255);
	return (i<<16)+(i<<8)+i;
}
예제 #3
0
std::vector<gmtl::Point3f> cPoints(std::vector<gmtl::Point3f> verts, char col)
{
	std::vector<gmtl::Point3f> color;
	//std::cout << vertices.size() << std::endl;;
	for (unsigned int i = 0; i < verts.size(); i++)
	{
		gmtl::Point3f red(1, 0, 0);
		gmtl::Point3f blue(0, 0, 1);
		gmtl::Point3f green(0, 1, 0);
		gmtl::Point3f white(1, 1, 1);
		gmtl::Point3f grey(0.5f, 0.5f, 0.5f);
		gmtl::Point3f old(verts.at(i));
		switch (col)
		{
		case 'w':
			color.push_back(white);
			break;
		case 'o':
			color.push_back(old);
			break;
		case 'g':
			color.push_back(grey);
			break;
		case 'h':
			if (i < verts.size() / 2)
				color.push_back(blue);
			else
				color.push_back(green);
			break;
		}


	}
	return color;
}
예제 #4
0
int
maintime::idle_progress (long ticks)
{
    m_tick = ticks;
    m_window->clear();
    m_gc->set_foreground(black());
    m_window->draw_rectangle
    (
        m_gc, false, 0, 0, m_window_x - 1, m_window_y - 1
    );

    int width = m_window_x - m_pill_width - 1;
    int tick_x = ((m_tick % m_ppqn) * (m_window_x - 1)) / m_ppqn ;
    int beat_x = (((m_tick / 4) % m_ppqn) * width) / m_ppqn ;
    int bar_x = (((m_tick / 16) % m_ppqn) * width) / m_ppqn ;
    if (tick_x <= (m_window_x / 4))
    {
        m_gc->set_foreground(grey());
        m_window->draw_rectangle
        (
            m_gc, true, 2, /*tick_x + 2,*/ 2, m_window_x - 4, m_window_y - 4
        );
    }
    m_gc->set_foreground(black());
    m_window->draw_rectangle
    (
        m_gc, true, beat_x + 2, 2, m_pill_width, m_window_y - 4
    );
    m_window->draw_rectangle
    (
        m_gc, true, bar_x + 2, 2, m_pill_width, m_window_y - 4
    );
    return true;
}
예제 #5
0
void BinaryImage::save(const char* path, enum ImageEncoding enc)
{
	GreyscaleImage grey(this->getWidth(), this->getHeight());
	
	this->convert(&grey);
	grey.saveContext(grey.getOscarContext(), path);
}
예제 #6
0
void greyscale()
{
    g_print("greyscale\n");
    SDL_Surface *ecran = NULL, *surface_tmp_g = NULL;
    SDL_Rect position;

    position.x = 0;
    position.y = 0;

    SDL_Init(SDL_INIT_VIDEO);

    surface_tmp_g = IMG_Load(chemin);

    ecran = SDL_SetVideoMode(surface_tmp_g->w, surface_tmp_g->h, 32, SDL_HWSURFACE);
    SDL_WM_SetCaption("PicToText", NULL);

    grey(surface_tmp_g);
    SDL_SaveBMP(surface_tmp_g, "image_grey");

    SDL_Flip(ecran);

    SDL_FreeSurface(surface_tmp_g);
    SDL_Quit();

    GtkWidget *image, *pHbox, *window;
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window),1550,900);
    gtk_container_set_border_width(GTK_CONTAINER(window),10);

    pHbox = gtk_hbox_new(FALSE,8);
    image = gtk_image_new_from_file("image_grey");
    gtk_box_pack_start(GTK_BOX(pHbox), image, FALSE,TRUE,0);
    gtk_container_add(GTK_CONTAINER(window), pHbox);
    gtk_widget_show_all(window);
}
예제 #7
0
void
perfroll::fill_background_pixmap ()
{
    m_gc->set_foreground(white());                  /* clear background */
    m_background->draw_rectangle(m_gc, true, 0, 0, m_background_x, m_names_y);
    m_gc->set_foreground(grey());                   /* draw horz grey lines */
    gint8 dash = 1;
    m_gc->set_dashes(0, &dash, 1);
    m_gc->set_line_attributes
    (
        1, Gdk::LINE_ON_OFF_DASH, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER
    );
    m_background->draw_line(m_gc, 0, 0, m_background_x, 0);
    int beats = m_measure_length / m_beat_length;
    for (int i = 0; i < beats ;)                    /* draw vertical lines   */
    {
        if (i == 0)
        {
            m_gc->set_line_attributes
            (
                1, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER
            );
        }
        else
        {
            m_gc->set_line_attributes
            (
                1, Gdk::LINE_ON_OFF_DASH, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER
            );
        }
        m_gc->set_foreground(grey());
        m_background->draw_line                     /* solid line, every beat */
        (
            m_gc, i * m_beat_length / m_perf_scale_x,
            0,    i * m_beat_length / m_perf_scale_x, m_names_y
        );
        if (m_beat_length < m_ppqn / 2)             /* jump 2 if 16th notes   */
            i += (m_ppqn / m_beat_length);
        else
            ++i;
    }
    m_gc->set_line_attributes                       /* reset line style       */
    (
        1, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER
    );
}
예제 #8
0
int main() {
    int n, k, t;
    for(n = 0; n <= 31; n++)
        N2[n] = 1<<n;
    ReadInt(&t);
    while(t--) {
        ReadInt(&n);
        ReadInt(&k);
        printf("%d\n", grey(n, k));
    }
    return 0;
}
예제 #9
0
void
GUIContainerStop::drawGL(const GUIVisualizationSettings& s) const {
    glPushName(getGlID());
    glPushMatrix();
    RGBColor grey(177, 184, 186, 171);
    RGBColor blue(83, 89, 172, 255);
    // draw the area
    int i;
    glTranslated(0, 0, getType());
    GLHelper::setColor(blue);
    GLHelper::drawBoxLines(myFGShape, myFGShapeRotations, myFGShapeLengths, 1.0);
    // draw details unless zoomed out to far
    const SUMOReal exaggeration = s.addSize.getExaggeration(s);
    if (s.scale * exaggeration >= 10) {
        // draw the lines
        for (i = 0; i != (int)myLines.size(); ++i) {
            glPushMatrix();
            glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
            glRotated(180, 1, 0, 0);
            glRotated(myFGSignRot, 0, 0, 1);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            pfSetPosition(0, 0);
            pfSetScale(1.f);
            glScaled(exaggeration, exaggeration, 1);
            glTranslated(1.2, -(double)i, 0);
            pfDrawString(myLines[i].c_str());
            glPopMatrix();
        }
        // draw the sign
        glTranslated(myFGSignPos.x(), myFGSignPos.y(), 0);
        int noPoints = 9;
        if (s.scale * exaggeration > 25) {
            noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
        }
        glScaled(exaggeration, exaggeration, 1);
        GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
        glTranslated(0, 0, .1);
        GLHelper::setColor(grey);
        GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
        if (s.scale * exaggeration >= 4.5) {
            GLHelper::drawText("C", Position(), .1, 1.6 * exaggeration, blue, myFGSignRot);
        }
    }
    glPopMatrix();
    glPopName();
    drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
    for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) {
        glTranslated(0, 1, 0); // make multiple containers viewable
        static_cast<GUIContainer*>(*i)->drawGL(s);
    }
}
예제 #10
0
파일: tcolors.c 프로젝트: 00001/plan9port
void
mousethread(void *v)
{
	Point p;
	Mouse m;
	int i, n, prev;
	char buf[100];
	ulong rgb;

	prev = -1;
	while(readmouse(mousectl) >= 0){
		m = mousectl->m;
		switch(m.buttons){
		case 1:
			while(m.buttons){
				if(screen->depth > 8)
					n = 256;
				else
					n = 1<<screen->depth;
				for(i=0; i!=n; i++)
					if(i!=prev && ptinrect(m.xy, crect[i])){
						if(ramp)
							rgb = grey(i);
						else
							rgb = cmap2rgb(i);
						sprint(buf, fmt,
							i,
							(rgb>>16)&0xFF,
							(rgb>>8)&0xFF,
							rgb&0xFF,
							(rgb<<8) | 0xFF);
						p = addpt(screen->r.min, Pt(2,2));
						draw(screen, Rpt(p, addpt(p, stringsize(font, buf))), display->white, nil, p);
						string(screen, p, display->black, ZP, font, buf);
						prev=i;
						break;
					}
				readmouse(mousectl);
				m = mousectl->m;
			}
			break;

		case 4:
			switch(menuhit(3, mousectl, &menu, nil)){
			case 0:
				threadexitsall(0);
			}
		}
	}
}
예제 #11
0
void ImageEffect::applyEffect(QImage &i, int effect) {
    switch(effect)
    {
        case ImageEffect::Effect_None:
            break;
        case ImageEffect::Effect_Grey:
            grey(i); break;
        case ImageEffect::Effect_Invert:
            invert(i); break;
        case ImageEffect::Effect_Mono:
            mono(i); break;
        case ImageEffect::Effect_Smurf:
            smurf(i); break;
    }
}
예제 #12
0
bool task3_2(const cv::Mat& image) {
    int suff = 1;
    bool res = true;

    for (int i = 0; i < task3_2c; ++i) {
        cv::Mat grey(image);
        grey.convertTo(grey, CV_32F);
        grey /= 255;
        cv::pow(grey, task3_2v[i], grey);
        grey *= 255;
        grey.convertTo(grey, CV_8U);
        grey.push_back(image);
        res &= cv::imwrite(PATH + generateName("Task3_2-", suff++), grey);
    }
    return res;
}
예제 #13
0
파일: nandwindow.cpp 프로젝트: Swyter/wiiqt
//expects blocks, not clusters!!
void NandWindow::DrawBlockMap( QList<quint16> newFile )
{
    if( blocks.size() != 0x1000 )
    {
        qWarning() << "NandWindow::DrawBlockMap -> current blocks are f****d up, son" << hex << blocks.size();
        return;
    }
    QPixmap blue( ":/blue.png" );
    QPixmap green( ":/green.png" );
    QPixmap pink( ":/pink.png" );
    QPixmap grey( ":/grey.png" );
    QPixmap black( ":/black.png" );

    for( quint16 i = 0; i < 0x1000; i++ )
    {
        quint16 thisBlock;
        if( !newFile.contains( i ) )
        {
            thisBlock = blocks.at( i );
        }
        else
        {
            thisBlock = 2;
        }
        switch( thisBlock )
        {
        default:
        case 1://used, but not in this file
            pmi[ i ]->setPixmap( green );
            break;
        case 2://used in this file
            pmi[ i ]->setPixmap( pink );
            break;
        case 0xFFFE://free block
            pmi[ i ]->setPixmap( grey );
            break;
        case 0xFFFC://reserved
            pmi[ i ]->setPixmap( blue );
            break;
        case 0xFFFD: // bad block
            pmi[ i ]->setPixmap( black );
            break;
        }
    }


}
예제 #14
0
void grey_scale(t_img_desc* img)
{
    if (img->comp < 3)
        return;

    // (i*3) because img->comp suck with BMP img
    for (int i = 0; i < img->x * img->y; ++i) {
        img->data[i] = grey(img->data[(i * 3)],
                img->data[(i * 3) + 1],
                img->data[(i * 3) + 2]);
    }

    // make the array shorter
    uchar *tmp = realloc(img->data, sizeof(char) * img->x * img->y);
    assert(tmp);

    img->data = tmp;
    img->comp = 1;
}
예제 #15
0
int
maintime::idle_progress (midipulse ticks)
{
    if (ticks >= 0)                     /* ca 2016-03-17 to make bar appear */
    {
        const int yoff = 4;
        int tick_x = (ticks % m_ppqn) * m_box_width / m_ppqn;
        int beat_x = ((ticks / m_beat_width) % m_ppqn) * m_box_less_pill / m_ppqn;
        int bar_x  = ((ticks / m_bar_width)  % m_ppqn) * m_box_less_pill / m_ppqn;
        m_tick = ticks;
        clear_window();
        draw_rectangle(black(), 0, yoff, m_box_width, m_box_height, false);
        if (tick_x <= m_flash_x)       /* for flashing the maintime bar     */
            draw_rectangle(grey(), 2, yoff+2, m_flash_width, m_flash_height);

        draw_rectangle(black(), beat_x + 2, yoff+2, m_pill_width, m_flash_height);
        draw_rectangle(bar_x + 2, yoff+2, m_pill_width, m_flash_height);
    }
    return true;
}
예제 #16
0
void
daSplat::Update( float timeStep )
{
	m_timer -= timeStep;
	
	SetScale(vsVector2D(1.2f,1.2f));
	
	if ( m_timer <= 0.f )
	{
		Extract();	// despawn us.
	}
	else
	{
		vsColor grey(0.5f,0.5f,0.5f,1.0f);
		if ( m_timer > 1.0f )
			SetColor(grey);
		else
			SetColor( vsInterpolate( m_timer, vsColor::Black, grey ) );
	}
}
예제 #17
0
void GreyImage_test::testReadFromGrey() {

    Block block;
    GreyImage grey( 20, 10 );

    //  X  X  X  X
    //  X  X  1  2
    //  X  X  3  4
    grey[2][1] = 1;
    grey[2][2] = 2;
    grey[3][1] = 3;
    grey[3][2] = 4;

    grey.getBlock( block, 2, 1 );

    QVERIFY( block[0][0] == 1 );
    QVERIFY( block[0][1] == 2 );
    QVERIFY( block[1][0] == 3 );
    QVERIFY( block[1][1] == 4 );
}
 bool canFinish(int numCourses, vector<pair<int, int>>& prerequisites) {
   //the problem is same as finding a cycle in a directed graph
   //this will hold the graph 
   //cout<<"here2\n";
   vector<unordered_set<int>> graph(numCourses); 
   for (auto courses : prerequisites){
     graph[courses.second].insert(courses.first);
   }
   
   vector<bool> visited(numCourses, false); //keeping track of all the taken courses
   vector<bool> grey(numCourses, false); //keep track of the current visited node
   //start dfs from the first node
   //cout<<"here1\n";
   for (int i=0; i<numCourses; i++) {
     //if the node is not visited visit the node and do dfs from each of its connections
     if (!visited[i]) {
       if (hascycle(i,visited,graph,grey)) {
         return false;
       }
     }  
   }
   return true;  
 }
subObservationVisualiserBase::subObservationVisualiserBase(const context& contextObj, float pointSize)
    :pointSize(pointSize), contextObj(contextObj),standardPointsItem(NULL), standardLinesItem(NULL), backgroundItem(NULL)
{
    //We don't run this if there are no vertex positions
    if(contextObj.getVertexPositions().size() == 0)
    {
        std::cout << "Specified graph did not have vertex positions, exiting..." << std::endl;
        QTimer::singleShot(0, this, SLOT(close()));
        return;
    }
    initialiseControls();

    QPen pen(Qt::NoPen);
    QColor grey("grey");
    grey.setAlphaF(0.5);
    QBrush brush;
    brush.setColor(grey);
    brush.setStyle(Qt::SolidPattern);
    backgroundItem = new QGraphicsRectItem(minX, minY, maxX - minX, maxY - minY, NULL);
    backgroundItem->setPen(pen);
    backgroundItem->setBrush(brush);
    backgroundItem->setZValue(-1);
    graphicsScene->addItem(backgroundItem);
}
예제 #20
0
void
perfroll::draw_sequence_on (Glib::RefPtr<Gdk::Drawable> a_draw, int a_sequence)
{
    if ((a_sequence < m_sequence_max) && perf().is_active(a_sequence))
    {
        long tick_offset = m_4bar_offset * m_ticks_per_bar;
        long x_offset = tick_offset / m_perf_scale_x;
        m_sequence_active[a_sequence] = true;
        sequence * seq =  perf().get_sequence(a_sequence);
        seq->reset_draw_trigger_marker();
        a_sequence -= m_sequence_offset;

        long sequence_length = seq->get_length();
        int length_w = sequence_length / m_perf_scale_x;
        long tick_on;
        long tick_off;
        long offset;
        bool selected;

        while (seq->get_next_trigger(&tick_on, &tick_off, &selected, &offset))
        {
            if (tick_off > 0)
            {
                long x_on  = tick_on  / m_perf_scale_x;
                long x_off = tick_off / m_perf_scale_x;
                int w = x_off - x_on + 1;
                int x = x_on;
                int y = m_names_y * a_sequence + 1;     // + 2
                int h = m_names_y - 2;                  // - 4
                x -= x_offset;          /* adjust to screen coordinates */
                if (selected)
                    m_gc->set_foreground(grey());
                else
                    m_gc->set_foreground(white());

                a_draw->draw_rectangle
                (
                    m_gc, true, x, y, w, h
                );
                m_gc->set_foreground(black());
                a_draw->draw_rectangle
                (
                    m_gc, false, x, y, w, h
                );

                m_gc->set_foreground(black());
                a_draw->draw_rectangle
                (
                    m_gc, false, x, y,
                    m_size_box_w, m_size_box_w    // ?
                );
                a_draw->draw_rectangle
                (
                    m_gc, false,
                    x + w - m_size_box_w,
                    y + h - m_size_box_w,
                    m_size_box_w, m_size_box_w    // ?
                );
                m_gc->set_foreground(black());

                long length_marker_first_tick =
                (
                    tick_on - (tick_on % sequence_length) +
                    (offset % sequence_length) - sequence_length
                );
                long tick_marker = length_marker_first_tick;
                while (tick_marker < tick_off)
                {
                    long tick_marker_x =
                        (tick_marker / m_perf_scale_x) - x_offset;

                    if (tick_marker > tick_on)
                    {
                        m_gc->set_foreground(light_grey());
                        a_draw->draw_rectangle
                        (
                            m_gc, true, tick_marker_x, y + 4, 1, h - 8
                        );
                    }

                    int lowest_note = seq->get_lowest_note_event();
                    int highest_note = seq->get_highest_note_event();
                    int height = highest_note - lowest_note + 2;
                    int length = seq->get_length();
                    long tick_s;
                    long tick_f;
                    int note;
                    bool selected;
                    int velocity;
                    draw_type dt;
                    seq->reset_draw_marker();
                    m_gc->set_foreground(black());
                    while
                    (
                        (
                            dt = seq->get_next_note_event
                            (
                                &tick_s, &tick_f, &note, &selected, &velocity
                            )
                        ) != DRAW_FIN
                    )
                    {
                        int note_y =
                        (
                            (m_names_y-6) -
                            ((m_names_y-6) * (note-lowest_note)) / height
                        ) + 1;
                        int tick_s_x =
                            ((tick_s * length_w) / length) + tick_marker_x;

                        int tick_f_x =
                            ((tick_f * length_w) / length) + tick_marker_x;

                        if (dt == DRAW_NOTE_ON || dt == DRAW_NOTE_OFF)
                            tick_f_x = tick_s_x + 1;

                        if (tick_f_x <= tick_s_x)
                            tick_f_x = tick_s_x + 1;

                        if (tick_s_x < x)
                            tick_s_x = x;

                        if (tick_f_x > x + w)
                            tick_f_x = x + w;

                        if (tick_f_x >= x && tick_s_x <= x + w)
                        {
                            m_pixmap->draw_line
                            (
                                m_gc, tick_s_x, y + note_y,
                                tick_f_x, y + note_y
                            );
                        }
                    }
                    tick_marker += sequence_length;
                }
            }
        }
    }
}
예제 #21
0
void
MppTabBar :: paintEvent(QPaintEvent *event)
{
	int ht = computeHeight(width());

	if (ht != height())
		doRepaintEnqueue();

	QPainter paint(this);

	int w = width();
	int h = height();
	int x_off = 0;
	int y_off;
	int n;
	int r;

	paint.setRenderHints(QPainter::Antialiasing, 1);
	paint.setFont(font());

	QColor grey(192,192,192);
	QColor light(128,128,128);
	QColor white(255,255,255);
	QColor black(0,0,0);

	paint.setPen(QPen(grey, 0));
	paint.setBrush(grey);
	paint.drawRoundedRect(QRect(0,0,w,h), 4, 4);

	for (r = n = 0; n != ntabs; n++) {
		int dw = computeWidth(n);
		if (x_off != 0 && x_off + dw >= w) {
			x_off = 0;
			r++;
		}
		y_off = r * basic_size * 2;

		if (isVisible(tabs[n].w)) {
			paint.setPen(QPen(black, 0));
			paint.setBrush(black);
		} else {
			paint.setPen(QPen(light, 0));
			paint.setBrush(light);
		}
		if (tabs[n].flags & FLAG_LEFT) {
			QPoint temp[3] = {
				QPoint(x_off, y_off + basic_size),
				QPoint(x_off + basic_size, y_off + (basic_size / 4)),
				QPoint(x_off + basic_size, y_off + (basic_size * 2) - (basic_size / 4) - 1)
			};
			paint.drawPolygon(temp, 3);

		} else if (tabs[n].flags & FLAG_RIGHT) {
			QPoint temp[3] = {
				QPoint(x_off + dw - basic_size, y_off + (basic_size / 4)),
				QPoint(x_off + dw, y_off + basic_size),
				QPoint(x_off + dw - basic_size, y_off + (basic_size * 2) - (basic_size / 4) - 1)
			};
			paint.drawPolygon(temp, 3);
		}

		tabs[n].area = QRect(x_off + (basic_size / 2), y_off + (basic_size / 4),
		    dw - basic_size, (basic_size * 2) - (basic_size / 2));

		if (isVisible(tabs[n].w)) {
			QRect area(x_off + basic_size, y_off + (basic_size / 4),
			    dw - (2*basic_size), (basic_size * 2) - (basic_size / 2));

			paint.setPen(QPen(white, 0));
			paint.setBrush(white);
			paint.drawRect(area);
		}

		paint.setPen(QPen(black, 0));
		paint.setBrush(black);
		paint.drawText(QRect(x_off + basic_size + (basic_size / 4),
		    y_off + (basic_size / 2),
		    dw - (2 * basic_size) - (basic_size / 2), basic_size),
		    Qt::TextSingleLine | Qt::AlignCenter, tabs[n].name);

		x_off += dw;
	}
	if (x_off != 0) {
		x_off = 0;
		r++;
	}
	for (n = 0; n != nwidgets; n++) {
		int dw = (widgets[n].pWidget ? 4 : 3) * basic_size;
		if (x_off != 0 && x_off + dw >= w) {
			x_off = 0;
			r++;
		}
		y_off = r * basic_size * 2;
		x_off += dw;
		if (widgets[n].pWidget == 0)
			continue;
		widgets[n].area = QRect(x_off - dw, y_off,
		    4 * basic_size, 2 * basic_size);
		widgets[n].pWidget->setGeometry(widgets[n].area);
		QWidget::eventFilter(widgets[n].pWidget, event);
	}
	y_off = (r + 1) * basic_size * 2;
}
예제 #22
0
void FileEditorWnd::setCommonStyle()
{
	m_textCtrl->SetMarginWidth(MARGIN_LINE_NUMBERS, 50);
	m_textCtrl->SetMarginType(MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);

	m_textCtrl->SetMarginWidth(MARGIN_BREAKPOINTS, 16);
	m_textCtrl->SetMarginType(MARGIN_BREAKPOINTS, wxSTC_MARGIN_SYMBOL);
	m_textCtrl->SetMarginSensitive(MARGIN_BREAKPOINTS, true);

	m_textCtrl->SetWrapMode(wxSTC_WRAP_NONE);

	m_textCtrl->MarkerDefineBitmap(MARK_BREAKPOINT_ON, wxImage(breakpoint_on_xpm));
	m_textCtrl->MarkerDefineBitmap(MARK_BREAKPOINT_OFF, wxImage(breakpoint_off_xpm));
	m_textCtrl->MarkerDefineBitmap(MARK_BREAKPOINT_INVALID, wxImage(breakpoint_invalid_xpm));
	m_textCtrl->MarkerDefineBitmap(MARK_DEBUGCURSOR, wxImage(debugcursor_xpm));

	// ---- Enable code folding
	m_textCtrl->SetMarginWidth(MARGIN_FOLD, 15);
	m_textCtrl->SetMarginType(MARGIN_FOLD, wxSTC_MARGIN_SYMBOL);
	m_textCtrl->SetMarginMask(MARGIN_FOLD, wxSTC_MASK_FOLDERS);
	m_textCtrl->SetMarginSensitive(MARGIN_FOLD, true);
	m_textCtrl->SetFoldMarginColour(true, wxColour(220, 220, 220));
	m_textCtrl->SetFoldMarginHiColour(true, clDefaultBkg);
	//wxColour foldMarginColour(clDefaultBkg);
	//m_textCtrl->StyleSetBackground(MARGIN_FOLD, foldMarginColour);

	// Properties found from http://www.scintilla.org/SciTEDoc.html
	m_textCtrl->SetProperty(wxT("fold"), wxT("1"));
	m_textCtrl->SetProperty(wxT("fold.comment"), wxT("1"));
	m_textCtrl->SetProperty(wxT("fold.compact"), wxT("1"));
	m_textCtrl->SetProperty(wxT("fold.preprocessor"), wxT("1"));
	// Disable automatic detection of inactive code due to #if #else #endif,
	// since lots of defines will be outside the file
	m_textCtrl->SetProperty("lexer.cpp.track.preprocessor", "0");

	wxColour grey(100, 100, 100);
	wxColour fcolour(240, 240, 240);
	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDER, fcolour);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDER, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDEROPEN, fcolour);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDEROPEN, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDERSUB, grey);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDERSUB, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDEREND, fcolour);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDEREND, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDEROPENMID, fcolour);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDEROPENMID, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDERMIDTAIL, grey);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDERMIDTAIL, grey);

	m_textCtrl->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER);
	m_textCtrl->MarkerSetForeground(wxSTC_MARKNUM_FOLDERTAIL, grey);
	m_textCtrl->MarkerSetBackground(wxSTC_MARKNUM_FOLDERTAIL, grey);
	// ---- End of code folding part

	// Indentation settings
	auto tabWidth = m_textCtrl->GetTabWidth();
	m_textCtrl->SetUseTabs(true);
	m_textCtrl->SetIndent(4);
	m_textCtrl->SetTabWidth(4);
	m_textCtrl->SetTabIndents(true);
	m_textCtrl->SetBackSpaceUnIndents(true);

	m_textCtrl->SetWhitespaceForeground(true, gWhiteSpaceColour);

	// Set indicator styles
	for (int i = 0; i < (int)gIndicatorStyles.size(); i++)
	{
		m_textCtrl->IndicatorSetStyle(i, gIndicatorStyles[i].style);
		m_textCtrl->IndicatorSetForeground(i, gIndicatorStyles[i].colour);
		m_textCtrl->IndicatorSetAlpha(i, gIndicatorStyles[i].alpha);
	}

	m_textCtrl->SetCaretLineBackground(clCurrentLineBkg);
	m_textCtrl->SetCaretLineVisible(true);
}
void 												
World::build(void) {
	int num_samples = 1; 
	
	// view plane  
	  
	vp.set_hres(400);
	vp.set_vres(400);
	vp.set_pixel_size(0.5);
	vp.set_samples(num_samples);
	
	// the ambient light here is the same as the default set in the World
	// constructor, and can therefore be left out
	
	Ambient* ambient_ptr = new Ambient;
	ambient_ptr->scale_radiance(1.0);
	set_ambient_light(ambient_ptr); 

	background_color = black;			// default color - this can be left out
	
	tracer_ptr = new RayCast(this); 

	
	// camera
	
	Pinhole* pinhole_ptr = new Pinhole;
	pinhole_ptr->set_eye(0, 0, 500); 
	pinhole_ptr->set_lookat(0.0);
	pinhole_ptr->set_view_distance(600.0);
	pinhole_ptr->compute_uvw();     
	set_camera(pinhole_ptr);

	
	// light
	
	Directional* light_ptr1 = new Directional;
	light_ptr1->set_direction(100, 100, 200);
	light_ptr1->scale_radiance(3.0); 	
	add_light(light_ptr1);
	
	
	// colors

	RGBColor yellow(1, 1, 0);										// yellow
	RGBColor brown(0.71, 0.40, 0.16);								// brown
	RGBColor darkGreen(0.0, 0.41, 0.41);							// darkGreen
	RGBColor orange(1, 0.75, 0);									// orange
	RGBColor green(0, 0.6, 0.3);									// green
	RGBColor lightGreen(0.65, 1, 0.30);								// light green
	RGBColor darkYellow(0.61, 0.61, 0);								// dark yellow
	RGBColor lightPurple(0.65, 0.3, 1);								// light purple
	RGBColor darkPurple(0.5, 0, 1);									// dark purple
	RGBColor grey(0.25);											// grey
	
	
	// Matte material reflection coefficients - common to all materials
	
	float ka = 0.25;
	float kd = 0.75;
	
	
	// spheres
	
	Matte* matte_ptr1 = new Matte;   
	matte_ptr1->set_ka(ka);	
	matte_ptr1->set_kd(kd);
	matte_ptr1->set_cd(yellow);				
	Sphere*	sphere_ptr1 = new Sphere(Point3D(5, 3, 0), 30); 
	sphere_ptr1->set_material(matte_ptr1);	   							// yellow
	add_object(sphere_ptr1);
	
	Matte* matte_ptr2 = new Matte;
	matte_ptr2->set_ka(ka);	
	matte_ptr2->set_kd(kd);
	matte_ptr2->set_cd(brown);
	Sphere*	sphere_ptr2 = new Sphere(Point3D(45, -7, -60), 20); 
	sphere_ptr2->set_material(matte_ptr2);								// brown
	add_object(sphere_ptr2);
	

	Matte* matte_ptr3 = new Matte;
	matte_ptr3->set_ka(ka);	
	matte_ptr3->set_kd(kd);
	matte_ptr3->set_cd(darkGreen);	
	Sphere*	sphere_ptr3 = new Sphere(Point3D(40, 43, -100), 17); 
	sphere_ptr3->set_material(matte_ptr3);								// dark green
	add_object(sphere_ptr3);
	
	Matte* matte_ptr4 = new Matte;
	matte_ptr4->set_ka(ka);	
	matte_ptr4->set_kd(kd);
	matte_ptr4->set_cd(orange);
	Sphere*	sphere_ptr4 = new Sphere(Point3D(-20, 28, -15), 20); 
	sphere_ptr4->set_material(matte_ptr4);								// orange
	add_object(sphere_ptr4);
	
	Matte* matte_ptr5 = new Matte;
	matte_ptr5->set_ka(ka);	
	matte_ptr5->set_kd(kd);
	matte_ptr5->set_cd(green);
	Sphere*	sphere_ptr5 = new Sphere(Point3D(-25, -7, -35), 27); 			
	sphere_ptr5->set_material(matte_ptr5);								// green
	add_object(sphere_ptr5);
	
	Matte* matte_ptr6 = new Matte;
	matte_ptr6->set_ka(ka);	
	matte_ptr6->set_kd(kd);
	matte_ptr6->set_cd(lightGreen);
	Sphere*	sphere_ptr6 = new Sphere(Point3D(20, -27, -35), 25); 
	sphere_ptr6->set_material(matte_ptr6);								// light green
	add_object(sphere_ptr6);
	
	Matte* matte_ptr7 = new Matte;
	matte_ptr7->set_ka(ka);	
	matte_ptr7->set_kd(kd);
	matte_ptr7->set_cd(green);
	Sphere*	sphere_ptr7 = new Sphere(Point3D(35, 18, -35), 22); 
	sphere_ptr7->set_material(matte_ptr7);   							// green
	add_object(sphere_ptr7);
	
	Matte* matte_ptr8 = new Matte;
	matte_ptr8->set_ka(ka);	
	matte_ptr8->set_kd(kd);
	matte_ptr8->set_cd(brown);
	Sphere*	sphere_ptr8 = new Sphere(Point3D(-57, -17, -50), 15);  
	sphere_ptr8->set_material(matte_ptr8);								// brown
	add_object(sphere_ptr8);
	
	Matte* matte_ptr9 = new Matte;
	matte_ptr9->set_ka(ka);	
	matte_ptr9->set_kd(kd);
	matte_ptr9->set_cd(lightGreen);
	Sphere*	sphere_ptr9 = new Sphere(Point3D(-47, 16, -80), 23); 
	sphere_ptr9->set_material(matte_ptr9);								// light green
	add_object(sphere_ptr9);
		
	Matte* matte_ptr10 = new Matte;
	matte_ptr10->set_ka(ka);	
	matte_ptr10->set_kd(kd);
	matte_ptr10->set_cd(darkGreen);	
	Sphere*	sphere_ptr10 = new Sphere(Point3D(-15, -32, -60), 22); 
	sphere_ptr10->set_material(matte_ptr10);     						// dark green
	add_object(sphere_ptr10);
	
	Matte* matte_ptr11 = new Matte;
	matte_ptr11->set_ka(ka);	
	matte_ptr11->set_kd(kd);
	matte_ptr11->set_cd(darkYellow);
	Sphere*	sphere_ptr11 = new Sphere(Point3D(-35, -37, -80), 22); 
	sphere_ptr11->set_material(matte_ptr11);							// dark yellow
	add_object(sphere_ptr11);
	
	Matte* matte_ptr12 = new Matte;
	matte_ptr12->set_ka(ka);	
	matte_ptr12->set_kd(kd);
	matte_ptr12->set_cd(darkYellow);
	Sphere*	sphere_ptr12 = new Sphere(Point3D(10, 43, -80), 22); 
	sphere_ptr12->set_material(matte_ptr12);							// dark yellow
	add_object(sphere_ptr12);
	
	Matte* matte_ptr13 = new Matte;
	matte_ptr13->set_ka(ka);	
	matte_ptr13->set_kd(kd);
	matte_ptr13->set_cd(darkYellow);		
	Sphere*	sphere_ptr13 = new Sphere(Point3D(30, -7, -80), 10); 
	sphere_ptr13->set_material(matte_ptr13);
	add_object(sphere_ptr13);											// dark yellow (hidden)
	
	Matte* matte_ptr14 = new Matte;
	matte_ptr14->set_ka(ka);	
	matte_ptr14->set_kd(kd);
	matte_ptr14->set_cd(darkGreen);	
	Sphere*	sphere_ptr14 = new Sphere(Point3D(-40, 48, -110), 18); 
	sphere_ptr14->set_material(matte_ptr14); 							// dark green
	add_object(sphere_ptr14);
	
	Matte* matte_ptr15 = new Matte;
	matte_ptr15->set_ka(ka);	
	matte_ptr15->set_kd(kd);
	matte_ptr15->set_cd(brown);	
	Sphere*	sphere_ptr15 = new Sphere(Point3D(-10, 53, -120), 18); 
	sphere_ptr15->set_material(matte_ptr15); 							// brown
	add_object(sphere_ptr15);
	
	Matte* matte_ptr16 = new Matte;
	matte_ptr16->set_ka(ka);	
	matte_ptr16->set_kd(kd);
	matte_ptr16->set_cd(lightPurple);
	Sphere*	sphere_ptr16 = new Sphere(Point3D(-55, -52, -100), 10); 
	sphere_ptr16->set_material(matte_ptr16);							// light purple
	add_object(sphere_ptr16);
	
	Matte* matte_ptr17 = new Matte;
	matte_ptr17->set_ka(ka);	
	matte_ptr17->set_kd(kd);
	matte_ptr17->set_cd(brown);
	Sphere*	sphere_ptr17 = new Sphere(Point3D(5, -52, -100), 15); 		
	sphere_ptr17->set_material(matte_ptr17);							// browm
	add_object(sphere_ptr17);
	
	Matte* matte_ptr18 = new Matte;
	matte_ptr18->set_ka(ka);	
	matte_ptr18->set_kd(kd);
	matte_ptr18->set_cd(darkPurple);
	Sphere*	sphere_ptr18 = new Sphere(Point3D(-20, -57, -120), 15); 
	sphere_ptr18->set_material(matte_ptr18);							// dark purple
	add_object(sphere_ptr18);
	
	Matte* matte_ptr19 = new Matte;
	matte_ptr19->set_ka(ka);	
	matte_ptr19->set_kd(kd);
	matte_ptr19->set_cd(darkGreen);
	Sphere*	sphere_ptr19 = new Sphere(Point3D(55, -27, -100), 17); 
	sphere_ptr19->set_material(matte_ptr19);							// dark green
	add_object(sphere_ptr19);

	Matte* matte_ptr20 = new Matte;
	matte_ptr20->set_ka(ka);	
	matte_ptr20->set_kd(kd);
	matte_ptr20->set_cd(brown);
	Sphere*	sphere_ptr20 = new Sphere(Point3D(50, -47, -120), 15); 
	sphere_ptr20->set_material(matte_ptr20);							// browm
	add_object(sphere_ptr20);
	 
	Matte* matte_ptr21 = new Matte;
	matte_ptr21->set_ka(ka);	
	matte_ptr21->set_kd(kd);
	matte_ptr21->set_cd(lightPurple); 	
	Sphere*	sphere_ptr21 = new Sphere(Point3D(70, -42, -150), 10); 
	sphere_ptr21->set_material(matte_ptr21);							// light purple
	add_object(sphere_ptr21);
	
	Matte* matte_ptr22 = new Matte;
	matte_ptr22->set_ka(ka);	
	matte_ptr22->set_kd(kd);
	matte_ptr22->set_cd(lightPurple);
	Sphere*	sphere_ptr22 = new Sphere(Point3D(5, 73, -130), 12); 
	sphere_ptr22->set_material(matte_ptr22);							// light purple
	add_object(sphere_ptr22);
	
	Matte* matte_ptr23 = new Matte;
	matte_ptr23->set_ka(ka);	
	matte_ptr23->set_kd(kd);
	matte_ptr23->set_cd(darkPurple);
	Sphere*	sphere_ptr23 = new Sphere(Point3D(66, 21, -130), 13); 			
	sphere_ptr23->set_material(matte_ptr23);							// dark purple
	add_object(sphere_ptr23);	
	
	Matte* matte_ptr24 = new Matte;
	matte_ptr24->set_ka(ka);	
	matte_ptr24->set_kd(kd);
	matte_ptr24->set_cd(lightPurple);  
	Sphere*	sphere_ptr24 = new Sphere(Point3D(72, -12, -140), 12); 
	sphere_ptr24->set_material(matte_ptr24);							// light purple
	add_object(sphere_ptr24);
	
	Matte* matte_ptr25 = new Matte;
	matte_ptr25->set_ka(ka);	
	matte_ptr25->set_kd(kd);
	matte_ptr25->set_cd(green);
	Sphere*	sphere_ptr25 = new Sphere(Point3D(64, 5, -160), 11); 			
	sphere_ptr25->set_material(matte_ptr25);					 		// green
	add_object(sphere_ptr25);
	  
	Matte* matte_ptr26 = new Matte;
	matte_ptr26->set_ka(ka);	
	matte_ptr26->set_kd(kd);
	matte_ptr26->set_cd(lightPurple);
	Sphere*	sphere_ptr26 = new Sphere(Point3D(55, 38, -160), 12); 		
	sphere_ptr26->set_material(matte_ptr26);							// light purple
	add_object(sphere_ptr26);
	
	Matte* matte_ptr27 = new Matte;
	matte_ptr27->set_ka(ka);	
	matte_ptr27->set_kd(kd);
	matte_ptr27->set_cd(lightPurple);
	Sphere*	sphere_ptr27 = new Sphere(Point3D(-73, -2, -160), 12); 		
	sphere_ptr27->set_material(matte_ptr27);							// light purple
	add_object(sphere_ptr27);
	 
	Matte* matte_ptr28 = new Matte;
	matte_ptr28->set_ka(ka);	
	matte_ptr28->set_kd(kd);
	matte_ptr28->set_cd(darkPurple);
	Sphere*	sphere_ptr28 = new Sphere(Point3D(30, -62, -140), 15); 
	sphere_ptr28->set_material(matte_ptr28); 							// dark purple
	add_object(sphere_ptr28);
	
	Matte* matte_ptr29 = new Matte;
	matte_ptr29->set_ka(ka);	
	matte_ptr29->set_kd(kd);
	matte_ptr29->set_cd(darkPurple);
	Sphere*	sphere_ptr29 = new Sphere(Point3D(25, 63, -140), 15); 
	sphere_ptr29->set_material(matte_ptr29);							// dark purple
	add_object(sphere_ptr29);
	
	Matte* matte_ptr30 = new Matte;
	matte_ptr30->set_ka(ka);	
	matte_ptr30->set_kd(kd);
	matte_ptr30->set_cd(darkPurple);
	Sphere*	sphere_ptr30 = new Sphere(Point3D(-60, 46, -140), 15);  
	sphere_ptr30->set_material(matte_ptr30); 							// dark purple
	add_object(sphere_ptr30);
	
	Matte* matte_ptr31 = new Matte;
	matte_ptr31->set_ka(ka);	
	matte_ptr31->set_kd(kd);
	matte_ptr31->set_cd(lightPurple);
	Sphere*	sphere_ptr31 = new Sphere(Point3D(-30, 68, -130), 12); 
	sphere_ptr31->set_material(matte_ptr31); 							// light purple
	add_object(sphere_ptr31);
	
	Matte* matte_ptr32 = new Matte;
	matte_ptr32->set_ka(ka);	
	matte_ptr32->set_kd(kd);
	matte_ptr32->set_cd(green);
	Sphere*	sphere_ptr32 = new Sphere(Point3D(58, 56, -180), 11);   
	sphere_ptr32->set_material(matte_ptr32);							//  green
	add_object(sphere_ptr32);
	
	Matte* matte_ptr33 = new Matte;
	matte_ptr33->set_ka(ka);	
	matte_ptr33->set_kd(kd);
	matte_ptr33->set_cd(green);
	Sphere*	sphere_ptr33 = new Sphere(Point3D(-63, -39, -180), 11); 
	sphere_ptr33->set_material(matte_ptr33);							// green 
	add_object(sphere_ptr33);
	
	Matte* matte_ptr34 = new Matte;
	matte_ptr34->set_ka(ka);	
	matte_ptr34->set_kd(kd);
	matte_ptr34->set_cd(lightPurple);
	Sphere*	sphere_ptr34 = new Sphere(Point3D(46, 68, -200), 10); 	
	sphere_ptr34->set_material(matte_ptr34);							// light purple
	add_object(sphere_ptr34);
	
	Matte* matte_ptr35 = new Matte;
	matte_ptr35->set_ka(ka);	
	matte_ptr35->set_kd(kd);
	matte_ptr35->set_cd(lightPurple);
	Sphere*	sphere_ptr35 = new Sphere(Point3D(-3, -72, -130), 12); 
	sphere_ptr35->set_material(matte_ptr35);							// light purple
	add_object(sphere_ptr35);
	
	
	// vertical plane
	
	Matte* matte_ptr36 = new Matte;
	matte_ptr36->set_ka(ka);	
	matte_ptr36->set_kd(kd);
	matte_ptr36->set_cd(grey);
	Plane* plane_ptr = new Plane(Point3D(0, 0, -150), Normal(0, 0, 1));
	plane_ptr->set_material(matte_ptr36);
	add_object (plane_ptr);
}
예제 #24
0
//------------------------------------------------------------------------
void CWaveDisplay::draw(CDrawContext* pContext)
{
    CPoint offset(38, 16);

    CRect R(0, 0, getViewSize().getWidth(), getViewSize().getHeight());
    back->draw(pContext, R.offset(offset), offset);

    R(615 - getViewSize().left, 240 - getViewSize().top, 615 + heads->getWidth() - getViewSize().left, 240 + heads->getHeight() / 4 - getViewSize().top);
    heads->draw(pContext, R.offset(offset), CPoint(0, (display * heads->getHeight()) / 4));

    pContext->setDrawMode(CDrawMode(kAntiAliasing));

    // trig-line
    long triggerType = (long)(effect->getParameter(CSmartelectronixDisplay::kTriggerType) * CSmartelectronixDisplay::kNumTriggerTypes + 0.0001);

    if (triggerType == CSmartelectronixDisplay::kTriggerRising || triggerType == CSmartelectronixDisplay::kTriggerFalling) {
        long y = 1 + (long)((1.f - effect->getParameter(CSmartelectronixDisplay::kTriggerLevel)) * (getViewSize().getHeight() - 2));

        CColor grey(229, 229, 229);
        pContext->setFrameColor(grey);
        pContext->drawLine(CPoint(0, y).offset(offset), CPoint(getViewSize().getWidth() - 1, y).offset(offset));
    }

    // zero-line
    CColor orange(179, 111, 56);
    pContext->setFrameColor(orange);
    pContext->drawLine(CPoint(0, getViewSize().getHeight() * 0.5 - 1).offset(offset), CPoint(getViewSize().getWidth() - 1, getViewSize().getHeight() * 0.5 - 1).offset(offset));

    // waveform
    const std::vector<CPoint>& points = (effect->getParameter(CSmartelectronixDisplay::kSyncDraw) > 0.5f) ? effect->getCopy() : effect->getPeaks();
    double counterSpeedInverse = pow(10.f, effect->getParameter(CSmartelectronixDisplay::kTimeWindow) * 5.f - 1.5);

    if (counterSpeedInverse < 1.0) //draw interpolated lines!
    {
        CColor blue(64, 148, 172);
        pContext->setFrameColor(blue);

        double phase = counterSpeedInverse;
        double dphase = counterSpeedInverse;

        double prevxi = points[0].x;
        double prevyi = points[0].y;

        for (long i = 1; i < getViewSize().getWidth() - 1; i++) {
            long index = (long)phase;
            double alpha = phase - (double)index;

            double xi = i;
            double yi = (1.0 - alpha) * points[index * 2].y + alpha * points[(index + 1) * 2].y;

            pContext->drawLine(CPoint(prevxi, prevyi).offset(offset), CPoint(xi, yi).offset(offset));
            prevxi = xi;
            prevyi = yi;

            phase += dphase;
        }
    } else {
        CColor grey(118, 118, 118);
        pContext->setFrameColor(grey);

        CPoint p1, p2;
        for (unsigned int i=0; i<points.size()-1; i++)
        {
            p1 = points[i];
            p2 = points[i+1];
            pContext->drawLine(p1.offset(offset), p2.offset(offset));
        }
    }

    //TODO clean this mess up...
    if (where.x != -1) {
        CPoint whereOffset = where;
        whereOffset.offsetInverse(offset);

        pContext->drawLine(CPoint(0, whereOffset.y).offset(offset), CPoint(getViewSize().getWidth() - 1, whereOffset.y).offset(offset));
        pContext->drawLine(CPoint(whereOffset.x, 0).offset(offset), CPoint(whereOffset.x, getViewSize().getHeight() - 1).offset(offset));

        float gain = powf(10.f, effect->getParameter(CSmartelectronixDisplay::kAmpWindow) * 6.f - 3.f);
        float y = (-2.f * ((float)whereOffset.y + 1.f) / (float)OSC_HEIGHT + 1.f) / gain;
        float x = (float)whereOffset.x * (float)counterSpeedInverse;
        char text[256];

        long lineSize = 10;

        CColor color(179, 111, 56);

        pContext->setFontColor(color);
        pContext->setFont(kNormalFontSmaller);

        readout->draw(pContext, CRect(508, 8, 508 + readout->getWidth(), 8 + readout->getHeight()).offset(offset), CPoint(0, 0));

        CRect textRect(512, 10, 652, 10 + lineSize);
        textRect.offset(offset);

        sprintf(text, "y = %.5f", y);
        pContext->drawString(text, textRect, kLeftText, true);
        textRect.offset(0, lineSize);

        sprintf(text, "y = %.5f dB", cf_lin2db(fabsf(y)));
        pContext->drawString(text, textRect, kLeftText, true);
        textRect.offset(0, lineSize * 2);

        sprintf(text, "x = %.2f samples", x);
        pContext->drawString(text, textRect, kLeftText, true);
        textRect.offset(0, lineSize);

        sprintf(text, "x = %.5f seconds", x / effect->getSampleRate());
        pContext->drawString(text, textRect, kLeftText, true);
        textRect.offset(0, lineSize);

        sprintf(text, "x = %.5f ms", 1000.f * x / effect->getSampleRate());
        pContext->drawString(text, textRect, kLeftText, true);
        textRect.offset(0, lineSize);

        if (x == 0)
            sprintf(text, "x = infinite Hz");
        else
            sprintf(text, "x = %.3f Hz", effect->getSampleRate() / x);

        pContext->drawString(text, textRect, kLeftText, true);
    }
}
예제 #25
0
void GUIFCCharacterItem::draw()
{
	if ( !IsVisible )
		return;

  SColor grey(255, 128, 128, 128);
	SColor white(255, 255, 255, 255);
  SColor charInset(255, 0, 64, 128);
  SColor blue(255, 64, 128, 255);
  core::rect<s32> rect = AbsoluteRect;
  wstringstream s;

  // draw the outline and background
  m_pDriver->draw2DRectangle( rect, grey, grey, grey, grey);

  rect.LowerRightCorner.X -= 2;
  rect.LowerRightCorner.Y -= 2;
  rect.UpperLeftCorner.X += 2;
  rect.UpperLeftCorner.Y += 2;
  if ( !m_bHighlight )
	  m_pDriver->draw2DRectangle( rect, white, white, white, white);
  else
	  m_pDriver->draw2DRectangle( rect, white, white, blue, blue);

  // draw the 'character image' inset
  rect.UpperLeftCorner.X += 7;
  rect.UpperLeftCorner.Y += 7;
  rect.LowerRightCorner.Y -= 7;
  rect.LowerRightCorner.X = rect.UpperLeftCorner.X + rect.getHeight();
  m_pDriver->draw2DRectangle( rect, charInset, charInset, charInset, charInset );

  // update rectangle for lines of text
	rect.UpperLeftCorner.X = rect.LowerRightCorner.X + 10;
	rect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - 10;
  // create the character details string and textobject
	IGUIFont* pFont = Environment->getSkin()->getFont();

	if ( !pFont )
		pFont = Environment->getBuiltInFont();

	wstring str = m_pCharacter->GetName();
	core::dimension2d<s32> extents = pFont->getDimension( str.c_str() );
	rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + extents.Height;

	pFont->draw( str.c_str(), rect, SColor(255, 0, 0, 0) );

	rect.UpperLeftCorner.Y = rect.LowerRightCorner.Y;
	rect.LowerRightCorner.Y += extents.Height;
	s << L"Level: " << m_pCharacter->GetLevel();
	str = s.str();
	pFont->draw( str.c_str(), rect, SColor(255, 0, 0, 0) );

	rect.UpperLeftCorner.Y = rect.LowerRightCorner.Y;
	rect.LowerRightCorner.Y += extents.Height;
	s.str(L"");
	s << L"XP: " << m_pCharacter->GetXP();
	str = s.str();
	pFont->draw( str.c_str(), rect, SColor(255, 0, 0, 0) );

	IGUIElement::draw();
}
예제 #26
0
void
GUIParkingArea::drawGL(const GUIVisualizationSettings& s) const {
    glPushName(getGlID());
    glPushMatrix();
    RGBColor grey(177, 184, 186, 171);
    RGBColor blue(83, 89, 172, 255);
    RGBColor red(255, 0, 0, 255);
    RGBColor green(0, 255, 0, 255);
    // draw the area
    glTranslated(0, 0, getType());
    GLHelper::setColor(blue);
    GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myWidth / 2.);
    // draw details unless zoomed out to far
    const SUMOReal exaggeration = s.addSize.getExaggeration(s);
    if (s.scale * exaggeration >= 10) {
        // draw the lots
        glTranslated(0, 0, .1);
        std::map<unsigned int, LotSpaceDefinition >::const_iterator i;
        for (i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) {
            glPushMatrix();
            glTranslated((*i).second.myPosition.x(), (*i).second.myPosition.y(), (*i).second.myPosition.z());
            glRotated((*i).second.myRotation, 0, 0, 1);
            Position pos = (*i).second.myPosition;
            PositionVector geom;
            SUMOReal w = (*i).second.myWidth / 2.;
            SUMOReal h = (*i).second.myLength;
            geom.push_back(Position(- w, + 0, 0.));
            geom.push_back(Position(+ w, + 0, 0.));
            geom.push_back(Position(+ w, + h, 0.));
            geom.push_back(Position(- w, + h, 0.));
            geom.push_back(Position(- w, + 0, 0.));
            /*
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            */
            GLHelper::setColor((*i).second.vehicle == 0 ? green : red);
            GLHelper::drawBoxLines(geom, 0.1);
            glPopMatrix();
        }
        GLHelper::setColor(blue);
        // draw the lines
        for (size_t i = 0; i != myLines.size(); ++i) {
            glPushMatrix();
            glTranslated(mySignPos.x(), mySignPos.y(), 0);
            glRotated(180, 1, 0, 0);
            glRotated(mySignRot, 0, 0, 1);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            pfSetPosition(0, 0);
            pfSetScale(1.f);
            glScaled(exaggeration, exaggeration, 1);
            glTranslated(1.2, -(double)i, 0);
            pfDrawString(myLines[i].c_str());
            glPopMatrix();
        }
        // draw the sign
        glTranslated(mySignPos.x(), mySignPos.y(), 0);
        int noPoints = 9;
        if (s.scale * exaggeration > 25) {
            noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
        }
        glScaled(exaggeration, exaggeration, 1);
        GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
        glTranslated(0, 0, .1);
        GLHelper::setColor(grey);
        GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
        if (s.scale * exaggeration >= 4.5) {
            GLHelper::drawText("P", Position(), .1, 1.6 * exaggeration, blue, mySignRot);
        }
    }
    glPopMatrix();
    glPopName();
    drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
    for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) {
        glTranslated(0, 1, 0); // make multiple containers viewable
        static_cast<GUIContainer*>(*i)->drawGL(s);
    }
}
예제 #27
0
void
GUIParkingArea::drawGL(const GUIVisualizationSettings& s) const {
    glPushName(getGlID());
    glPushMatrix();
    RGBColor grey(177, 184, 186, 171);
    RGBColor blue(83, 89, 172, 255);
    RGBColor red(255, 0, 0, 255);
    RGBColor green(0, 255, 0, 255);
    // draw the area
    glTranslated(0, 0, getType());
    GLHelper::setColor(blue);
    GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myWidth / 2.);
    // draw details unless zoomed out to far
    const double exaggeration = s.addSize.getExaggeration(s);
    if (s.scale * exaggeration >= 1) {
        // draw the lots
        glTranslated(0, 0, .1);
        std::map<unsigned int, LotSpaceDefinition >::const_iterator i;
        for (i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) {
            glPushMatrix();
            glTranslated((*i).second.myPosition.x(), (*i).second.myPosition.y(), (*i).second.myPosition.z());
            glRotated((*i).second.myRotation, 0, 0, 1);
            Position pos = (*i).second.myPosition;
            PositionVector geom;
            double w = (*i).second.myWidth / 2. - 0.1 * exaggeration;
            double h = (*i).second.myLength;
            geom.push_back(Position(- w, + 0, 0.));
            geom.push_back(Position(+ w, + 0, 0.));
            geom.push_back(Position(+ w, + h, 0.));
            geom.push_back(Position(- w, + h, 0.));
            geom.push_back(Position(- w, + 0, 0.));
            /*
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            */
            GLHelper::setColor((*i).second.vehicle == 0 ? green : red);
            GLHelper::drawBoxLines(geom, 0.1 * exaggeration);
            glPopMatrix();
        }
        GLHelper::setColor(blue);
        // draw the lines
        for (size_t i = 0; i != myLines.size(); ++i) {
            // push a new matrix for every line
            glPushMatrix();
            // traslate and rotate
            glTranslated(mySignPos.x(), mySignPos.y(), 0);
            glRotated(180, 1, 0, 0);
            glRotated(mySignRot, 0, 0, 1);
            // draw line
            GLHelper::drawText(myLines[i].c_str(), Position(1.2, (double)i), .1, 1.f, RGBColor(76, 170, 50), 0, FONS_ALIGN_LEFT);
            // pop matrix for every line
            glPopMatrix();

        }
        // draw the sign
        glTranslated(mySignPos.x(), mySignPos.y(), 0);
        int noPoints = 9;
        if (s.scale * exaggeration > 25) {
            noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
        }
        glScaled(exaggeration, exaggeration, 1);
        GLHelper::drawFilledCircle((double) 1.1, noPoints);
        glTranslated(0, 0, .1);
        GLHelper::setColor(grey);
        GLHelper::drawFilledCircle((double) 0.9, noPoints);
        if (s.scale * exaggeration >= 4.5) {
            GLHelper::drawText("P", Position(), .1, 1.6, blue, mySignRot);
        }
    }
    glPopMatrix();
    if (s.addFullName.show && getMyName() != "") {
        GLHelper::drawText(getMyName(), mySignPos, GLO_MAX - getType(), s.addFullName.scaledSize(s.scale), s.addFullName.color, s.getTextAngle(mySignRot));
    }
    glPopName();
    drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
    for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) {
        glTranslated(0, 1, 0); // make multiple containers viewable
        static_cast<GUIContainer*>(*i)->drawGL(s);
    }
    // draw parking vehicles (their lane might not be within drawing range. if it is, they are drawn twice)
    myLane.getVehiclesSecure();
    for (std::set<const MSVehicle*>::const_iterator v = myLane.getParkingVehicles().begin(); v != myLane.getParkingVehicles().end(); ++v) {
        static_cast<const GUIVehicle* const>(*v)->drawGL(s);
    }
    myLane.releaseVehicles();

}
void Astar::paintImage() {
  int width  = 15;
  int height = 19;
  int s = 19;
  int r = s / 2;
  int o = r + 1;
  cv::Scalar white(255, 255, 255);
  cv::Scalar grey(200, 200, 200);
  cv::Scalar blue(200, 0, 0);
  cv::Scalar purple(200, 0, 200);
  cv::Scalar green(0, 200, 0);
  cv::Scalar red(0, 0, 200);
  cv::Scalar yellow(0, 255, 255);
  cv::Mat img(s*width, s*height, CV_8UC3, white);
  std::vector<Node> allNodes;
  for (std::set<Node>::iterator it = closedList.begin(); it != closedList.end(); it++) {
    allNodes.push_back(*it);
  }
  for (std::set<Node>::iterator it = openList.begin(); it != openList.end(); it++) {
    allNodes.push_back(*it);
  }
  for (std::set<Node>::iterator it = obstacles.begin(); it != obstacles.end(); it++) {
    allNodes.push_back(*it);
  }
  allNodes.push_back(this->goalNode);
  allNodes.push_back(this->startingNode);

  Node par;
  for (std::vector<Node>::iterator it = allNodes.begin(); it != allNodes.end(); it++) {
    Node cur = *it;
    int x = cur.getX();
    int y = cur.getY();
    switch(cur.getPaint()) {
      case OPEN:      cv::circle(img, cv::Point(s*x+o, s*y+o), r, grey, -1);
                      break;
      case CLOSED:    cv::circle(img, cv::Point(s*x+o, s*y+o), r, purple, -1);
                      break;
      case START:     cv::circle(img, cv::Point(s*x+o, s*y+o), r, red, -1);
                      break;
      case PATH:      par = cur.getParent();
                      cv::circle(img, cv::Point(s*x+o, s*y+o), r/2, yellow, -1);
                      break;
      case GOAL:      cv::circle(img, cv::Point(s*x+o, s*y+o), r, blue, -1);
                      break;
      case OBSTACLE:  cv::circle(img, cv::Point(s*x+o, s*y+o), r, green, -1);
                      break;
    }
  }
  for (std::vector<Node>::iterator it = path.begin(); it != path.end(); it++) {
    Node cur = *it;
    int x = cur.getX();
    int y = cur.getY();
    cv::circle(img, cv::Point(s*x+o, s*y+o), r/2, yellow, -1);
  }
  std::set<Node>::iterator it = std::min_element(obstacles.begin(), obstacles.end(), Node::CompareNode());
  Node currentNode = *it;
  std::stringstream title, filepath;
  title << "i=" << (currentNode.getX()-3);
  cv::namedWindow(title.str());
  cv::imshow(title.str(), img);
  filepath << "./img/" << "ue8_t2-" << ((currentNode.getX()-3)+2) << ".png";
  cv::imwrite(filepath.str(), img);
  cv::waitKey(0);
}
예제 #29
0
void FreeRegionGrabber::paintEvent( QPaintEvent* e )
{
    Q_UNUSED( e );
    if ( grabbing ) // grabWindow() should just get the background
        return;

    QPainter painter( this );

    QPalette pal(QToolTip::palette());
    QFont font = QToolTip::font();

    QColor handleColor = pal.color( QPalette::Active, QPalette::Highlight );
    handleColor.setAlpha( 160 );
    QColor overlayColor( 0, 0, 0, 160 );
    QColor textColor = pal.color( QPalette::Active, QPalette::Text );
    QColor textBackgroundColor = pal.color( QPalette::Active, QPalette::Base );
    painter.drawPixmap(0, 0, pixmap);
    painter.setFont(font);

    QPolygon pol = selection;
    if ( !selection.boundingRect().isNull() )
    {
        // Draw outline around selection.
        // Important: the 1px-wide outline is *also* part of the captured free-region because
        // I found no way to draw the outline *around* the selection because I found no way
        // to create a QPolygon which is smaller than the selection by 1px (QPolygon::translated
        // is NOT equivalent to QRect::adjusted)
        QPen pen(handleColor, 1, Qt::SolidLine, Qt::SquareCap, Qt::BevelJoin);
        painter.setPen(pen);
        painter.drawPolygon( pol );

        // Draw the grey area around the selection
        QRegion grey( rect() );
        grey = grey - pol;
        painter.setClipRegion( grey );
        painter.setPen( Qt::NoPen );
        painter.setBrush( overlayColor );
        painter.drawRect( rect() );
        painter.setClipRect( rect() );
        drawPolygon( &painter, pol, handleColor);
    }

    if ( showHelp )
    {
        painter.setPen( textColor );
        painter.setBrush( textBackgroundColor );
        QString helpText = i18n( "Select a region using the mouse. To take the snapshot, press the Enter key or double click. Press Esc to quit." );
        helpTextRect = painter.boundingRect( rect().adjusted( 2, 2, -2, -2 ), Qt::TextWordWrap, helpText );
        helpTextRect.adjust( -2, -2, 4, 2 );
        drawPolygon( &painter, helpTextRect, textColor, textBackgroundColor );
        painter.drawText( helpTextRect.adjusted( 3, 3, -3, -3 ), helpText );
    }

    if ( selection.isEmpty() )
    {
        return;
    }

    // The grabbed region is everything which is covered by the drawn
    // rectangles (border included). This means that there is no 0px
    // selection, since a 0px wide rectangle will always be drawn as a line.
    QString txt = QString( "%1x%2" ).arg( selection.boundingRect().width() )
                  .arg( selection.boundingRect().height() );
    QRect textRect = painter.boundingRect( rect(), Qt::AlignLeft, txt );
    QRect boundingRect = textRect.adjusted( -4, 0, 0, 0);

    if ( textRect.width() < pol.boundingRect().width() - 2*handleSize &&
         textRect.height() < pol.boundingRect().height() - 2*handleSize &&
         ( pol.boundingRect().width() > 100 && pol.boundingRect().height() > 100 ) ) // center, unsuitable for small selections
    {
        boundingRect.moveCenter( pol.boundingRect().center() );
        textRect.moveCenter( pol.boundingRect().center() );
    }
    else if ( pol.boundingRect().y() - 3 > textRect.height() &&
              pol.boundingRect().x() + textRect.width() < rect().right() ) // on top, left aligned
    {
        boundingRect.moveBottomLeft( QPoint( pol.boundingRect().x(), pol.boundingRect().y() - 3 ) );
        textRect.moveBottomLeft( QPoint( pol.boundingRect().x() + 2, pol.boundingRect().y() - 3 ) );
    }
    else if ( pol.boundingRect().x() - 3 > textRect.width() ) // left, top aligned
    {
        boundingRect.moveTopRight( QPoint( pol.boundingRect().x() - 3, pol.boundingRect().y() ) );
        textRect.moveTopRight( QPoint( pol.boundingRect().x() - 5, pol.boundingRect().y() ) );
    }
    else if ( pol.boundingRect().bottom() + 3 + textRect.height() < rect().bottom() &&
              pol.boundingRect().right() > textRect.width() ) // at bottom, right aligned
    {
        boundingRect.moveTopRight( QPoint( pol.boundingRect().right(), pol.boundingRect().bottom() + 3 ) );
        textRect.moveTopRight( QPoint( pol.boundingRect().right() - 2, pol.boundingRect().bottom() + 3 ) );
    }
    else if ( pol.boundingRect().right() + textRect.width() + 3 < rect().width() ) // right, bottom aligned
    {
        boundingRect.moveBottomLeft( QPoint( pol.boundingRect().right() + 3, pol.boundingRect().bottom() ) );
        textRect.moveBottomLeft( QPoint( pol.boundingRect().right() + 5, pol.boundingRect().bottom() ) );
    }
    // if the above didn't catch it, you are running on a very tiny screen...
    drawPolygon( &painter, boundingRect, textColor, textBackgroundColor );

    painter.drawText( textRect, txt );

    if ( ( pol.boundingRect().height() > handleSize*2 && pol.boundingRect().width() > handleSize*2 )
         || !mouseDown )
    {
        painter.setBrush(QBrush(Qt::transparent));
        painter.setClipRegion( QRegion(pol));
        painter.drawPolygon( rect() );
    }
}
예제 #30
0
TAM::TAM(int numTones, int numRes, Image* stroke)
: images(numTones, std::vector<Image*>(numRes)) {
    std::vector<Image> candidates(numRes);
    
    for (int tone = 0; tone < numTones; ++tone) {
        int imageSize = 1;
        for (int resolution = 0; resolution < numRes; ++resolution) {
            images[tone][resolution] = new Image(imageSize, imageSize);
            static Pixel white = Pixel(1,1,1);
            images[tone][resolution]->fillImage(white);
            if (tone == 0) {
                candidates[resolution] = Image(imageSize, imageSize);
            }
            imageSize *= 2;
        }
    }
    
    
    
    
    double darkestTone =.9;
    double lightestTone = .15;
    double toneInterval;
    if (numTones == 1) {
        toneInterval = darkestTone - lightestTone;
    } else {
        toneInterval = (darkestTone - lightestTone) / (numTones - 1);
    }
    for (int toneLevel = 0; toneLevel < numTones; ++toneLevel) {
        double maxTone = lightestTone + toneInterval * toneLevel;
        while (fabs(maxTone - images[toneLevel][numRes-1]->getTone()) > (.1/(numRes-3))) {
            RandomStroke bestStroke;
            double bestTone = -10000;
            for (int i = 0; i < 25; ++i) {
                double toneSum = 0;
                bool horizontalStroke = maxTone <= .7;
                RandomStroke currentStroke = getRandomStroke(horizontalStroke);
                for (int resolution = 3; resolution < numRes; ++resolution) {
                    if (fabs(maxTone - images[toneLevel][resolution]->getTone()) > (.1/(resolution-3+1.))) {
                        drawStroke(stroke, currentStroke, &candidates[resolution]);
                        // Get the effective length of the stroke, given that it might "run off" the edge
                        
                        double withStroke = fabs(maxTone - candidates[resolution].getTone());
                        double withoutStroke = fabs(maxTone - images[toneLevel][resolution]->getTone());
                        if (withoutStroke < withStroke) {
                            continue;
                        }
                        double toneContribution = candidates[resolution].getTone() - images[toneLevel][resolution]->getTone();
//                        // All images are squares, side lengths are equal
//                        const double imageSize = images[toneLevel][resolution]->getWidth();
//                        
//                        double actualStrokeLength = currentStroke.length * stroke->getWidth();
//                        double normalizedStrokeLength;
//                        double actualStrokeX = currentStroke.x*imageSize;
//                        double actualStrokeY = currentStroke.y*imageSize;
//                        if(horizontalStroke){
//                            normalizedStrokeLength = getActualStrokeLength(actualStrokeX, actualStrokeLength, imageSize);
//                        }
//                        else {
//                            normalizedStrokeLength = getActualStrokeLength(actualStrokeY, actualStrokeLength, imageSize);
//                        }
                        toneContribution /= currentStroke.length;
                        toneSum += toneContribution;
                        candidates[resolution] = *images[toneLevel][resolution];
                    }
                }
                
                if (toneSum > bestTone) {
                    bestTone = toneSum;
                    bestStroke = currentStroke;
                }
            }
            
            
            for (int candidate = 3; candidate < numRes; ++candidate) {
                if (fabs(maxTone - images[toneLevel][candidate]->getTone()) > (.1/(candidate-3 + 1.))) {
                    drawStroke(stroke, bestStroke, images[toneLevel][candidate]);
                    candidates[candidate] = *images[toneLevel][candidate];
                }
            }
        }

        for (int resolution=0; resolution<3; resolution++){
            float greyLevel = 1-maxTone;
            Pixel grey(greyLevel, greyLevel, greyLevel);
            images[toneLevel][resolution]->fillImage(grey);
        }
        
        if (toneLevel != numTones - 1) {
            for (int resolution = 0; resolution < numRes; ++resolution) {
                *images[toneLevel+1][resolution] = *images[toneLevel][resolution];
                candidates[resolution] = *images[toneLevel][resolution];
            }
        }
    }
}