| 1 | <html dir="rtl"> |
| 2 | <head> |
| 3 | <title>Testing textpath</title> |
| 4 | <style type="text/css"> |
| 5 | @import "../../../../dojo/resources/dojo.css"; |
| 6 | @import "../../../../dijit/tests/css/dijitTests.css"; |
| 7 | </style> |
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 9 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
| 10 | <script type="text/javascript"> |
| 11 | |
| 12 | dojo.require("dojox.gfx"); |
| 13 | dojo.require("dojox.gfx._gfxBidiSupport"); |
| 14 | |
| 15 | var CPD = 30, tp1, tp2, tp3,tp4,tp5, t1, t2, t3, t4, t5, t6; |
| 16 | var g1 = null; |
| 17 | var g2 = null; |
| 18 | |
| 19 | var surfaceLTR = null, surfaceRTL = null, surfaceAUTO = null; |
| 20 | |
| 21 | var placeAnchor = function(surface, x, y){ |
| 22 | surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}); |
| 23 | surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}); |
| 24 | }; |
| 25 | var makeText = function(surface, text, font, fill, stroke){ |
| 26 | var t = surface.createText(text); |
| 27 | if(font) t.setFont(font); |
| 28 | if(fill) t.setFill(fill); |
| 29 | if(stroke) t.setStroke(stroke); |
| 30 | placeAnchor(surface, text.x, text.y); |
| 31 | return t; |
| 32 | }; |
| 33 | |
| 34 | makeShapes = function(){ |
| 35 | var m = dojox.gfx.matrix; |
| 36 | surfaceLTR = dojox.gfx.createSurface("testLTR", 500, 170, "ltr"); |
| 37 | console.debug("surfaceLTR created"); |
| 38 | var p = surfaceLTR.createPath({}) |
| 39 | .moveTo(0, 15) |
| 40 | .setAbsoluteMode(false) |
| 41 | .curveTo(CPD, 0, 0, 0, 50, 0) |
| 42 | ; |
| 43 | console.debug("p created"); |
| 44 | tp1 = surfaceLTR.createTextPath({ |
| 45 | text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. " |
| 46 | , align: "start" |
| 47 | }) |
| 48 | .moveTo(0, 15) |
| 49 | .setAbsoluteMode(false) |
| 50 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 51 | .setFont({family: "times", size: "12pt"}) |
| 52 | .setFill("blue") |
| 53 | ; |
| 54 | console.debug("tp1 created"); |
| 55 | tp2 = surfaceLTR.createTextPath({ |
| 56 | text: "Beginning \u05e1\u05d5\u05e3." |
| 57 | , align: "start" |
| 58 | |
| 59 | }) |
| 60 | .moveTo(0, 50) |
| 61 | .setAbsoluteMode(false) |
| 62 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 63 | .setFont({family: "times", size: "12pt"}) |
| 64 | .setFill("blue") |
| 65 | ; |
| 66 | console.debug("tp2 created"); |
| 67 | g1 = surfaceLTR.createGroup(); |
| 68 | t1 = makeText(surfaceLTR, {id: "t1",x: 0, y: 100, text: "1.) \u05d4\u05ea\u05d7\u05dc\u05d4 end!"}, |
| 69 | {family: "Times", size: "18pt"}, "black", "blue") |
| 70 | .setTransform(m.rotategAt(0, 250, 150)); |
| 71 | |
| 72 | t2 = makeText(surfaceLTR, {x: 0, y: 140, text: "1.) Beginning \u05e1\u05d5\u05e3!"}, |
| 73 | {family: "Times", size: "18pt"}, "black", "blue") |
| 74 | .setTransform(m.rotategAt(0, 250, 100)); |
| 75 | |
| 76 | surfaceRTL = dojox.gfx.createSurface("testRTL", 500, 170); |
| 77 | console.debug("surfaceRTL created"); |
| 78 | var p2 = surfaceRTL.createPath({}) |
| 79 | .moveTo(0, 15) |
| 80 | .setAbsoluteMode(false) |
| 81 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 82 | ; |
| 83 | console.debug("p2 created"); |
| 84 | tp3 = surfaceRTL.createTextPath({ |
| 85 | text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. " |
| 86 | , align: "start" |
| 87 | //, rotated: true |
| 88 | }) |
| 89 | .moveTo(0, 15) |
| 90 | .setAbsoluteMode(false) |
| 91 | .curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 92 | .setFont({family: "times", size: "12pt"}) |
| 93 | .setFill("red") |
| 94 | ; |
| 95 | console.debug("tp3 created"); |
| 96 | tp4 = surfaceRTL.createTextPath({ |
| 97 | text: "Beginning \u05e1\u05d5\u05e3." |
| 98 | , align: "start" |
| 99 | |
| 100 | //, rotated: true |
| 101 | }) |
| 102 | //.setShape(p.shape) |
| 103 | .moveTo(0, 50) |
| 104 | .setAbsoluteMode(false) |
| 105 | .curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 106 | .setFont({family: "times", size: "12pt"}) |
| 107 | .setFill("red") |
| 108 | ; |
| 109 | console.debug("tp4 created"); |
| 110 | |
| 111 | t3 = makeText(surfaceRTL, {id: "t1",x: 0, y: 100, text: "1.) \u05d4\u05ea\u05d7\u05dc\u05d4 end!"}, |
| 112 | {family: "Times", size: "18pt"}, "black", "red") |
| 113 | .setTransform(m.rotategAt(0, 250, 150)); |
| 114 | |
| 115 | t4 = makeText(surfaceRTL, {x: 0, y: 140, text: "1.) Beginning \u05e1\u05d5\u05e3!"}, |
| 116 | {family: "Times", size: "18pt"}, "black", "red") |
| 117 | .setTransform(m.rotategAt(0, 250, 100)); |
| 118 | |
| 119 | surfaceAUTO = dojox.gfx.createSurface("testAUTO", 500, 170,"auto"); |
| 120 | console.debug("surfaceAUTO created"); |
| 121 | var p3 = surfaceAUTO.createPath({}) |
| 122 | .moveTo(0, 15) |
| 123 | .setAbsoluteMode(false) |
| 124 | .curveTo(CPD, 0, 0, 0, 100, 0) |
| 125 | ; |
| 126 | console.debug("p3 created"); |
| 127 | |
| 128 | var tp5 = surfaceAUTO.createTextPath({ |
| 129 | text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. " |
| 130 | , align: "start" |
| 131 | |
| 132 | //, rotated: true |
| 133 | }) |
| 134 | //.setShape(p.shape) |
| 135 | .moveTo(0, 15) |
| 136 | .setAbsoluteMode(false) |
| 137 | .curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 138 | |
| 139 | .setFont({family: "times", size: "12pt"}) |
| 140 | .setFill("red") |
| 141 | ; |
| 142 | console.debug("tp5 created"); |
| 143 | var tp6 = surfaceAUTO.createTextPath({ |
| 144 | text: "Beginning \u05e1\u05d5\u05e3." |
| 145 | , align: "start" |
| 146 | |
| 147 | //, rotated: true |
| 148 | }) |
| 149 | //.setShape(p.shape) |
| 150 | .moveTo(0, 50) |
| 151 | .setAbsoluteMode(false) |
| 152 | .curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 153 | .setFont({family: "times", size: "12pt"}) |
| 154 | .setFill("blue") |
| 155 | ; |
| 156 | console.debug("tp6 created"); |
| 157 | |
| 158 | t3 = makeText(surfaceAUTO, {id: "t1",x: 0, y: 100, text: "1.) \u05d4\u05ea\u05d7\u05dc\u05d4 end!"}, |
| 159 | {family: "Times", size: "18pt"}, "black", "red") |
| 160 | .setTransform(m.rotategAt(0, 250, 150)); |
| 161 | |
| 162 | t4 = makeText(surfaceAUTO, {x: 0, y: 140, text: "1.) Beginning \u05e1\u05d5\u05e3!"}, |
| 163 | {family: "Times", size: "18pt"}, "black", "blue") |
| 164 | .setTransform(m.rotategAt(0, 250, 100)); |
| 165 | |
| 166 | }; |
| 167 | |
| 168 | |
| 169 | dojo.addOnLoad(makeShapes); |
| 170 | |
| 171 | </script> |
| 172 | </head> |
| 173 | <body> |
| 174 | <h1>dojox.gfx Text on a Path test</h1> |
| 175 | <h2>LTR TextPath and Text first two are TextPath and two others are Text</h2> |
| 176 | <div id="testLTR" style="width: 500px;"></div> |
| 177 | <h2>RTL Text Path and Text first two are TextPath and two others are Text</h2> |
| 178 | <div id="testRTL" style="width: 500px;"></div> |
| 179 | <h2>AUTO Text Path and Text first two are TextPath and two others are Text</h2> |
| 180 | <div id="testAUTO" style="width: 500px;"></div> |
| 181 | |
| 182 | <p>That's all Folks!</p> |
| 183 | </body> |
| 184 | </html> |