Discussion:
PStricks problem
Arek Kuźniewski
2008-08-18 13:44:59 UTC
Permalink
I need to define function (in pstricks mode) for drawing lines. Function
should work like this:
------------
\def\newhline(#1,#2){#3}{\psline(#1,#2)(#1+#3,#2)
------------
Of course this function doesn't work.
How can I define this function? If I needed only integer values of #1
and #3, I would do it by counters, for example:
------------
\newcounter{nhlc}
\def\newhline(#1,#2){#3}{\setcounter{nhlc}{#1}\stepcounter{nhlc}{#3}
\psline(#1,#2)(\thenhlc,#2)}
-------------
But the problem is, that I need #1 and #3 in real (e.g. #1=1.2 and #3=4.3).
The second definition doesn't work for it.

Is some way to define function for calculation #1+#3?
--
Arek

In darkness there can be light.
In misery there can be beauty.
In death there can be life.
Alain Delmotte
2008-08-25 08:08:00 UTC
Permalink
Hello,

Have a look at the calc package! It brings changes to the arguments and
lengths of the counters.
I had the same problem when I created the pst-soroban package. (Have a
look to pst-soroban.sty-CTAN)

Hope this helped.

Alain Delmotte
Post by Arek Kuźniewski
I need to define function (in pstricks mode) for drawing lines.
------------
\def\newhline(#1,#2){#3}{\psline(#1,#2)(#1+#3,#2)
------------
Of course this function doesn't work.
How can I define this function? If I needed only integer values of #1
------------
\newcounter{nhlc}
\def\newhline(#1,#2){#3}{\setcounter{nhlc}{#1}\stepcounter{nhlc}{#3}
\psline(#1,#2)(\thenhlc,#2)}
-------------
But the problem is, that I need #1 and #3 in real (e.g. #1=1.2 and #3=4.3).
The second definition doesn't work for it.
Is some way to define function for calculation #1+#3?
--
Arek
In darkness there can be light.
In misery there can be beauty.
In death there can be life.
------------------------------------
Arek Kuźniewski
2008-08-25 16:23:55 UTC
Permalink
Hello

I can't see where are you making operation on non-integer values in your
pts-soroban.sty

You always have A+B or A-B or A*B, but A and B are always integer (1, 2,
3, ...). I need to do these operations on real A and B (1.2, 1.3, 1.25
etc.).
If I'm wrong, tell me, where (in your pst-soroban.sty) you can make
+/-/* operations on the real values.

(I hope my description is clear, because my English is not good).

Greetings,
Arek
Post by Alain Delmotte
Hello,
Have a look at the calc package! It brings changes to the arguments and
lengths of the counters.
I had the same problem when I created the pst-soroban package. (Have a
look to pst-soroban.sty-CTAN)
Hope this helped.
Alain Delmotte
Post by Arek Kuźniewski
I need to define function (in pstricks mode) for drawing lines.
------------
\def\newhline(#1,#2){#3}{\psline(#1,#2)(#1+#3,#2)
------------
Of course this function doesn't work.
How can I define this function? If I needed only integer values of #1
------------
\newcounter{nhlc}
\def\newhline(#1,#2){#3}{\setcounter{nhlc}{#1}\stepcounter{nhlc}{#3}
\psline(#1,#2)(\thenhlc,#2)}
-------------
But the problem is, that I need #1 and #3 in real (e.g. #1=1.2 and #3=4.3).
The second definition doesn't work for it.
Is some way to define function for calculation #1+#3?
--
Arek
In darkness there can be light.
In misery there can be beauty.
In death there can be life.
------------------------------------
Alain Delmotte
2008-08-26 12:45:57 UTC
Permalink
Hi!

You are right for pst-soroban.
Here is the beginning of pgf-soroban where there is computation of new
lengths with decimals in the \ladj command (lengthadjust):
the argument of \ladj is a decimal asking for a drawing a
fraction/multiple of the normal (unit??) one, which draws a soroban of
the actual size.
(I think what you need is decimal lengths??)

Hope this helps.

Alain Delmotte

\RequirePackage{calc,ifthen}
\RequirePackage{tikz}

\definecolor{brun}{rgb}{.55 .27 .08} % nouvelle couleur brune
\newcommand{\colbil}{yellow} % couleur par défaut des billes
\newcommand{\coltig}{brun} % couleur par défaut des billes

\newcounter{xx}
\newcounter{yy}
\newlength{\unba}\setlength{\unba}{1mm} % unité de base, par défaut 1mm
\newlength{\eplia}\setlength{\eplia}{3.9mm} % support et ligne centrale
\newlength{\eplib}\setlength{\eplib}{2pt} % deux barres autour ligne
centrale
\newlength{\eplic}\setlength{\eplic}{6pt} % cadre et barres extérieures
\newlength{\eplid}\setlength{\eplid}{1pt} % arrondi des billes

\newcommand{\ladj}[1]{% ajustement des longueurs
\setlength{\unba}{1mm * \real{#1}}
\setlength{\eplia}{3.9mm * \real{#1}}
\setlength{\eplib}{2pt * \real{#1}}
\setlength{\eplic}{6pt * \real{#1}}
\setlength{\eplid}{1pt * \real{#1}}
}
Post by Arek Kuźniewski
Hello
I can't see where are you making operation on non-integer values in your
pts-soroban.sty
You always have A+B or A-B or A*B, but A and B are always integer (1, 2,
3, ...). I need to do these operations on real A and B (1.2, 1.3, 1.25
etc.).
If I'm wrong, tell me, where (in your pst-soroban.sty) you can make
+/-/* operations on the real values.
(I hope my description is clear, because my English is not good).
Greetings,
Arek
Post by Alain Delmotte
Hello,
Have a look at the calc package! It brings changes to the arguments and
lengths of the counters.
I had the same problem when I created the pst-soroban package. (Have a
look to pst-soroban.sty-CTAN)
Hope this helped.
Alain Delmotte
Post by Arek Kuźniewski
I need to define function (in pstricks mode) for drawing lines.
------------
\def\newhline(#1,#2){#3}{\psline(#1,#2)(#1+#3,#2)
------------
Of course this function doesn't work.
How can I define this function? If I needed only integer values of #1
------------
\newcounter{nhlc}
\def\newhline(#1,#2){#3}{\setcounter{nhlc}{#1}\stepcounter{nhlc}{#3}
\psline(#1,#2)(\thenhlc,#2)}
-------------
But the problem is, that I need #1 and #3 in real (e.g. #1=1.2 and #3=4.3).
The second definition doesn't work for it.
Is some way to define function for calculation #1+#3?
--
Arek
In darkness there can be light.
In misery there can be beauty.
In death there can be life.
------------------------------------
Yahoo! Groups Links
------------------------------------

Continue reading on narkive:
Loading...