{"action":"created","issue":{"url":"https://api.github.com/repos/backspaces/agentscript/issues/69","labels_url":"https://api.github.com/repos/backspaces/agentscript/issues/69/labels{/name}","comments_url":"https://api.github.com/repos/backspaces/agentscript/issues/69/comments","events_url":"https://api.github.com/repos/backspaces/agentscript/issues/69/events","html_url":"https://github.com/backspaces/agentscript/pull/69","id":47629080,"number":69,"title":"Rendering module","user":{"login":"bennlich","id":704368,"avatar_url":"https://avatars.githubusercontent.com/u/704368?v=3","gravatar_id":"","url":"https://api.github.com/users/bennlich","html_url":"https://github.com/bennlich","followers_url":"https://api.github.com/users/bennlich/followers","following_url":"https://api.github.com/users/bennlich/following{/other_user}","gists_url":"https://api.github.com/users/bennlich/gists{/gist_id}","starred_url":"https://api.github.com/users/bennlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennlich/subscriptions","organizations_url":"https://api.github.com/users/bennlich/orgs","repos_url":"https://api.github.com/users/bennlich/repos","events_url":"https://api.github.com/users/bennlich/events{/privacy}","received_events_url":"https://api.github.com/users/bennlich/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-11-03T18:48:38Z","updated_at":"2015-04-07T01:42:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/backspaces/agentscript/pulls/69","html_url":"https://github.com/backspaces/agentscript/pull/69","diff_url":"https://github.com/backspaces/agentscript/pull/69.diff","patch_url":"https://github.com/backspaces/agentscript/pull/69.patch"},"body":"**Not for merging! Currently just for sparking discussion.**\r\n\r\nThis is the beginning of an attempt to isolate canvas/rendering logic in a single class, `CanvasView`. The goal is to easily be able to swap out renderers (Canvas, CanvasTile, WebGL) of an agentscript model.\r\n\r\nSo far, the changes have all been pretty straightforward cutting/pasting `Model` functions over  to `CanvasView`.\r\n\r\nI left `setWorld()` in `Model` for the time being because it seems model-related, although a lot of the calculations it performs are specifically for rendering.\r\n\r\nStill need to figure out how to deal with lingering references to `model.contexts`:\r\n\r\n* In `AgentSet`, `show()`, `hide()`\r\n```\r\nshow: -> o.hidden = false for o in @; @draw(@model.contexts[@name])\r\nhide: -> o.hidden = true for o in @; @draw(@model.contexts[@name])\r\n```\r\nShould AgentSets emit 'changed' events to alert the renderer to redraw them?\r\n\r\nAnd:\r\n\r\n* In `Patches`, `usePixels()`, `setPixels()`, `installDrawing()`\r\n\r\n```\r\nusePixels: (@drawWithPixels=true) ->\r\n  ctx = @model.contexts.patches\r\n  u.setCtxSmoothing ctx, not @drawWithPixels\r\n  \r\nsetPixels: ->\r\n  if @size is 1\r\n  then @usePixels(); @pixelsCtx = @model.contexts.patches\r\n  else @pixelsCtx = u.createCtx @numX, @numY\r\n  @pixelsImageData = @pixelsCtx.getImageData(0, 0, @numX, @numY)\r\n  @pixelsData = @pixelsImageData.data\r\n    if @pixelsData instanceof Uint8Array # Check for typed arrays\r\n      @pixelsData32 = new Uint32Array @pixelsData.buffer\r\n      @pixelsAreLittleEndian = u.isLittleEndian()\r\n  \r\ninstallDrawing: (img, ctx=@model.contexts.drawing) ->\r\n  u.setIdentity ctx\r\n  ctx.drawImage img, 0, 0, ctx.canvas.width, ctx.canvas.height\r\n  ctx.restore()\r\n```\r\n\r\nCan these be made into aliases for functionality in CanvasView?"},"comment":{"url":"https://api.github.com/repos/backspaces/agentscript/issues/comments/90308139","html_url":"https://github.com/backspaces/agentscript/pull/69#issuecomment-90308139","issue_url":"https://api.github.com/repos/backspaces/agentscript/issues/69","id":90308139,"user":{"login":"bennlich","id":704368,"avatar_url":"https://avatars.githubusercontent.com/u/704368?v=3","gravatar_id":"","url":"https://api.github.com/users/bennlich","html_url":"https://github.com/bennlich","followers_url":"https://api.github.com/users/bennlich/followers","following_url":"https://api.github.com/users/bennlich/following{/other_user}","gists_url":"https://api.github.com/users/bennlich/gists{/gist_id}","starred_url":"https://api.github.com/users/bennlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennlich/subscriptions","organizations_url":"https://api.github.com/users/bennlich/orgs","repos_url":"https://api.github.com/users/bennlich/repos","events_url":"https://api.github.com/users/bennlich/events{/privacy}","received_events_url":"https://api.github.com/users/bennlich/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T01:42:34Z","updated_at":"2015-04-07T01:42:34Z","body":"In reply to: https://github.com/RedfishGroup/seismogram-app/pull/12#issuecomment-90251595\r\n\r\nI think the way we currently do headless in AS is kind of a hack. I think my goal at the time was to allow AS models to run without a canvas stack while making as *few* changes to the codebase as possible (as opposed to making changes that were as *good-for-the-future-of-AS* as possible).\r\n\r\nIdeally (?) we can do away with the `headless` flag altogether; instead, the `Model` constructor would accept a `View` class (defaulting to the current one, `CanvasView`). Then making a headless model would just be a matter of passing in a `null` View (or using some parameter-alias to the same effect, maybe still going by the name `headless`).\r\n\r\nIf we agree that this where we want to go, then I think the next step is to determine what to pull out of existing AS classes (probably from more than just `Model`, but hopefully not much more) to move into a new View class. I think I started this process in this PR, but it's definitely not done. I'll look over what's left?"}}