ソースを参照

improved Arc_wText

Gilbert Brault 5 年 前
コミット
7544a1a41f

+ 327 - 0
notebooks/.ipynb_checkpoints/DryFriction-checkpoint.ipynb

@@ -0,0 +1,327 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "%matplotlib widget"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from pysketcher import *"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from ipywidgets import FloatSlider, AppLayout, Label, HBox, Button"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from IPython.display import SVG, display"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from math import tan, radians, sin, cos"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "myfig={}"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "gw = \"\"\"\\\n",
+    "libraries: [\"from math import tan, radians, sin, cos\",\"from pysketcher import *\"]\n",
+    "fontsize: 18\n",
+    "g: 9.81              # constant gravity\n",
+    "theta: 30.0          # inclined plane angle\n",
+    "L: 10.0              # sketch sizing parameter\n",
+    "a: 1.0               #\n",
+    "xmin: 0.0            # sketech min Abscissa\n",
+    "ymin: -3.0           # sketech min Ordinate     \n",
+    "rl: 2.0              # rectangle width\n",
+    "rL: 1.0              # rectangle length\n",
+    "setframe:            # sketch setup\n",
+    "    action: \"drawing_tool.set_coordinate_system(xmin=xmin, xmax=xmin+1.5*L,ymin=ymin, ymax=ymin+1.5*L,instruction_file='tmp_mpl_friction.py')\"\n",
+    "setblackline:        # default frame values and actions\n",
+    "    action: \"drawing_tool.set_linecolor('black')\"\n",
+    "B: point(a+L,0)                      # wall right end\n",
+    "A: point(a,tan(radians(theta))*L)    # wall left end\n",
+    "normal_vec: point(sin(radians(theta)),cos(radians(theta)))     # Vector normal to wall\n",
+    "tangent_vec: point(cos(radians(theta)),-sin(radians(theta)))   # Vector tangent to wall\n",
+    "help_line: Line(A,B)                 # wall line\n",
+    "x: a + 3*L/10.\n",
+    "y: help_line(x=x)    \n",
+    "contact: point(x, y)    \n",
+    "c: contact + rL/2*normal_vec\n",
+    "rectangle: \n",
+    "    formula: Rectangle(contact, rl, rL)\n",
+    "    style:\n",
+    "        linecolor: blue\n",
+    "        filled_curves: blue\n",
+    "    transform: [\"rotate(-theta, contact)\",\"translate(-rl/2*tangent_vec)\"]\n",
+    "N: \n",
+    "    formula: Force(contact - rl*normal_vec, contact, r'$N$', text_pos='start')\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "mg: \n",
+    "    formula: Gravity(c, rl, text='$Mg$')\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "wheel: \n",
+    "    formula: \"Composition({'outer': rectangle})\"   \n",
+    "    style:\n",
+    "        shadow: 1\n",
+    "body: \n",
+    "    formula: \"Composition({'wheel': wheel, 'N': N, 'mg': mg})\"\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "mB:\n",
+    "    formula: Text(r'$B$',B)\n",
+    "mA:\n",
+    "    formula: Text(r'$A$', A)\n",
+    "wall: \n",
+    "    formula: Wall(x=[A[0], B[0]], y=[A[1], B[1]], thickness=-0.25,transparent=False)\n",
+    "    style:\n",
+    "        linecolor: black    \n",
+    "angle: \n",
+    "    formula: \"Arc_wText(r'$<bslash>theta$', center=B, radius=3, start_angle=180-theta, arc_angle=theta, fontsize=fontsize)\"\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "        linewidth: 1\n",
+    "ground: \n",
+    "     formula: Line((B[0]-L/10., 0), (B[0]-L/2.,0))\n",
+    "     stlye:\n",
+    "         linecolor: black\n",
+    "         linestyle: dashed\n",
+    "         linewidth: 1\n",
+    "x_const: \n",
+    "    formula: Line(contact, contact + point(0,4))\n",
+    "    style:\n",
+    "        linestyle: dotted\n",
+    "    transform: rotate(-theta, contact)\n",
+    "x_axis: \n",
+    "    formula: \"Axis(start=contact+ 2*rl*normal_vec, length=2*rl,label='$x$', rotation_angle=-theta)\"\n",
+    "plan: \n",
+    "    formula: \"Composition({'body': body, 'angle': angle, 'inclined wall': wall, 'x start': x_const, 'x axis': x_axis, 'mA': mA, 'mB': mB})\"\n",
+    "friction: \n",
+    "    formula: \"Composition({'plan': plan, 'ground': ground})\"\n",
+    "\"\"\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "sketchParse(gw,myfig)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "d = myfig['friction'].draw()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.display()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "angle = myfig['theta']\n",
+    "def doright(change):\n",
+    "    global angle\n",
+    "    rotate(-5)\n",
+    "    angle += 5\n",
+    "def doleft(change):\n",
+    "    global angle\n",
+    "    rotate(5)\n",
+    "    angle -= 5\n",
+    "def rotate(theta):\n",
+    "    global angle\n",
+    "    drawing_tool.erase()\n",
+    "    myfig['plan']['angle'].changeAngles(180-angle,angle)\n",
+    "    myfig['plan'].rotate(theta,myfig['B'])\n",
+    "    myfig['friction'].draw()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "left = Button(\n",
+    "    description = '',\n",
+    "    icon = 'rotate-left',\n",
+    ")\n",
+    "left.on_click(doleft)\n",
+    "right = Button(\n",
+    "    description = '',\n",
+    "    icon = 'rotate-right',\n",
+    ")\n",
+    "right.on_click(doright)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "application/vnd.jupyter.widget-view+json": {
+       "model_id": "3cff8da2d92b4c4a803bac48e8f4a06f",
+       "version_major": 2,
+       "version_minor": 0
+      },
+      "text/plain": [
+       "AppLayout(children=(HBox(children=(Button(icon='rotate-left', style=ButtonStyle()), Button(icon='rotate-right'…"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "AppLayout(\n",
+    "    center=drawing_tool.mpl.gcf().canvas,\n",
+    "    footer=HBox([left,right]),\n",
+    "    pane_heights=[0, 6, 1]\n",
+    ")\n",
+    "#drawing_tool.mpl.ion()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.mpl.ion()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "myfig['friction'].graphviz_dot('friction')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "!dot -Tpng -o friction.png friction.dot"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "![](friction.png)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.mpl.gcf().canvas.print_png(\"friction.png\")"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "![](friction.png)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "display(SVG(sketch2SVG()))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

ファイルの差分が大きいため隠しています
+ 24 - 157
notebooks/.ipynb_checkpoints/yamlTest-checkpoint.ipynb


+ 327 - 0
notebooks/DryFriction.ipynb

@@ -0,0 +1,327 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "%matplotlib widget"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from pysketcher import *"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from ipywidgets import FloatSlider, AppLayout, Label, HBox, Button"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from IPython.display import SVG, display"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from math import tan, radians, sin, cos"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "myfig={}"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "gw = \"\"\"\\\n",
+    "libraries: [\"from math import tan, radians, sin, cos\",\"from pysketcher import *\"]\n",
+    "fontsize: 18\n",
+    "g: 9.81              # constant gravity\n",
+    "theta: 30.0          # inclined plane angle\n",
+    "L: 10.0              # sketch sizing parameter\n",
+    "a: 1.0               #\n",
+    "xmin: 0.0            # sketech min Abscissa\n",
+    "ymin: -3.0           # sketech min Ordinate     \n",
+    "rl: 2.0              # rectangle width\n",
+    "rL: 1.0              # rectangle length\n",
+    "setframe:            # sketch setup\n",
+    "    action: \"drawing_tool.set_coordinate_system(xmin=xmin, xmax=xmin+1.5*L,ymin=ymin, ymax=ymin+1.5*L,instruction_file='tmp_mpl_friction.py')\"\n",
+    "setblackline:        # default frame values and actions\n",
+    "    action: \"drawing_tool.set_linecolor('black')\"\n",
+    "B: point(a+L,0)                      # wall right end\n",
+    "A: point(a,tan(radians(theta))*L)    # wall left end\n",
+    "normal_vec: point(sin(radians(theta)),cos(radians(theta)))     # Vector normal to wall\n",
+    "tangent_vec: point(cos(radians(theta)),-sin(radians(theta)))   # Vector tangent to wall\n",
+    "help_line: Line(A,B)                 # wall line\n",
+    "x: a + 3*L/10.\n",
+    "y: help_line(x=x)    \n",
+    "contact: point(x, y)    \n",
+    "c: contact + rL/2*normal_vec\n",
+    "rectangle: \n",
+    "    formula: Rectangle(contact, rl, rL)\n",
+    "    style:\n",
+    "        linecolor: blue\n",
+    "        filled_curves: blue\n",
+    "    transform: [\"rotate(-theta, contact)\",\"translate(-rl/2*tangent_vec)\"]\n",
+    "N: \n",
+    "    formula: Force(contact - rl*normal_vec, contact, r'$N$', text_pos='start')\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "mg: \n",
+    "    formula: Gravity(c, rl, text='$Mg$')\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "wheel: \n",
+    "    formula: \"Composition({'outer': rectangle})\"   \n",
+    "    style:\n",
+    "        shadow: 1\n",
+    "body: \n",
+    "    formula: \"Composition({'wheel': wheel, 'N': N, 'mg': mg})\"\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "mB:\n",
+    "    formula: Text(r'$B$',B)\n",
+    "mA:\n",
+    "    formula: Text(r'$A$', A)\n",
+    "wall: \n",
+    "    formula: Wall(x=[A[0], B[0]], y=[A[1], B[1]], thickness=-0.25,transparent=False)\n",
+    "    style:\n",
+    "        linecolor: black    \n",
+    "angle: \n",
+    "    formula: \"Arc_wText(r'$<bslash>theta$', center=B, radius=3, start_angle=180-theta, arc_angle=theta, fontsize=fontsize)\"\n",
+    "    style:\n",
+    "        linecolor: black\n",
+    "        linewidth: 1\n",
+    "ground: \n",
+    "     formula: Line((B[0]-L/10., 0), (B[0]-L/2.,0))\n",
+    "     stlye:\n",
+    "         linecolor: black\n",
+    "         linestyle: dashed\n",
+    "         linewidth: 1\n",
+    "x_const: \n",
+    "    formula: Line(contact, contact + point(0,4))\n",
+    "    style:\n",
+    "        linestyle: dotted\n",
+    "    transform: rotate(-theta, contact)\n",
+    "x_axis: \n",
+    "    formula: \"Axis(start=contact+ 2*rl*normal_vec, length=2*rl,label='$x$', rotation_angle=-theta)\"\n",
+    "plan: \n",
+    "    formula: \"Composition({'body': body, 'angle': angle, 'inclined wall': wall, 'x start': x_const, 'x axis': x_axis, 'mA': mA, 'mB': mB})\"\n",
+    "friction: \n",
+    "    formula: \"Composition({'plan': plan, 'ground': ground})\"\n",
+    "\"\"\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "sketchParse(gw,myfig)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "d = myfig['friction'].draw()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.display()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "angle = myfig['theta']\n",
+    "def doright(change):\n",
+    "    global angle\n",
+    "    rotate(-5)\n",
+    "    angle += 5\n",
+    "def doleft(change):\n",
+    "    global angle\n",
+    "    rotate(5)\n",
+    "    angle -= 5\n",
+    "def rotate(theta):\n",
+    "    global angle\n",
+    "    drawing_tool.erase()\n",
+    "    myfig['plan']['angle'].changeAngles(180-angle,angle)\n",
+    "    myfig['plan'].rotate(theta,myfig['B'])\n",
+    "    myfig['friction'].draw()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "left = Button(\n",
+    "    description = '',\n",
+    "    icon = 'rotate-left',\n",
+    ")\n",
+    "left.on_click(doleft)\n",
+    "right = Button(\n",
+    "    description = '',\n",
+    "    icon = 'rotate-right',\n",
+    ")\n",
+    "right.on_click(doright)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "application/vnd.jupyter.widget-view+json": {
+       "model_id": "51b53a7bf9db49359e0ddb79fa3f037b",
+       "version_major": 2,
+       "version_minor": 0
+      },
+      "text/plain": [
+       "AppLayout(children=(HBox(children=(Button(icon='rotate-left', style=ButtonStyle()), Button(icon='rotate-right'…"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "AppLayout(\n",
+    "    center=drawing_tool.mpl.gcf().canvas,\n",
+    "    footer=HBox([left,right]),\n",
+    "    pane_heights=[0, 6, 1]\n",
+    ")\n",
+    "#drawing_tool.mpl.ion()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.mpl.ion()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "myfig['friction'].graphviz_dot('friction')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "!dot -Tpng -o friction.png friction.dot"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "![](friction.png)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "drawing_tool.mpl.gcf().canvas.print_png(\"friction.png\")"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "![](friction.png)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "display(SVG(sketch2SVG()))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.8.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}

+ 2 - 0
notebooks/fig.dot

@@ -33,4 +33,6 @@ digraph G {
 "Arrow3:\narrow" -> "Line:\nhead right";
 "Line:\nhead right" -> "Curve:\nline (7)";
 "Axis:\nx axis" -> "Text:\nlabel";
+"Composition:\nfixed elements" -> "Text:\nmA";
+"Composition:\nfixed elements" -> "Text:\nmB";
 }

BIN
notebooks/fig.png


BIN
notebooks/fig1.png


+ 36 - 0
notebooks/friction.dot

@@ -0,0 +1,36 @@
+digraph G {
+"Composition:\nfriction" -> "Composition:\nplan";
+"Composition:\nplan" -> "Composition:\nbody";
+"Composition:\nbody" -> "Composition:\nwheel";
+"Composition:\nwheel" -> "Rectangle:\nouter";
+"Rectangle:\nouter" -> "Curve:\nrectangle";
+"Composition:\nbody" -> "Force:\nN";
+"Force:\nN" -> "Line:\narrow (1)";
+"Line:\narrow (1)" -> "Curve:\nline (1)";
+"Force:\nN" -> "Text:\ntext (1)";
+"Composition:\nbody" -> "Gravity:\nmg";
+"Gravity:\nmg" -> "Line:\narrow (2)";
+"Line:\narrow (2)" -> "Curve:\nline (2)";
+"Gravity:\nmg" -> "Text:\ntext (2)";
+"Composition:\nplan" -> "Arc_wText:\nangle";
+"Arc_wText:\nangle" -> "Arc:\narc";
+"Arc:\narc" -> "Curve:\narc";
+"Arc_wText:\nangle" -> "Text:\ntext (3)";
+"Composition:\nplan" -> "Wall:\ninclined wall";
+"Wall:\ninclined wall" -> "Curve:\nwall";
+"Composition:\nplan" -> "Line:\nx start";
+"Line:\nx start" -> "Curve:\nline (3)";
+"Composition:\nplan" -> "Axis:\nx axis";
+"Axis:\nx axis" -> "Arrow3:\narrow";
+"Arrow3:\narrow" -> "Line:\nline";
+"Line:\nline" -> "Curve:\nline (4)";
+"Arrow3:\narrow" -> "Line:\nhead left";
+"Line:\nhead left" -> "Curve:\nline (5)";
+"Arrow3:\narrow" -> "Line:\nhead right";
+"Line:\nhead right" -> "Curve:\nline (6)";
+"Axis:\nx axis" -> "Text:\nlabel";
+"Composition:\nplan" -> "Text:\nmA";
+"Composition:\nplan" -> "Text:\nmB";
+"Composition:\nfriction" -> "Line:\nground";
+"Line:\nground" -> "Curve:\nline (7)";
+}

BIN
notebooks/friction.png


ファイルの差分が大きいため隠しています
+ 24 - 157
notebooks/yamlTest.ipynb


+ 21 - 6
pysketcher/shapes.py

@@ -70,7 +70,7 @@ def sketchParse(sketch, container):
                 else:
                     for _transform in _c["transform"]:
                     #  x_const.rotate(-theta, contact)
-                        _t = f"{_k}.{_c['transform']}"
+                        _t = f"{_k}.{_transform}"
                         #print(_t)
                         exec(_t,container)
             if "action" in _keys:
@@ -1631,13 +1631,28 @@ class Arc_wText(Shape):
     def __init__(self, text, center, radius,
                  start_angle, arc_angle, fontsize=0,
                  resolution=180, text_spacing=1/60.):
-        arc = Arc(center, radius, start_angle, arc_angle,
-                  resolution)
+        self.text = text
+        self.center = center
+        self.radius = radius
+        self.fontsize=fontsize
+        self.resolution=resolution
+        self.text_spacing=text_spacing
+        self.changeAngles(start_angle,arc_angle)
+    def changeAngles(self,start_angle,arc_angle):
+        arc = Arc(self.center, self.radius, start_angle, arc_angle,
+                  self.resolution)
         mid = arr2D(arc(arc_angle/2.))
-        normal = unit_vec(mid - arr2D(center))
-        text_pos = mid + normal*drawing_tool.xrange*text_spacing
+        normal = unit_vec(mid - arr2D(self.center))
+        text_pos = mid + normal*drawing_tool.xrange*self.text_spacing
+        if hasattr(self, 'linewidth'):
+            arc.set_linewidth(self.linewidth)
         self.shapes = {'arc': arc,
-                       'text': Text(text, text_pos, fontsize=fontsize)}
+                       'text': Text(self.text, text_pos, fontsize=self.fontsize)}
+    def set_linewidth(self, width):
+        self.linewidth = width
+        self.change_linewidth()
+    def change_linewidth(self):
+        super().set_linewidth(self.linewidth)
 
 class Composition(Shape):
     def __init__(self, shapes):