Skip to content
Permalink
Browse files

fix saving to `png`

  • Loading branch information...
shamansir committed Feb 26, 2019
1 parent e2ca8f8 commit d0cb5c23c308368e73e5c381e9d7d10f54615522
Showing with 23 additions and 22 deletions.
  1. +0 −1 fss.js
  2. +6 −0 gui.js
  3. +0 −14 index.html
  4. +9 −2 index.js
  5. +7 −4 src/Main.elm
  6. +1 −1 src/Navigation.elm
1 fss.js
@@ -18,7 +18,6 @@ require('flat-surface-shader/source/Math');
//}

function buildFSS(model, fss, source) {
console.log(model.size, fss.faces);
var palette = model.palette;

var scene = new FSS.Scene();
6 gui.js
@@ -339,6 +339,10 @@ function start(document, model, constants, funcs) {
}
});

switchMode = (mode) => {

};


// const textBlend = gui.add(config, 'textBlend', HTML_BLENDS);
// textBlend.onFinishChange((value) => {
@@ -356,6 +360,8 @@ function start(document, model, constants, funcs) {
// layers.map((layer, index) => {
// gui.addFolder()
// });

return { config, update };
}

module.exports = start;
@@ -6,20 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="js-animation"></div>
<canvas id="js-save-buffer"></canvas>
<div class="hide-on-space">
<div id="patch-target"></div>
</div>
<div id="export-target">
<a href="#" id="close-export">Close</a>
<textarea id="export-code" readonly></textarea>
</div>
<div id="import-target">
<a href="#" id="close-import">Close</a>
<textarea id="import-code"></textarea>
<a href="#" id="import">Import</a>
</div>
<script async src="app.js"></script>
</body>
</html>
@@ -275,7 +275,7 @@ setTimeout(() => {

if (!model.mode || (model.mode.substring(0, 4) != 'tron')) {

startGui(
const { config, update } = startGui(
document,
model,
constants,
@@ -296,7 +296,7 @@ setTimeout(() => {
, changeHtmlBlend : (index, blend) =>
{ app.ports.changeHtmlBlend.send({ layer: index, value: blend }) }
, changeProduct : (id) =>
{ app.ports.changeProduct.send(id) }
{ console.log('change product to', id); app.ports.changeProduct.send(id) }
, resize : (value) => {
console.log('resize', value);
app.ports.resize.send(
@@ -346,6 +346,13 @@ setTimeout(() => {
{ app.ports.applyRandomizer.send(prepareModelForImport(value)); }
});

app.ports.pushUpdate.subscribe((data) => {
// console.log('push update received', data);
config.product = data.product;
// TODO: apply the mode change in GUI and so change the size selection
update();
});

}

model.layers.forEach((layer, index) => {
@@ -10,7 +10,7 @@ import Task exposing (Task)
import Browser.Dom as Browser
import Browser.Events as Browser

import Html exposing (Html, text, div, span, input)
import Html exposing (Html, text, div, span, input, canvas)
import Html.Attributes as H
exposing (class, width, height, style, class, type_, min, max, value, id)
-- import Html.Events exposing (on, onInput, onMouseUp, onClick)
@@ -524,7 +524,8 @@ update msg model =

getPushUpdate : Model -> PushUpdate
getPushUpdate model =
{ size = encodeSizeRule model.size
{ size = getRuleSize model.size |> Maybe.withDefault ( -1, -1 )
, sizeRule = encodeSizeRule model.size
, product = Product.encode model.product
, coverSize = Product.getCoverTextSize model.product
, background = model.background
@@ -1077,7 +1078,8 @@ view model =
-- (config |>
-- Controls.controls numVertices theta)
--:: WebGL.toHtmlWith
[ mergeHtmlLayers model |> div [ H.class "html-layers" ]
[ canvas [ H.id "js-save-buffer" ] [ ]
, mergeHtmlLayers model |> div [ H.class "html-layers" ]
, if model.controlsVisible
then ( div
[ H.class "overlay-panel import-export-panel hide-on-space" ]
@@ -1248,7 +1250,8 @@ port changeHtmlBlend :
-- OUTGOING PORTS

type alias PushUpdate =
{ size: String
{ size: ( Int, Int )
, sizeRule : String
, product: String
, coverSize: Size
, background: String
@@ -82,7 +82,7 @@ onUrlRequest req = NoOp

decodeFragment : String -> FragmentData
decodeFragment str =
Debug.log "apply size" <| case String.split "/" str of
case String.split "/" str of
modeStr::ruleStr::_ -> ModeAndSizeRule (decodeMode modeStr) (decodeSizeRule ruleStr)
modeOrRule::_ ->
case tryDecodingMode modeOrRule of

0 comments on commit d0cb5c2

Please sign in to comment.
You can’t perform that action at this time.