{"action":"opened","issue":{"url":"https://api.github.com/repos/karai17/Simple-Tiled-Implementation/issues/125","repository_url":"https://api.github.com/repos/karai17/Simple-Tiled-Implementation","labels_url":"https://api.github.com/repos/karai17/Simple-Tiled-Implementation/issues/125/labels{/name}","comments_url":"https://api.github.com/repos/karai17/Simple-Tiled-Implementation/issues/125/comments","events_url":"https://api.github.com/repos/karai17/Simple-Tiled-Implementation/issues/125/events","html_url":"https://github.com/karai17/Simple-Tiled-Implementation/issues/125","id":189550707,"number":125,"title":"Inherit color space during Map:drawLayer","user":{"login":"josefnpat","id":646162,"avatar_url":"https://avatars.githubusercontent.com/u/646162?v=3","gravatar_id":"","url":"https://api.github.com/users/josefnpat","html_url":"https://github.com/josefnpat","followers_url":"https://api.github.com/users/josefnpat/followers","following_url":"https://api.github.com/users/josefnpat/following{/other_user}","gists_url":"https://api.github.com/users/josefnpat/gists{/gist_id}","starred_url":"https://api.github.com/users/josefnpat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josefnpat/subscriptions","organizations_url":"https://api.github.com/users/josefnpat/orgs","repos_url":"https://api.github.com/users/josefnpat/repos","events_url":"https://api.github.com/users/josefnpat/events{/privacy}","received_events_url":"https://api.github.com/users/josefnpat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-16T00:44:26Z","updated_at":"2016-11-16T00:44:26Z","closed_at":null,"body":"So I was trying to debug stuff by setting the color of a layer, but saw it doesn't inherit the color space (love.graphics.[get|set]Color)\r\n\r\nI then looked at the code, and saw that it was mangling it into rgba(255,255,255,255).\r\n\r\nI know you need to get the layer opacity, but you can do that while still respecting the global color space.\r\n\r\n```diff\r\ndiff --git a/src/libs/sti/init.lua b/src/libs/sti/init.lua\r\nindex dc4c7c3..971bf80 100644\r\n--- a/src/libs/sti/init.lua\r\n+++ b/src/libs/sti/init.lua\r\n@@ -695,9 +695,10 @@ end\r\n -- @param layer The Layer to draw\r\n -- @return nil\r\n function Map:drawLayer(layer)\r\n-\tlg.setColor(255, 255, 255, 255 * layer.opacity)\r\n+\tlocal r,g,b,a = love.graphics.getColor()\r\n+\tlg.setColor(r, g, b, a * layer.opacity)\r\n \tlayer:draw()\r\n-\tlg.setColor(255, 255, 255, 255)\r\n+\tlg.setColor(r,g,b,a)\r\n end\r\n \r\n --- Default draw function for Tile Layers\r\n```\r\n\r\nThis is what I did, and I would suggest something like this.\r\n\r\nThat way you can make color changes to the layers, and even fade them out, etc. Anything you can do with rgba."}}
{"actor":{"display_login":"josefnpat"}}