{"action":"created","issue":{"url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/841","repository_url":"https://api.github.com/repos/Gamua/Starling-Framework","labels_url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/841/labels{/name}","comments_url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/841/comments","events_url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/841/events","html_url":"https://github.com/Gamua/Starling-Framework/issues/841","id":150085732,"number":841,"title":"Add border parameter to Canvas object drawing","user":{"login":"sjabberwocky","id":4690432,"avatar_url":"https://avatars.githubusercontent.com/u/4690432?v=3","gravatar_id":"","url":"https://api.github.com/users/sjabberwocky","html_url":"https://github.com/sjabberwocky","followers_url":"https://api.github.com/users/sjabberwocky/followers","following_url":"https://api.github.com/users/sjabberwocky/following{/other_user}","gists_url":"https://api.github.com/users/sjabberwocky/gists{/gist_id}","starred_url":"https://api.github.com/users/sjabberwocky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjabberwocky/subscriptions","organizations_url":"https://api.github.com/users/sjabberwocky/orgs","repos_url":"https://api.github.com/users/sjabberwocky/repos","events_url":"https://api.github.com/users/sjabberwocky/events{/privacy}","received_events_url":"https://api.github.com/users/sjabberwocky/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Gamua/Starling-Framework/labels/Feature","name":"Feature","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-21T14:09:38Z","updated_at":"2016-04-29T16:01:22Z","closed_at":null,"body":"I think It's good idea to add border to simple canvas objects.\r\nYou could do it based on my code for ellipse border or could do something much more beautiful. :)\r\n```as3\r\nprivate function drawEllipseBorder(canvas : Canvas, rx : Number, ry : Number, color : Number, thickness : Number, alpha : Number) : void\r\n{\r\n    var step : Number = 2 * Math.PI / 40;\r\n    var points : Vector.<Point> = new Vector.<Point>();\r\n    for (var angle : Number = 0; angle < 2 * Math.PI; angle += step)\r\n    {\r\n        points.push(new Point(rx * Math.cos(angle), -ry * Math.sin(angle)));\r\n    }\r\n\r\n    var border : Canvas = new Canvas();\r\n    for (var i : uint = 0; i < points.length; i++)\r\n    {\r\n        drawBorderPiece(points[i], (i + 1 == points.length) ? points[0] : points[i + 1], canvas, color, thickness, alpha);\r\n    }\r\n}\r\n\r\nprivate function drawBorderPiece(pointX : Point, pointY : Point, canvas : Canvas, color : uint, thickness : Number, alpha : Number) : void\r\n{\r\n    var newVertices : Array = new Array();\r\n\r\n    newVertices.push(getVertex(pointX, pointY, -thickness));\r\n    newVertices.push(getVertex(pointX, pointY, thickness));\r\n    newVertices.push(getVertex(pointY, pointX, -thickness));\r\n    newVertices.push(getVertex(pointY, pointX, thickness));\r\n\r\n    var pol : Polygon = new Polygon(newVertices);\r\n    canvas.beginFill(color, alpha);\r\n    canvas.drawPolygon(pol);\r\n    canvas.endFill();\r\n}\r\n\r\nprivate function getVertex(a0 : Point, a1 : Point, thickness : Number) : Point\r\n{\r\n    //calculate normal vector where х = (у0-у1); у = (х1-х0)\r\n    var n : Point = new Point(a0.y - a1.y, a1.x - a0.x);\r\n    //calculate normal vector lenght \r\n    var l : Number = Math.sqrt(n.x * n.x + n.y * n.y);\r\n    //normalize vector, multiply by thickness, add end point\r\n    n.x = n.x / l * thickness + a1.x;\r\n    n.y = n.y / l * thickness + a1.y;\r\n    return n;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/comments/215778557","html_url":"https://github.com/Gamua/Starling-Framework/issues/841#issuecomment-215778557","issue_url":"https://api.github.com/repos/Gamua/Starling-Framework/issues/841","id":215778557,"user":{"login":"aberestovskyi","id":11671104,"avatar_url":"https://avatars.githubusercontent.com/u/11671104?v=3","gravatar_id":"","url":"https://api.github.com/users/aberestovskyi","html_url":"https://github.com/aberestovskyi","followers_url":"https://api.github.com/users/aberestovskyi/followers","following_url":"https://api.github.com/users/aberestovskyi/following{/other_user}","gists_url":"https://api.github.com/users/aberestovskyi/gists{/gist_id}","starred_url":"https://api.github.com/users/aberestovskyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aberestovskyi/subscriptions","organizations_url":"https://api.github.com/users/aberestovskyi/orgs","repos_url":"https://api.github.com/users/aberestovskyi/repos","events_url":"https://api.github.com/users/aberestovskyi/events{/privacy}","received_events_url":"https://api.github.com/users/aberestovskyi/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T16:01:22Z","updated_at":"2016-04-29T16:01:22Z","body":"I've portabled this extenstion https://github.com/StarlingGraphics/Starling-Extension-Graphics to Starling 2.0. Made rounded rectangle and stroke for the objects. I'll make pull request with it soon"}}