123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869 |
- /* Graphics_utils.cpp
- *
- * Copyright (C) 1992-2011,2015 Paul Boersma
- *
- * This code is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This code is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this work. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <math.h>
- #include "GraphicsP.h"
- /***** UTILITIES: *****/
- /***** THESE ROUINTES OUTPUT TO CURRENT GRAPHICS BY CALLING PRIMITIVES. *****/
- /***** THE TWO UTILITIES "Graphics_grey" AND "Graphics_altitude" *****/
- /***** ARE IN DIFFERENT FILES BECAUSE THEY NEED LOCAL SUBROUTINES. *****/
- /********** Utility functions. **********/
- /********** Drawing into margins. **********/
- void Graphics_drawInnerBox (Graphics me) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- Graphics_setInner (me);
- Graphics_setWindow (me, 0.0, 1.0, 0.0, 1.0);
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_rectangle (me, 0.0, 1.0, 0.0, 1.0);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setLineWidth (me, lineWidth);
- Graphics_setColour (me, colour);
- }
- void Graphics_textLeft (Graphics me, bool farr, conststring32 text) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int vert = farr ? Graphics_TOP : Graphics_BOTTOM;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, 0.0, 1.0);
- Graphics_setTextRotation (me, 90.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, vert);
- if (! farr) Graphics_setInner (me);
- Graphics_text (me, 0.0, 0.5, text);
- if (! farr) Graphics_unsetInner (me);
- Graphics_setTextRotation (me, 0.0);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setColour (me, colour);
- }
- void Graphics_textRight (Graphics me, bool farr, conststring32 text) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int vert = farr ? Graphics_TOP : Graphics_BOTTOM;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setTextAlignment (me, Graphics_CENTRE, vert);
- Graphics_setWindow (me, 0.0, 1.0, 0.0, 1.0);
- Graphics_setTextRotation (me, 270.0);
- if (! farr) Graphics_setInner (me);
- Graphics_text (me, 1.0, 0.5, text);
- if (! farr) Graphics_unsetInner (me);
- Graphics_setTextRotation (me, 0.0);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setColour (me, colour);
- }
- void Graphics_textBottom (Graphics me, bool farr, conststring32 text) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, 0.0, 1.0);
- if (farr) {
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_text (me, 0.5, 0.0, text);
- } else {
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- Graphics_text (me, 0.5, - my vertTick, text);
- Graphics_unsetInner (me);
- }
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setColour (me, colour);
- }
- void Graphics_textTop (Graphics me, bool farr, conststring32 text) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, 0.0, 1.0);
- if (farr) {
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_text (me, 0.5, 1.0, text);
- } else {
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- Graphics_text (me, 0.5, 1.0 + my vertTick, text);
- Graphics_unsetInner (me);
- }
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksLeft (Graphics me, int numberOfMarks, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarks < 2) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_RIGHT, Graphics_HALF);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (int i = 1; i <= numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), yWC = y1WC + (y2WC - y1WC) * f;
- if (haveNumbers) Graphics_text (me, - my horTick, yWC, Melder_float (Melder_half (yWC)));
- if (haveTicks) Graphics_line (me, - my horTick, yWC, 0, yWC);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines && numberOfMarks > 2) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (int i = 2; i < numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), yWC = y1WC + (y2WC - y1WC) * f;
- Graphics_line (me, 0.0, yWC, 1.0, yWC);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksRight (Graphics me, int numberOfMarks, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarks < 2) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_LEFT, Graphics_HALF);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (int i = 1; i <= numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), yWC = y1WC + (y2WC - y1WC) * f;
- if (haveNumbers) Graphics_text (me, 1.0 + my horTick, yWC, Melder_float (Melder_half (yWC)));
- if (haveTicks) Graphics_line (me, 1.0, yWC, 1.0 + my horTick, yWC);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines && numberOfMarks > 2) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (int i = 2; i < numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), yWC = y1WC + (y2WC - y1WC) * f;
- Graphics_line (me, 0.0, yWC, 1.0, yWC);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksBottom (Graphics me, int numberOfMarks, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarks < 2) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (int i = 1; i <= numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), xWC = x1WC + (x2WC - x1WC) * f;
- if (haveNumbers) Graphics_text (me, xWC, - my vertTick, Melder_float (Melder_half (xWC)));
- if (haveTicks) Graphics_line (me, xWC, - my vertTick, xWC, 0);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines && numberOfMarks > 2) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (int i = 2; i < numberOfMarks; i ++)
- {
- double f = (i - 1.0) / (numberOfMarks - 1), xWC = x1WC + (x2WC - x1WC) * f;
- Graphics_line (me, xWC, 0.0, xWC, 1.0);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksTop (Graphics me, int numberOfMarks, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarks < 2) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (int i = 1; i <= numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), xWC = x1WC + (x2WC - x1WC) * f;
- if (haveNumbers) Graphics_text (me, xWC, 1.0 + my vertTick, Melder_float (Melder_half (xWC)));
- if (haveTicks) Graphics_line (me, xWC, 1.0, xWC, 1.0 + my vertTick);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines && numberOfMarks > 2) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (int i = 2; i < numberOfMarks; i ++) {
- double f = (i - 1.0) / (numberOfMarks - 1), xWC = x1WC + (x2WC - x1WC) * f;
- Graphics_line (me, xWC, 0.0, xWC, 1.0);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- #define MAXNUM_MARKS_PER_DECADE 7
- static double decade_y [1 + MAXNUM_MARKS_PER_DECADE] [1 + MAXNUM_MARKS_PER_DECADE] = {
- { 0 },
- { 0, 10 },
- { 0, 10, 30 },
- { 0, 10, 20, 50 },
- { 0, 10, 20, 30, 50 },
- { 0, 10, 20, 30, 50, 70 },
- { 0, 10, 15, 20, 30, 50, 70 },
- { 0, 10, 15, 20, 30, 40, 50, 70 }
- };
- void Graphics_marksLeftLogarithmic (Graphics me, int numberOfMarksPerDecade, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1 = my d_x1WC, x2 = my d_x2WC, y1 = my d_y1WC, y2 = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarksPerDecade < 1) numberOfMarksPerDecade = 1;
- if (numberOfMarksPerDecade > MAXNUM_MARKS_PER_DECADE) numberOfMarksPerDecade = MAXNUM_MARKS_PER_DECADE;
- if (y1 > 300 || y2 > 300) return;
- double py1 = pow (10, y1 + ( y1 < y2 ? -1e-6 : 1e-6 ));
- double py2 = pow (10, y2 + ( y1 < y2 ? 1e-6 : -1e-6 ));
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1, y2);
- Graphics_setTextAlignment (me, Graphics_RIGHT, Graphics_HALF);
- Graphics_setInner (me);
- for (int i = 1; i <= numberOfMarksPerDecade; i ++) {
- double y = decade_y [numberOfMarksPerDecade] [i];
- while (y < (y1<y2?py1:py2)) y *= 10.0;
- while (y >= (y1<y2?py1:py2)) y /= 10.0;
- for (y *= 10.0; y <= (y1<y2?py2:py1); y *= 10.0) {
- if (haveNumbers) Graphics_text (me, - my horTick, log10 (y), Melder_float (Melder_half (y)));
- if (haveTicks) {
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_line (me, - my horTick, log10 (y), 0, log10 (y));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, log10 (y), 1.0, log10 (y));
- Graphics_setLineType (me, lineType);
- Graphics_setLineWidth (me, lineWidth);
- }
- }
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1, x2, y1, y2);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksRightLogarithmic (Graphics me, int numberOfMarksPerDecade, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1 = my d_x1WC, x2 = my d_x2WC, y1 = my d_y1WC, y2 = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarksPerDecade < 1) numberOfMarksPerDecade = 1;
- if (numberOfMarksPerDecade > MAXNUM_MARKS_PER_DECADE) numberOfMarksPerDecade = MAXNUM_MARKS_PER_DECADE;
- if (y1 > 300.0 || y2 > 300.0) return;
- double py1 = pow (10.0, y1 + ( y1 < y2 ? -1e-6 : 1e-6 ));
- double py2 = pow (10.0, y2 + ( y1 < y2 ? 1e-6 : -1e-6 ));
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, y1, y2);
- Graphics_setTextAlignment (me, Graphics_LEFT, Graphics_HALF);
- Graphics_setInner (me);
- for (int i = 1; i <= numberOfMarksPerDecade; i ++) {
- double y = decade_y [numberOfMarksPerDecade] [i];
- while (y < (y1<y2?py1:py2)) y *= 10.0;
- while (y >= (y1<y2?py1:py2)) y /= 10.0;
- for (y *= 10.0; y <= (y1<y2?py2:py1); y *= 10.0) {
- if (haveNumbers) Graphics_text (me, 1.0 + my horTick, log10 (y), Melder_float (Melder_half (y)));
- if (haveTicks) {
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_line (me, 1.0, log10 (y), 1.0 + my horTick, log10 (y));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, log10 (y), 1.0, log10 (y));
- Graphics_setLineType (me, lineType);
- Graphics_setLineWidth (me, lineWidth);
- }
- }
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1, x2, y1, y2);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksTopLogarithmic (Graphics me, int numberOfMarksPerDecade, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1 = my d_x1WC, x2 = my d_x2WC, y1 = my d_y1WC, y2 = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarksPerDecade < 1) numberOfMarksPerDecade = 1;
- if (numberOfMarksPerDecade > MAXNUM_MARKS_PER_DECADE) numberOfMarksPerDecade = MAXNUM_MARKS_PER_DECADE;
- if (x1 > 300.0 || x2 > 300.0) return;
- double px1 = pow (10.0, x1 + ( x1 < x2 ? -1e-6 : 1e-6 ));
- double px2 = pow (10.0, x2 + ( x1 < x2 ? 1e-6 : -1e-6 ));
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1, x2, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- for (int i = 1; i <= numberOfMarksPerDecade; i ++) {
- double x = decade_y [numberOfMarksPerDecade] [i];
- while (x < (x1<x2?px1:px2)) x *= 10.0;
- while (x >= (x1<x2?px1:px2)) x /= 10.0;
- for (x *= 10.0; x <= (x1<x2?px2:px1); x *= 10.0) {
- if (haveNumbers) Graphics_text (me, log10 (x), 1.0 + my vertTick, Melder_float (Melder_half (x)));
- if (haveTicks) {
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_line (me, log10 (x), 1.0, log10 (x), 1.0 + my vertTick);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, log10 (x), 0.0, log10 (x), 1.0);
- Graphics_setLineType (me, lineType);
- Graphics_setLineWidth (me, lineWidth);
- }
- }
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1, x2, y1, y2);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksBottomLogarithmic (Graphics me, int numberOfMarksPerDecade, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1 = my d_x1WC, x2 = my d_x2WC, y1 = my d_y1WC, y2 = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (numberOfMarksPerDecade < 1) numberOfMarksPerDecade = 1;
- if (numberOfMarksPerDecade > MAXNUM_MARKS_PER_DECADE) numberOfMarksPerDecade = MAXNUM_MARKS_PER_DECADE;
- if (x1 > 300.0 || x2 > 300.0) return;
- double px1 = pow (10.0, x1 + ( x1 < x2 ? -1e-6 : 1e-6 ));
- double px2 = pow (10.0, x2 + ( x1 < x2 ? 1e-6 : -1e-6 ));
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1, x2, 0, 1);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- for (int i = 1; i <= numberOfMarksPerDecade; i ++) {
- double x = decade_y [numberOfMarksPerDecade] [i];
- while (x < (x1<x2?px1:px2)) x *= 10.0;
- while (x >= (x1<x2?px1:px2)) x /= 10.0;
- for (x *= 10.0; x <= (x1<x2?px2:px1); x *= 10.0) {
- if (haveNumbers) Graphics_text (me, log10 (x), - my vertTick, Melder_float (Melder_half (x)));
- if (haveTicks) {
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_line (me, log10 (x), - my vertTick, log10 (x), 0.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, log10 (x), 0.0, log10 (x), 1.0);
- Graphics_setLineType (me, lineType);
- Graphics_setLineWidth (me, lineWidth);
- }
- }
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1, x2, y1, y2);
- Graphics_setColour (me, colour);
- }
- void Graphics_markLeft (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_RIGHT, Graphics_HALF);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, - my horTick, position, Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, - my horTick, position, 0.0, position);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, position, 1.0, position);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, - my horTick, position, text); // 'text' has to stay valid until here; no Graphics is allowed to use the cat buffer!
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markRight (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_LEFT, Graphics_HALF);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, 1.0 + my horTick, position, Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, 1.0, position, 1.0 + my horTick, position);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, position, 1.0, position);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, 1.0 + my horTick, position, text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markTop (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, position, 1.0 + my vertTick, Melder_float (Melder_single (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, position, 1.0, position, 1.0 + my vertTick);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, position, 0.0, position, 1.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, position, 1.0 + my vertTick, text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markBottom (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, position, - my vertTick, Melder_float (Melder_single (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, position, - my vertTick, position, 0.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, position, 0.0, position, 1.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, position, - my vertTick, text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markLeftLogarithmic (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (position <= 0.0) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_RIGHT, Graphics_HALF);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, - my horTick, log10 (position), Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, - my horTick, log10 (position), 0.0, log10 (position));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, log10 (position), 1.0, log10 (position));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, - my horTick, log10 (position), text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markRightLogarithmic (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (position <= 0.0) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0.0, 1.0, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_LEFT, Graphics_HALF);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, 1.0 + my horTick, log10 (position), Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, 1.0, log10 (position), 1.0 + my horTick, log10 (position));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, 0.0, log10 (position), 1.0, log10 (position));
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, 1.0 + my horTick, log10 (position), text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markTopLogarithmic (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (position <= 0.0) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, log10 (position), 1.0 + my vertTick, Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, log10 (position), 1.0, log10 (position), 1.0 + my vertTick);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, log10 (position), 0.0, log10 (position), 1.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, log10 (position), 1.0 + my vertTick, text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_markBottomLogarithmic (Graphics me, double position, bool hasNumber, bool hasTick, bool hasDottedLine, conststring32 text /* cattable */) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- if (position <= 0.0) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- if (hasNumber) Graphics_text (me, log10 (position), - my vertTick, Melder_float (Melder_half (position)));
- if (hasTick) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- Graphics_line (me, log10 (position), - my vertTick, log10 (position), 0.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (hasDottedLine) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- Graphics_line (me, log10 (position), 0.0, log10 (position), 1.0);
- Graphics_setLineWidth (me, lineWidth);
- }
- if (text && text [0]) Graphics_text (me, log10 (position), - my vertTick, text);
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksLeftEvery (Graphics me, double units, double distance, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- integer first, last;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- distance *= units;
- first = Melder_iceiling (( y1WC < y2WC ? y1WC : y2WC ) / distance - 1e-5);
- last = Melder_ifloor (( y1WC < y2WC ? y2WC : y1WC ) / distance + 1e-5);
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_RIGHT, Graphics_HALF);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (integer i = first; i <= last; i ++) {
- double yWC = i * distance;
- if (haveNumbers) Graphics_text (me, - my horTick, yWC, Melder_float (Melder_half (yWC / units)));
- if (haveTicks) Graphics_line (me, - my horTick, yWC, 0.0, yWC);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (integer i = first; i <= last; i ++) {
- double yWC = i * distance;
- Graphics_line (me, 0.0, yWC, 1.0, yWC);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksRightEvery (Graphics me, double units, double distance, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- integer first, last;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- distance *= units;
- first = Melder_iceiling (( y1WC < y2WC ? y1WC : y2WC ) / distance - 1e-5);
- last = Melder_ifloor (( y1WC < y2WC ? y2WC : y1WC ) / distance + 1e-5);
- if (first > last) return;
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, 0, 1, y1WC, y2WC);
- Graphics_setTextAlignment (me, Graphics_LEFT, Graphics_HALF);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (integer i = first; i <= last; i ++) {
- double yWC = i * distance;
- if (haveNumbers) Graphics_text (me, 1.0 + my horTick, yWC, Melder_float (Melder_half (yWC / units)));
- if (haveTicks) Graphics_line (me, 1.0, yWC, 1.0 + my horTick, yWC);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (integer i = first; i <= last; i ++) {
- double yWC = i * distance;
- Graphics_line (me, 0.0, yWC, 1.0, yWC);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksBottomEvery (Graphics me, double units, double distance, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- integer first, last;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- distance *= units;
- first = Melder_iceiling (( x1WC < x2WC ? x1WC : x2WC ) / distance - 1e-5);
- last = Melder_ifloor (( x1WC < x2WC ? x2WC : x1WC ) / distance + 1e-5);
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_TOP);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (integer i = first; i <= last; i ++) {
- double xWC = i * distance;
- if (haveNumbers) Graphics_text (me, xWC, - my vertTick, Melder_float (Melder_half (xWC / units)));
- if (haveTicks) Graphics_line (me, xWC, - my vertTick, xWC, 0.0);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (integer i = first; i <= last; i ++) {
- double xWC = i * distance;
- Graphics_line (me, xWC, 0.0, xWC, 1.0);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_marksTopEvery (Graphics me, double units, double distance, bool haveNumbers, bool haveTicks, bool haveDottedLines) {
- double x1WC = my d_x1WC, x2WC = my d_x2WC, y1WC = my d_y1WC, y2WC = my d_y2WC;
- int lineType = my lineType;
- integer first, last;
- double lineWidth = my lineWidth;
- Graphics_Colour colour = my colour;
- distance *= units;
- first = Melder_iceiling (( x1WC < x2WC ? x1WC : x2WC ) / distance - 1e-5);
- last = Melder_ifloor (( x1WC < x2WC ? x2WC : x1WC ) / distance + 1e-5);
- Graphics_setColour (me, Graphics_BLACK);
- Graphics_setWindow (me, x1WC, x2WC, 0.0, 1.0);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_BOTTOM);
- Graphics_setInner (me);
- if (haveTicks) {
- Graphics_setLineType (me, Graphics_DRAWN);
- Graphics_setLineWidth (me, 2.0 * lineWidth);
- }
- for (integer i = first; i <= last; i ++) {
- double xWC = i * distance;
- if (haveNumbers) Graphics_text (me, xWC, 1.0 + my vertTick, Melder_float (Melder_half (xWC / units)));
- if (haveTicks) Graphics_line (me, xWC, 1.0, xWC, 1.0 + my vertTick);
- }
- if (haveTicks) Graphics_setLineWidth (me, lineWidth);
- if (haveDottedLines) {
- Graphics_setLineType (me, Graphics_DOTTED);
- Graphics_setLineWidth (me, 0.67 * lineWidth);
- for (integer i = first; i <= last; i ++) {
- double xWC = i * distance;
- Graphics_line (me, xWC, 0.0, xWC, 1.0);
- }
- Graphics_setLineWidth (me, lineWidth);
- }
- Graphics_unsetInner (me);
- Graphics_setWindow (me, x1WC, x2WC, y1WC, y2WC);
- Graphics_setLineType (me, lineType);
- Graphics_setColour (me, colour);
- }
- void Graphics_mark (Graphics me, double x, double y, double size_mm, conststring32 markString /* cattable */) {
- int mark;
- if (! markString || ! markString [0]) mark = 0;
- else if (! markString [1]) {
- if (markString [0] == '+') mark = 1;
- else if (markString [0] == 'x') mark = 2;
- else if (markString [0] == 'o') mark = 3;
- else if (markString [0] == '.') mark = 0;
- else mark = -1;
- } else mark = -1;
- if (mark == -1) {
- int oldSize = my fontSize;
- int oldHorizontalAlignment = my horizontalTextAlignment;
- int oldVerticalAlignment = my verticalTextAlignment;
- Graphics_setFontSize (me, size_mm * 72.0 / 25.4);
- Graphics_setTextAlignment (me, Graphics_CENTRE, Graphics_HALF);
- Graphics_text (me, x, y, markString);
- Graphics_setFontSize (me, oldSize);
- Graphics_setTextAlignment (me, (kGraphics_horizontalAlignment) oldHorizontalAlignment, oldVerticalAlignment);
- } else if (mark == 0) {
- Graphics_fillCircle_mm (me, x, y, size_mm);
- } else if (mark == 1) {
- double dx = 0.5 * Graphics_dxMMtoWC (me, size_mm);
- double dy = 0.5 * Graphics_dyMMtoWC (me, size_mm);
- Graphics_line (me, x - dx, y, x + dx, y);
- Graphics_line (me, x, y - dy, x, y + dy);
- } else if (mark == 2) {
- double dx = 0.4 * Graphics_dxMMtoWC (me, size_mm);
- double dy = 0.4 * Graphics_dyMMtoWC (me, size_mm);
- Graphics_line (me, x - dx, y - dy, x + dx, y + dy);
- Graphics_line (me, x + dx, y - dy, x - dx, y + dy);
- } else {
- Graphics_circle_mm (me, x, y, size_mm);
- }
- }
- void Graphics_setTextRotation_vector (Graphics me, double dx, double dy) {
- double angle;
- if (dy == 0.0) {
- angle = dx >= 0.0 ? 0.0 : 180.0;
- } else if (dx == 0.0) {
- angle = dy > 0.0 ? 90.0 : 270.0;
- } else {
- double dxDC = dx * my scaleX, dyDC = my yIsZeroAtTheTop ? -dy * my scaleY : dy * my scaleY;
- angle = atan2 (dyDC, dxDC) * (180.0 / NUMpi);
- }
- Graphics_setTextRotation (me, angle);
- }
- /* End of file Graphics_utils.cpp */
|