{"action":"created","issue":{"url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/752","repository_url":"https://api.github.com/repos/hajimehoshi/ebiten","labels_url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/752/labels{/name}","comments_url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/752/comments","events_url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/752/events","html_url":"https://github.com/hajimehoshi/ebiten/issues/752","id":391551854,"node_id":"MDU6SXNzdWUzOTE1NTE4NTQ=","number":752,"title":"new DrawImage options API (proposal)","user":{"login":"eihigh","id":44455895,"node_id":"MDQ6VXNlcjQ0NDU1ODk1","avatar_url":"https://avatars3.githubusercontent.com/u/44455895?v=4","gravatar_id":"","url":"https://api.github.com/users/eihigh","html_url":"https://github.com/eihigh","followers_url":"https://api.github.com/users/eihigh/followers","following_url":"https://api.github.com/users/eihigh/following{/other_user}","gists_url":"https://api.github.com/users/eihigh/gists{/gist_id}","starred_url":"https://api.github.com/users/eihigh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eihigh/subscriptions","organizations_url":"https://api.github.com/users/eihigh/orgs","repos_url":"https://api.github.com/users/eihigh/repos","events_url":"https://api.github.com/users/eihigh/events{/privacy}","received_events_url":"https://api.github.com/users/eihigh/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-17T04:15:15Z","updated_at":"2018-12-18T04:09:01Z","closed_at":"2018-12-18T04:09:01Z","author_association":"NONE","body":"Hi, I'm developing my games on Ebiten everyday. Thank you a lot.\r\n\r\nNow I want to propose a new DrawImage API, `DrawGroup`.\r\n\r\nMy external (and experimental) implementation is https://github.com/eihigh/love-and-hate/blob/master/internal/draw/draw.go .\r\n\r\n## Design\r\n\r\n`DrawGroup` contains `Dst`, `ColorM`, `CompositeMode`, and `Filter`. They're based on [Performance Tips](https://github.com/hajimehoshi/ebiten/wiki/Performance-Tips) .\r\n\r\n```Go\r\nfunc draw() {\r\n\t// If Dst is nil, screen is used as a default dst.\r\n\tdg := &ebiten.DrawGroup{Dst: nil}\r\n\r\n\t// Simple drawing.\r\n\tdg.DrawImage(someImage)\r\n\r\n\t// The first argument is *ebiten.Image.\r\n\t// The following arguments are GeoM/ColorM operations.\r\n\tdg.DrawImage(\r\n\t\tsomeImage,\r\n\t\tebiten.Translate(0, 100),\r\n\t\tebiten.Scale(-1, 1),\r\n\t)\r\n\r\n\t// Another group.\r\n\t// The less the group, the more efficient.\r\n\tdg = &ebiten.DrawImage{Mode: ebiten.CompositeModeLighter}\r\n\r\n\t// Each DrawImages are independent.\r\n\t// So there is no need to `op.GeoM.Reset()`\r\n\tdg.DrawImage(\r\n\t\tsomeEffect,\r\n\t\tebiten.Translate(50, 50),\r\n\t\tebiten.ScaleColor(1, 1, 1, 0.5),\r\n\t)\r\n}\r\n\r\n// Users can define custom operations.\r\nfunc center(i *ebiten.Image) ebiten.OptionFn {\r\n\tw, h := i.Size()\r\n\treturn ebiten.Translate(-float64(w)/2, -float64(h)/2)\r\n}\r\n```\r\n\r\nBy doing this,\r\n\r\n* more obvious about drawing performance\r\n* `screen` is hidden; never use screen as source\r\n    * and no need to manage `screen *ebiten.Image` passed to the update function\r\n* reduce boring `op.GeoM.Reset(); op.GeoM.Reset(); ...`\r\n* Tell deprecated fields in DrawImageOptions goodbye.\r\n\r\nConcerns:\r\n\r\n* Is this \"functional option pattern\" really easy (especially for beginners?)\r\n* Is this really simple?\r\n* Concurrency (maybe Dst should not be nil, set screen)\r\n* Some API changes, too many API additions.\r\n* My bad English ;)"},"comment":{"url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/comments/448089906","html_url":"https://github.com/hajimehoshi/ebiten/issues/752#issuecomment-448089906","issue_url":"https://api.github.com/repos/hajimehoshi/ebiten/issues/752","id":448089906,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODA4OTkwNg==","user":{"login":"eihigh","id":44455895,"node_id":"MDQ6VXNlcjQ0NDU1ODk1","avatar_url":"https://avatars3.githubusercontent.com/u/44455895?v=4","gravatar_id":"","url":"https://api.github.com/users/eihigh","html_url":"https://github.com/eihigh","followers_url":"https://api.github.com/users/eihigh/followers","following_url":"https://api.github.com/users/eihigh/following{/other_user}","gists_url":"https://api.github.com/users/eihigh/gists{/gist_id}","starred_url":"https://api.github.com/users/eihigh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eihigh/subscriptions","organizations_url":"https://api.github.com/users/eihigh/orgs","repos_url":"https://api.github.com/users/eihigh/repos","events_url":"https://api.github.com/users/eihigh/events{/privacy}","received_events_url":"https://api.github.com/users/eihigh/received_events","type":"User","site_admin":false},"created_at":"2018-12-18T04:09:01Z","updated_at":"2018-12-18T04:09:01Z","author_association":"NONE","body":"Thanks for your response and I'm sorry for I wasted your time 😢\r\n\r\nI agree that API should be stateless. And I should re-think about it.\r\nI have to study more and more...\r\n\r\nI'll close this issue. Thanks!"}}
{"actor":{"display_login":"eihigh"}}