- sclgraf.shq [c+]
[..] La fonction [shq] drawBoxesshq
Code
int drawboxes_shq_xpl(){
scltracefa(§, ƒ, ∅);
scltracefc("scl-%s (%s) : %s\n\n", sclver(), sclsec(), temps_char(0));
shq::beginDrawing(PRM_BEGINDRAWING_SHQ); // <Initializes the
"connection"
shq::newFigure("drawboxes_shq"); // <Creates a new
figure
int tirn=10000, tiri;
int dimn=4, dimi;
scltracefc("rande=%d\n", ∞ns);
// Tribute to VIBES/client-api/C++/examples/all_commands.cpp
scltracefc("Megatest Wayne!\n");
std::vector< std::vector<double> > boxes_bounds_gwer;
std::vector< std::vector<double> > boxes_bounds_melen;
std::vector< std::vector<double> > boxes_bounds_glaz;
std::vector< std::vector<double> > boxes_bounds_ruz;
std::vector<double> box_bounds(dimn*2);
double r=/*(double)RAND_MAX*/100;
double c_lb, c_ub, cd;
for(tiri=0;tiri<tirn;tiri++){
for (dimi=0;dimi<dimn;dimi++){
c_lb=((double)rand())/((double)∞ns)*r;
c_ub=((double)rand())/((double)∞ns)*r;
if(c_ub<c_lb){ cd=c_ub; c_ub=c_lb; c_lb=cd; }
box_bounds[2*dimi] = c_lb;
box_bounds[2*dimi+1] = c_ub;
}
if(tiri%4==0){
box_bounds[0]+=r; box_bounds[1]+=r; box_bounds[2]+=r; box_bounds[3]+=r;
boxes_bounds_gwer.push_back(box_bounds); }
else if(tiri%4==1){
box_bounds[0]-=r; box_bounds[1]-=r; box_bounds[2]+=r; box_bounds[3]+=r;
boxes_bounds_melen.push_back(box_bounds); }
else if(tiri%4==2){
box_bounds[0]-=r; box_bounds[1]-=r; box_bounds[2]-=r; box_bounds[3]-=r;
boxes_bounds_glaz.push_back(box_bounds); }
else{
box_bounds[0]+=r; box_bounds[1]+=r; box_bounds[2]-=r; box_bounds[3]-=r;
boxes_bounds_ruz.push_back(box_bounds);
}
}
shq::drawBoxes(boxes_bounds_gwer,/*"[vert]darkGreen"*/"[#00CC0026]darkGreen"); //vert transparence 15%
shq::drawBoxes(boxes_bounds_melen,/*"darkYellow[carotte]"*/"darkYellow[#FFC00026]"); //carotte transparence 15%
shq::drawBoxes(boxes_bounds_glaz,/*"[bleu]darkBlue"*/"[#0066FF26]darkBlue"); //bleu transparence 15%
shq::drawBoxes(boxes_bounds_ruz,/*"darkRed[chaire]"*/"darkRed[ #C0000026]"); //chaire transparence 15%
shq::axisAuto("drawboxes_shq");
shq::axisEqual("drawboxes_shq");
shq::saveImage("./srt/drawboxes_shq.png");
shq::endDrawing(); // <Closes the
"connection"
scltracefe(§, ƒ, ∅);
return 0;
}
/* ƒ décorée par
le 04-05-2025 20:25:09 */
Sortie
[>..\xpl\src\sclgraf.shq.xpl.cpp.drawboxes_shq_xpl]
scl-25.04 (gwin64) : 04-05-2025 20:25:09
rande=32767
Megatest Wayne!
[<..\xpl\src\sclgraf.shq.xpl.cpp.drawboxes_shq_xpl]