Esempio n. 1
0
File: sequential.c Progetto: snpy/ar
// Calculate one step and max corrections
double calculation(const int iterate) {
	// Vt + Vr + Vb + Vl - 4Vx = 0
	int y, x;
	double maxStepSize, pde, stepSize;
	d("Calculation step (iterate: %d)", iterate);
	maxStepSize = 0;

	for (y = 1; y < segment_size_y - 1; ++y) {
		for (x = 1; x < segment_size_x - 1; ++x) {
			// We're using checkerboard to calculate values.
			if ((y + x + iterate) % 2 == 0
				|| is_outside(x, y)
				|| is_wire(x, y)
			) {
				continue;
			}

			pde = data[bottom_point(x, y)]
				+ data[top_point(x, y)]
				+ data[left_point(x, y)]
				+ data[right_point(x, y)];
			pde *= .25;

			stepSize = abs(pde - data[y * segment_size_x + x]);
			if (stepSize > maxStepSize) {
				maxStepSize = stepSize;
			}

			data[y * segment_size_x + x] = pde;
		}
	}

	return maxStepSize;
}
Esempio n. 2
0
void ComboBox::Paint(Canvas& canvas, const Rect& dirty_rect) {

    __super::Paint(canvas, dirty_rect);

    float button_width = GetDropDownButtonWidth();
    auto button_rect = GetContentRect();
    button_rect.position.x = button_rect.position.x + button_rect.size.width - button_width;
    button_rect.size.width = button_width;

    float top_edge_length = button_width / 2;
    if (top_edge_length / 2 > button_rect.size.height / 2) {
        top_edge_length = button_rect.size.height / 2;
    }

    float height = top_edge_length / 2;
    float half_height = height / 2;
    Point center_point(
        button_rect.position.x + button_rect.size.width / 2,
        button_rect.position.y + button_rect.size.height / 2);

    Point left_point(center_point.x - height, center_point.y - half_height);
    left_point = MakeClearEdgePointForFill(left_point, ClearEdgeOption::Clear);

    Point right_point(center_point.x + height, center_point.y - half_height);
    right_point = MakeClearEdgePointForFill(right_point, ClearEdgeOption::Clear);

    Point bottom_point(center_point.x, center_point.y + half_height);
    bottom_point = MakeClearEdgePointForFill(bottom_point, ClearEdgeOption::Clear);

    auto path = GetApplication().GetResourceFactory()->CreatePathGeometry();
    if (path == nullptr) {
        return;
    }

    auto sink = path->Open();
    if (sink == nullptr) {
        return;
    }

    sink->BeginFigure(left_point, GeometrySink::BeginFigureOption::Fill);
    sink->AddLine(right_point);
    sink->AddLine(bottom_point);
    sink->EndFigure(GeometrySink::EndFigureOption::Close);
    sink->Close();

    Canvas::StateGuard state_guard(canvas);
    canvas.SetBrushWithColor(GetDropDownButtonColor());
    canvas.DrawGeometry(path);
}