コード例 #1
0
QRectF ArrowAluCin::boundingRect() const
{
    return polygon().boundingRect();
}
コード例 #2
0
ファイル: GLDMaskBox.cpp プロジェクト: Iownnoname/qt
QPainterPath GLDMaskBox::buildPathRoundRectTip()
{
    // 建立圆角矩形tip路径
    QPainterPath path;

    do
    {
        QRect rc = this->rect();

        if (m_oTipBoxParam.m_sizeArrow.isValid())
        {
            rc -= QMargins(m_oTipBoxParam.m_sizeArrow.height(),
                           m_oTipBoxParam.m_sizeArrow.height(),
                           m_oTipBoxParam.m_sizeArrow.height(),
                           m_oTipBoxParam.m_sizeArrow.height());
        }
        else
        {
            break;
        }

        if (!m_oTipBoxParam.m_wgtOwner)
        {
            break;
        }

        // 添加圆角矩形
        path.addRoundedRect(rc, 20, 20);

        // 计算箭头(按照屏幕坐标进行计算)

        // 计算第一个交点(与外围)
        QPoint ptOwnerCenter = m_oTipBoxParam.m_wgtOwner->mapToGlobal(
                    m_oTipBoxParam.m_wgtOwner->rect().center());
        QPoint ptThisCenter = this->mapToGlobal(this->rect().center());

        QLineF lineCenters(ptOwnerCenter, ptThisCenter);
        QRectF rcRing(this->mapToGlobal(this->rect().topLeft()),
                      this->mapToGlobal(this->rect().bottomRight()));

        QPointF pt1(0, 0);
        QPointF pt2(0, 0);

        if (!calcCrossLine2Rect(lineCenters, rcRing, pt1, pt2))
        {
            break;
        }

        QPoint ptArrow1 = pt1.isNull() ? pt2.toPoint() : pt1.toPoint();

        // 计算剩下两个交点(与内围)
        double dR = 0;
        double dAngle = 0;

        calcRadiusAndAngleOfPt2d(ptThisCenter, dR, dAngle, ptArrow1);
        QPointF ptNew1 = calcPtOfAngle2d(dR, dR, dAngle + 10, ptArrow1).toPoint();
        QPointF ptNew2 = calcPtOfAngle2d(dR, dR, dAngle - 10, ptArrow1).toPoint();

        QLineF line1(ptOwnerCenter, ptNew1);
        QLineF line2(ptOwnerCenter, ptNew2);

        QRectF rcInsideRing(this->mapToGlobal(rc.topLeft()), this->mapToGlobal(rc.bottomRight()));

        if (!calcCrossLine2Rect(line1, rcInsideRing, pt1, pt2))
        {
            break;
        }

        QPoint ptArrow2 = pt1.isNull() ? pt2.toPoint() : pt1.toPoint();

        if (!calcCrossLine2Rect(line2, rcInsideRing, pt1, pt2))
        {
            break;
        }

        QPoint ptArrow3 = pt1.isNull() ? pt2.toPoint() : pt1.toPoint();

        QVector<QPoint> ptsArrow;
        ptsArrow << mapFromGlobal(ptArrow1)
                 << mapFromGlobal(ptArrow2)
                 << mapFromGlobal(ptArrow3)
                 << mapFromGlobal(ptArrow1);

        QPolygonF polygon(ptsArrow);
        QPainterPath pathArrow;
        pathArrow.addPolygon(polygon);

        path += pathArrow;

    } while(0);

    return path;
}
コード例 #3
0
void SvgElementVisitor::visit(clan::DomElement &e)
{
	if (e.get_namespace_uri() != Svg::svg_ns) return;

	// To do: do a more efficient search for the correct handler

	auto local_name = e.get_local_name();
	if (local_name == "a") a(e);
	else if (local_name == "altGlyph") altGlyph(e);
	else if (local_name == "altGlyphDef") altGlyphDef(e);
	else if (local_name == "altGlyphItem") altGlyphItem(e);
	else if (local_name == "animate") animate(e);
	else if (local_name == "animateColor") animateColor(e);
	else if (local_name == "animateMotion") animateMotion(e);
	else if (local_name == "animateTransform") animateTransform(e);
	else if (local_name == "circle") circle(e);
	else if (local_name == "clipPath") clipPath(e);
	else if (local_name == "color-profile") color_profile(e);
	else if (local_name == "cursor") cursor(e);
	else if (local_name == "defs") defs(e);
	else if (local_name == "desc") desc(e);
	else if (local_name == "ellipse") ellipse(e);
	else if (local_name == "feBlend") feBlend(e);
	else if (local_name == "feColorMatrix") feColorMatrix(e);
	else if (local_name == "feComponentTransfer") feComponentTransfer(e);
	else if (local_name == "feComposite") feComposite(e);
	else if (local_name == "feConvolveMatrix") feConvolveMatrix(e);
	else if (local_name == "feDiffuseLighting") feDiffuseLighting(e);
	else if (local_name == "feDisplacementMap") feDisplacementMap(e);
	else if (local_name == "feDistantLight") feDistantLight(e);
	else if (local_name == "feFlood") feFlood(e);
	else if (local_name == "feFuncA") feFuncA(e);
	else if (local_name == "feFuncB") feFuncB(e);
	else if (local_name == "feFuncG") feFuncG(e);
	else if (local_name == "feFuncR") feFuncR(e);
	else if (local_name == "feGaussianBlur") feGaussianBlur(e);
	else if (local_name == "feImage") feImage(e);
	else if (local_name == "feMerge") feMerge(e);
	else if (local_name == "feMergeNode") feMergeNode(e);
	else if (local_name == "feMorphology") feMorphology(e);
	else if (local_name == "feOffset") feOffset(e);
	else if (local_name == "fePointLight") fePointLight(e);
	else if (local_name == "feSpecularLighting") feSpecularLighting(e);
	else if (local_name == "feSpotLight") feSpotLight(e);
	else if (local_name == "feTile") feTile(e);
	else if (local_name == "feTurbulence") feTurbulence(e);
	else if (local_name == "filter") filter(e);
	else if (local_name == "font") font(e);
	else if (local_name == "font-face") font_face(e);
	else if (local_name == "font-face-format") font_face_format(e);
	else if (local_name == "font-face-name") font_face_name(e);
	else if (local_name == "font-face-src") font_face_src(e);
	else if (local_name == "font-face-uri") font_face_uri(e);
	else if (local_name == "foreignObject") foreignObject(e);
	else if (local_name == "g") g(e);
	else if (local_name == "glyph") glyph(e);
	else if (local_name == "glyphRef") glyphRef(e);
	else if (local_name == "hkern") hkern(e);
	else if (local_name == "image") image(e);
	else if (local_name == "line") line(e);
	else if (local_name == "linearGradient") linearGradient(e);
	else if (local_name == "marker") marker(e);
	else if (local_name == "mask") mask(e);
	else if (local_name == "metadata") metadata(e);
	else if (local_name == "missing-glyph") missing_glyph(e);
	else if (local_name == "mpath") mpath(e);
	else if (local_name == "path") path(e);
	else if (local_name == "pattern") pattern(e);
	else if (local_name == "polygon") polygon(e);
	else if (local_name == "polyline") polyline(e);
	else if (local_name == "radialGradient") radialGradient(e);
	else if (local_name == "rect") rect(e);
	else if (local_name == "script") script(e);
	else if (local_name == "set") set(e);
	else if (local_name == "stop") stop(e);
	else if (local_name == "style") style(e);
	else if (local_name == "svg") svg(e);
	else if (local_name == "switch") switch_(e);
	else if (local_name == "symbol") symbol(e);
	else if (local_name == "text") text(e);
	else if (local_name == "textPath") textPath(e);
	else if (local_name == "title") title(e);
	else if (local_name == "tref") tref(e);
	else if (local_name == "tspan") tspan(e);
	else if (local_name == "use") use(e);
	else if (local_name == "view") view(e);
	else if (local_name == "vkern") vkern(e);
}
コード例 #4
0
ファイル: generic.c プロジェクト: pcwalton/NetSurf
static bool
path(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_plot_pen_t *pen)
{
    int path_loop;
    nsfb_point_t *pts;
    nsfb_point_t *curpt;
    int ptc = 0;
    nsfb_bbox_t curve;
    nsfb_point_t ctrla;
    nsfb_point_t ctrlb;
    int added_count = 0;
    int bpts;

    /* count the verticies in the path and add N_SEG extra for curves */
    for (path_loop = 0; path_loop < pathc; path_loop++) {
        ptc++;
        if ((pathop[path_loop].operation == NFSB_PLOT_PATHOP_QUAD) ||
            (pathop[path_loop].operation == NFSB_PLOT_PATHOP_CUBIC))
            ptc += N_SEG;
    }

    /* allocate storage for the vertexes */
    curpt = pts = malloc(ptc * sizeof(nsfb_point_t));

    for (path_loop = 0; path_loop < pathc; path_loop++) {
        switch (pathop[path_loop].operation) {
        case NFSB_PLOT_PATHOP_QUAD:
            curpt-=2;
            added_count -= 2;
            curve.x0 = pathop[path_loop - 2].point.x;
            curve.y0 = pathop[path_loop - 2].point.y;
            ctrla.x = pathop[path_loop - 1].point.x;
            ctrla.y = pathop[path_loop - 1].point.y;
            curve.x1 = pathop[path_loop].point.x;
            curve.y1 = pathop[path_loop].point.y;
            bpts = quadratic_points(N_SEG, curpt, &curve, &ctrla);
            curpt += bpts;
            added_count += bpts;
            break;

        case NFSB_PLOT_PATHOP_CUBIC:
            curpt-=3;
            added_count -=3;
            curve.x0 = pathop[path_loop - 3].point.x;
            curve.y0 = pathop[path_loop - 3].point.y;
            ctrla.x = pathop[path_loop - 2].point.x;
            ctrla.y = pathop[path_loop - 2].point.y;
            ctrlb.x = pathop[path_loop - 1].point.x;
            ctrlb.y = pathop[path_loop - 1].point.y;
            curve.x1 = pathop[path_loop].point.x;
            curve.y1 = pathop[path_loop].point.y;
            bpts = cubic_points(N_SEG, curpt, &curve, &ctrla, &ctrlb);
            curpt += bpts;
            added_count += bpts;
            break;

        default:
            *curpt = pathop[path_loop].point;
            curpt++;
            added_count ++;
            break;
        }
    }

    if (pen->fill_type != NFSB_PLOT_OPTYPE_NONE) {
        polygon(nsfb, (int *)pts, added_count, pen->fill_colour);
    }

    if (pen->stroke_type != NFSB_PLOT_OPTYPE_NONE) {
        polylines(nsfb, added_count, pts, pen);
    }

    free(pts);

    return true;
}
コード例 #5
0
ファイル: polygon.cpp プロジェクト: Afreeca/qt
int main()
{
    {
        // STREAM
//! [0]
        QPolygon polygon;
        polygon << QPoint(10, 20) << QPoint(20, 30);
//! [0]
    }

    {
        // STREAMF
//! [1]
        QPolygonF polygon;
        polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
//! [1]
    }

    {
        // SETPOINTS
//! [2]
        static const int points[] = { 10, 20, 30, 40 };
        QPolygon polygon;
        polygon.setPoints(2, points);
//! [2]
    }

    {
        // SETPOINTS2
//! [3]
        QPolygon polygon;
        polygon.setPoints(2, 10, 20, 30, 40);
//! [3]
    }

    {
        // PUTPOINTS
//! [4]
        QPolygon polygon(1);
        polygon[0] = QPoint(4, 5);
        polygon.putPoints(1, 2, 6,7, 8,9);
//! [4]
    }

    {
        // PUTPOINTS2
//! [5]
        QPolygon polygon(3);
        polygon.putPoints(0, 3, 4,5, 0,0, 8,9);
        polygon.putPoints(1, 1, 6,7);
//! [5]
    }

    {
        // PUTPOINTS3
//! [6]
        QPolygon polygon1;
        polygon1.putPoints(0, 3, 1,2, 0,0, 5,6);
        // polygon1 is now the three-point polygon(1,2, 0,0, 5,6);

        QPolygon polygon2;
        polygon2.putPoints(0, 3, 4,4, 5,5, 6,6);
        // polygon2 is now (4,4, 5,5, 6,6);

        polygon1.putPoints(2, 3, polygon2);
        // polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6);
//! [6]
    }
    return 0;
}
コード例 #6
0
ファイル: qwt_plot_curve.cpp プロジェクト: 0vermind/NeoLoader
/*!
  Draw step function

  The direction of the steps depends on Inverted attribute.

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rectangle of the canvas
  \param from index of the first point to be painted
  \param to index of the last point to be painted

  \sa CurveAttribute, setCurveAttribute(),
      draw(), drawCurve(), drawDots(), drawLines(), drawSticks()
*/
void QwtPlotCurve::drawSteps( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int from, int to ) const
{
    const bool doAlign = QwtPainter::roundingAlignment( painter );

    QPolygonF polygon( 2 * ( to - from ) + 1 );
    QPointF *points = polygon.data();

    bool inverted = orientation() == Qt::Vertical;
    if ( d_data->attributes & Inverted )
        inverted = !inverted;

    const QwtSeriesData<QPointF> *series = data();

    int i, ip;
    for ( i = from, ip = 0; i <= to; i++, ip += 2 )
    {
        const QPointF sample = series->sample( i );
        double xi = xMap.transform( sample.x() );
        double yi = yMap.transform( sample.y() );
        if ( doAlign )
        {
            xi = qRound( xi );
            yi = qRound( yi );
        }

        if ( ip > 0 )
        {
            const QPointF &p0 = points[ip - 2];
            QPointF &p = points[ip - 1];

            if ( inverted )
            {
                p.rx() = p0.x();
                p.ry() = yi;
            }
            else
            {
                p.rx() = xi;
                p.ry() = p0.y();
            }
        }

        points[ip].rx() = xi;
        points[ip].ry() = yi;
    }

    if ( d_data->paintAttributes & ClipPolygons )
    {
        const QPolygonF clipped = QwtClipper::clipPolygonF( 
            canvasRect, polygon, false );

        QwtPainter::drawPolyline( painter, clipped );
    }
    else
    {
        QwtPainter::drawPolyline( painter, polygon );
    }

    if ( d_data->brush.style() != Qt::NoBrush )
        fillCurve( painter, xMap, yMap, canvasRect, polygon );
}
コード例 #7
0
int main(int argc, char* argv[])
{
	if (argc < 5)
	{
		std::cout << "program " << argv[0] << " takes a *layered* mesh file and closed polylines from a geometry and "
		                                      "computes the surface mesh nodes within the closed polyline"
		          << std::endl;
		std::cout << "Usage: " << std::endl
		          << argv[0] << "\n\t--mesh ogs_meshfile\n\t--geometry ogs_geometry_as_gli_file" << std::endl;
		return -1;
	}

	// *** read mesh
	std::string tmp(argv[1]);
	if (tmp.find("--mesh") == std::string::npos)
	{
		std::cout << "could not extract mesh file name" << std::endl;
		return -1;
	}

	tmp = argv[2];
	std::string file_base_name(tmp);
	if (tmp.find(".msh") != std::string::npos)
		file_base_name = tmp.substr(0, tmp.size() - 4);

	std::vector<MeshLib::CFEMesh*> mesh_vec;
	FEMRead(file_base_name, mesh_vec);
	if (mesh_vec.empty())
	{
		std::cerr << "could not read mesh from file " << std::endl;
		return -1;
	}
	MeshLib::CFEMesh* mesh(mesh_vec[mesh_vec.size() - 1]);
	mesh->ConstructGrid();

	// extract path
	std::string path;
	BaseLib::extractPath(argv[2], path);

	// *** read geometry
	tmp = argv[3];
	if (tmp.find("--geometry") == std::string::npos)
	{
		std::cout << "could not extract geometry file name" << std::endl;
		return -1;
	}

	GEOLIB::GEOObjects* geo(new GEOLIB::GEOObjects);
	tmp = argv[4];
	std::string unique_name;
	std::vector<std::string> error_strings;
	FileIO::readGLIFileV4(tmp, geo, unique_name, error_strings);

	//	{
	//		const std::vector<GEOLIB::Point*>* pnts (geo->getPointVec (tmp));
	//		if (pnts) {
	//			std::string fname ("MeshIDs.txt");
	//			std::ofstream out (fname.c_str());
	//
	//			std::string fname_gli ("MeshNodesAsPnts.gli");
	//			std::ofstream pnt_out (fname_gli.c_str());
	//			pnt_out << "#POINTS" << std::endl;
	//
	//			MeshLib::ExtractMeshNodes extract_mesh_nodes (mesh);
	//
	//			const size_t n_pnts (pnts->size());
	//			for (size_t k(0); k<n_pnts; k++) {
	//				extract_mesh_nodes.writeNearestMeshNodeToPoint (out, pnt_out, *((*pnts)[k]));
	//			}
	//			pnt_out << "#STOP" << std::endl;
	//		}
	//		return 0;
	//	}

	// *** get Polygon
	const std::vector<GEOLIB::Polyline*>* plys(geo->getPolylineVec(unique_name));
	if (!plys)
	{
		std::cout << "could not get vector of polylines" << std::endl;
		delete mesh;
		delete geo;
		return -1;
	}

	std::vector<size_t> mesh_ids;
	//	size_t ply_id (0);
	//	size_t layer(1);
	//	getMeshNodesFromLayerAlongPolyline(mesh, geo, unique_name, ply_id, layer, mesh_ids);
	//	writeMeshNodes(mesh, mesh_ids, "MeshIDs.txt", "MeshNodesAsPoints.gli", true);

	//*** extract surface out of mesh
	MeshLib::ExtractMeshNodes extract_mesh_nodes(mesh);

	//	// *** generate a polygon from polyline
	////	std::vector<GEOLIB::Polyline*> polylines;
	//	const size_t n_plys (plys->size());
	//	for (size_t k(0); k < n_plys; k++)
	//	{
	//		bool closed ((*plys)[k]->isClosed());
	//		if (!closed)
	//		{
	//			std::cout << "converting polyline " << k << " to closed polyline" << std::endl;
	//			GEOLIB::Polygon* polygon(NULL);
	//			extract_mesh_nodes.getPolygonFromPolyline(*((*plys)[k]), geo, unique_name, polygon);
	////			polylines.push_back (polygon);
	////			geo->appendPolylineVec (polylines, unique_name);
	//			std::string *polygon_name(new std::string);
	//			geo->getPolylineVecObj(unique_name)->getNameOfElementByID(k, *polygon_name);
	//			(*polygon_name) += "-Polygon";
	//			geo->getPolylineVecObj(unique_name)->push_back(polygon, polygon_name);
	////			polylines.clear();
	//		}
	//	}
	//
	//	FileIO::writeGLIFileV4 ("New.gli", unique_name, *geo);

	// *** search mesh nodes for direct assigning bc, st or ic
	const size_t n_plys(plys->size());
	for (size_t k(0); k < n_plys; k++)
	{
		bool closed((*plys)[k]->isClosed());
		if (!closed)
		{
			std::cout << "polyline " << k << " is not closed" << std::endl;
		}
		else
		{
			std::string fname(path + "MeshIDs.txt");
			std::ofstream out(fname.c_str());
			std::string fname_gli(path + "MeshNodesAsPnts.gli");
			std::ofstream pnt_out(fname_gli.c_str());
			pnt_out << "#POINTS" << std::endl;
			GEOLIB::Polygon polygon(*((*plys)[k]));
			//			extract_mesh_nodes.writeMesh2DNodeIDAndArea (out, pnt_out, polygon);
			extract_mesh_nodes.writeTopSurfaceMeshNodeIDs(out, pnt_out, polygon);
			// write all nodes - not only the surface nodes
			//			extract_mesh_nodes.writeMeshNodeIDs (out, pnt_out, polygon);
			pnt_out << "#STOP" << std::endl;
			out.close();
			pnt_out.close();
		}
	}

	// *** for Model Pipiripau
	//	std::vector<GEOLIB::Polygon*> holes;
	//	size_t bounding_polygon_id(0);
	//	while (bounding_polygon_id < n_plys && ! (*plys)[bounding_polygon_id]->isClosed()) {
	//		bounding_polygon_id++;
	//	}
	//
	//	for (size_t k(bounding_polygon_id+1); k<n_plys; k++) {
	//		bool closed ((*plys)[k]->isClosed());
	//		if (!closed) {
	//			std::cout << "polyline " << k << " is not closed" << std::endl;
	//		} else {
	//			holes.push_back (new GEOLIB::Polygon(*(((*plys)[k]))));
	//		}
	//	}
	//	extract_mesh_nodes.writeMesh2DNodeIDAndArea (out, pnt_out, GEOLIB::Polygon((*((*plys)[bounding_polygon_id]))),
	// holes);
	//	for (size_t k(0); k<holes.size(); k++) {
	//		delete holes[k];
	//	}

	//	out << "#STOP" << std::endl;
	//	out.close();
	//
	//	pnt_out << "#STOP" << std::endl;
	//	pnt_out.close ();

	delete mesh;
	delete geo;

	return 0;
}
コード例 #8
0
ファイル: Maze1.cpp プロジェクト: HelstVadsom/amazing-maze
void walls_init()
{
  glNewList( cu32NorthWallID, GL_COMPILE );
  polygon(north_vertices,0,1,2,3);
  polygon(north_vertices,1,5,6,2);
  polygon(north_vertices,4,5,6,7);
  polygon(north_vertices,0,4,7,3);
  polygon(north_vertices,0,1,5,4);
  polygon(north_vertices,3,2,6,7);

  glEndList();

  glNewList( cu32EastWallID, GL_COMPILE );

  polygon(east_vertices,0,1,2,3);
  polygon(east_vertices,1,5,6,2);
  polygon(east_vertices,4,5,6,7);
  polygon(east_vertices,0,4,7,3);
  polygon(east_vertices,0,1,5,4);
  polygon(east_vertices,3,2,6,7);

  glEndList();

}
コード例 #9
0
ファイル: partition.cpp プロジェクト: mvdan/geoc-viewer
void ConvexpartitionIpelet::protected_run(int fn)
{
  
  if (fn==4) {
    show_help();
    return;
  }

  std::list<Polygon_2> pol_list;
  Iso_rectangle_2 bbox=
    read_active_objects( CGAL::dispatch_or_drop_output<Polygon_2>( std::back_inserter(pol_list) ) );

  
  
  if (pol_list.size ()==0){
    print_error_message("No polygon selected");
    return;
  }
  
  for (std::list<Polygon_2>::iterator itp=pol_list.begin();itp!=pol_list.end();++itp){
    //~ Polygon_2 polygon=*itp;
    //~ std::list<Polygon_2> partition_polys;
    CGAL::Polygon_2<Kernel,std::list<Kernel::Point_2> > polygon(itp->vertices_begin(),itp->vertices_end());
    std::list<CGAL::Polygon_2<Kernel,std::list<Kernel::Point_2> > > partition_polys;
    
    if (!polygon.is_simple()){
      print_error_message("Polygon must be simple");
      continue;   
    }
    
    if (polygon.orientation()!=CGAL::COUNTERCLOCKWISE)
      polygon.reverse_orientation();
    
    switch(fn){
    case 0:
    CGAL::y_monotone_partition_2(polygon.vertices_begin(), 
                                  polygon.vertices_end(),
                                  std::back_inserter(partition_polys));
    break;
    
    case 1:
    CGAL::greene_approx_convex_partition_2(polygon.vertices_begin(), 
                                  polygon.vertices_end(),
                                  std::back_inserter(partition_polys));
    break;

    case 2:
    CGAL::approx_convex_partition_2(polygon.vertices_begin(), 
                                  polygon.vertices_end(),
                                  std::back_inserter(partition_polys));
    break;
    
    case 3:
    CGAL::optimal_convex_partition_2(polygon.vertices_begin(), 
                                  polygon.vertices_end(),
                                  std::back_inserter(partition_polys));
    break;
    }
    
    draw_in_ipe(partition_polys.begin(),partition_polys.end());
  }
}
コード例 #10
0
int trichro_back_buffer(int xchroma, int ychroma, int rayon, int largeurchroma)//calcul et couleurs dans les 10eme de sec.
{
clear_bitmap(bmp_buffer_trichro);
int coord[4];
for (hcl=0.0; hcl<360.0; hcl+=0.4)
{
     xcl = cos(hcl*PI/180.0)*(rayon+16);
	 ycl = sin(hcl*PI/180.0)*(rayon+16);

	 hsv_to_rgb(hcl, 1.0, 1.0, &rcl, &gcl, &bcl);

	 coord[0]=xchroma;
     coord[1]=ychroma;
     coord[2]=(int)(xchroma+xcl);
     coord[3]=(int)(ychroma+ycl);
//	 ol::Line(ol::Vec2D(xchroma,ychroma),ol::Vec2D(xchroma+xcl,ychroma+ycl)).Draw(Rgba(rcl,gcl,bcl));
 polygon(bmp_buffer_trichro, 2, coord, makecol(rcl,gcl,bcl));
}

//ol::Circle MasqueNoir(ol::Vec2D(xchroma,ychroma),rayon-16);
//MasqueNoir.Draw(CouleurFond);
circlefill(bmp_buffer_trichro,  xchroma,ychroma, rayon-16, makecol(0,0,0));

for(angle = 0 ; angle <(PI*360) / 180  ; angle+=0.1)//radians
{
   vx = cos(angle)*rayon;
   vy = sin(angle)*rayon;
   if(mouse_x>xtrichro_window+vx-16  && mouse_x< xtrichro_window+vx+16 && mouse_y>ytrichro_window+vy-16 && mouse_y<ytrichro_window+vy+16
      && mouse_button==1 && window_focus_id==902)

   {
   angle_snap=angle;//angle rotation roue couleur
   position_curseur_hue_x= xtrichro_window+vx;//affichage
   position_curseur_hue_y=ytrichro_window+vy ;//affichage
   cref=getpixel(bmp_buffer_trichro,(int)(xchroma+vx),(int)(ychroma+vy));
    r_pick=getr(cref);
    v_pick=getg(cref);
    b_pick=getb(cref);
   stock_etat_picker_dans_dockcolor(dock_color_selected);
    //angle=((PI*360) / (180*127))*midi_levels[497];
    midi_levels[497]=(int)(angle_snap/((PI*360) / (180*127)));
    if(midi_send_out[497]==1){index_send_midi_out[497]=1;}
    mouse_released=1;
   }

}


//attaque midi
if (miditable[0][497]==istyp && miditable[1][497]==ischan && miditable[2][497]==ispitch)
{
  angle_snap=((PI*360) / (180*127))*midi_levels[497];
  vx = cos(angle_snap)*125;
  vy = sin(angle_snap)*125;
  position_curseur_hue_x= xtrichro_window+vx;
  position_curseur_hue_y=ytrichro_window+vy ;
  cref=getpixel(bmp_buffer_trichro,(int)(xchroma+vx),(int)(ychroma+vy));
  r_pick=getr(cref);
  v_pick=getg(cref);
  b_pick=getb(cref);
  stock_etat_picker_dans_dockcolor(dock_color_selected);
}
//triangle
	V3D_f v1 =
	{
		xchroma+vxd, ychroma+vyd, 0,
		0., 0.,
		makecol(0, 0, 0) // black vertex
	};
	V3D_f v2 =
	{
		xchroma+vxw, ychroma+vyw, 0,
		0., 0.,
		makecol(255, 255, 255) // white vertex
	};
	V3D_f v3 =
	{
		xchroma+vxh, ychroma+vyh, 0,
		0., 0.,
		makecol(r_pick, v_pick, b_pick) // color vertex
	};


	triangle3d_f(bmp_buffer_trichro, POLYTYPE_GCOL, NULL, &v1, &v2, &v3);


//definir si on est dans l aire du triangle
//(angle (Pa-1 Pa-2) * angle (Pa-2 Pa-3) * angle (Pa-3 Pa-1)) resultat pos ou neg
float angle1, angle2,angle3;
angle1=CounterClockWise(mouse_x,mouse_y,xtrichro_window+vxd, ytrichro_window+vyd,xtrichro_window+vxh, ytrichro_window+vyh) ; //Pa1-Pa2
angle2=CounterClockWise(mouse_x,mouse_y,xtrichro_window+vxh, ytrichro_window+vyh,xtrichro_window+vxw, ytrichro_window+vyw);//Pa2 - Pa3
angle3=CounterClockWise(mouse_x,mouse_y,xtrichro_window+vxw, ytrichro_window+vyw, xtrichro_window+vxd, ytrichro_window+vyd);//Pa3-Pa1

if((angle1*angle2*angle3) <=0 ) //dans le triangle formé par la souris et les 3 points du triangle
{


if(mouse_b&1 && mouse_x>xtrichro_window+vxd && mouse_x<xtrichro_window+vxw && mouse_y>ytrichro_window+vyd && mouse_y<ytrichro_window+vyh && window_focus_id==902)
{
picker_x=mouse_x-xtrichro_window;
picker_y=mouse_y-ytrichro_window;
stock_etat_picker_dans_dockcolor(dock_color_selected);
}

}


if(getpixel(bmp_buffer_trichro,(int)(xchroma+picker_x),(int)(ychroma+picker_y))!=0)
{colorpicker=getpixel(bmp_buffer_trichro,(int)(xchroma+picker_x),(int)(ychroma+picker_y));}

my_red=getr(colorpicker);
my_green=getg(colorpicker);
my_blue=getb(colorpicker);

if (index_quadri==1)
{
   float hue, saturation, value;
   rgb_to_hsv(my_red, my_green, my_blue, &hue, &saturation, &value);
   //saturation: plus il y en a , moins de jaune il y a
   my_yellow=(int)(255-(255*saturation));
}
return(0);
}
コード例 #11
0
ファイル: fill.c プロジェクト: 99years/plan9
void fill(int num[], double *ff[]){
	polygon(num, ff, Odd, e1->foregr);
}