Example of primitives in a canvas.
One of the first actions in a ROOT session is the creation of a Canvas. Here we create a Canvas named "c1".
After having executed this macro, try now to point on any object on the screen: pad, text, lines, etc.
When the cursor points to sensitive areas in an object, the cursor shape changes and suggests the type of action that can be applied.
For example:
- One can move, grow,shrink a pad.
- A text can be moved.
- A line can be moved or its end points can be modified.
- One can move, grow and shrink PaveLabels and PavesText.
Point to an object and click the right mouse button to change attributes. Try to change the canvas size.
In the canvas "File" menu, select the option "Print" to produce a PostScript file with a copy of the canvas.
void canvas(){
TPad *pad1 =
new TPad(
"pad1",
"This is pad1",0.05,0.52,0.95,0.97);
TPad *pad2 =
new TPad(
"pad2",
"This is pad2",0.05,0.02,0.95,0.47);
TPad *pad21 =
new TPad(
"pad21",
"First subpad of pad2",0.02,0.05,0.48,0.95,17,3);
TPad *pad22 =
new TPad(
"pad22",
"Second subpad of pad2",0.52,0.05,0.98,0.95,17,3);
float xt1 = 0.5;
float yt1 = 0.1;
float xp2 = 0.5;
float yp2 = 0.4;
paves->
AddText(
"This is a PavesText");
paves->
AddText(
"You can add new lines");
paves->
AddText(
"Text formatting is automatic");
float xlc = 0.01;
float ylc = 0.01;
float dxp2 = (0.9-xp2)/nloops;
float dyp2 = (0.7-yp2)/nloops;
float dxlc = (0.1-xlc)/nloops;
float dylc = (0.4-xlc)/nloops;
float dxt1 = (0.5-xt1)/nloops;
float dyt1 = (0.8-yt1)/nloops;
float t1end = 0.3;
float t1ds = (t1end - t10)/nloops;
for (int i=0;i<nloops;i++) {
color++;
color %= 8;
}
}
- Author
- Rene Brun
Definition in file canvas.C.