From 7827fe5ec72a878672a16937977eaa02d49758ca Mon Sep 17 00:00:00 2001 From: Valvin Date: Sun, 17 Sep 2017 22:25:03 +0200 Subject: [PATCH] add image using url (all image format supported by canvas) add custom canvas size --- comicgen.js | 17 ++++++++++++++--- gege.css | 7 ++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/comicgen.js b/comicgen.js index 6853eb8..26f62c9 100644 --- a/comicgen.js +++ b/comicgen.js @@ -1,8 +1,7 @@ var d = document; var cg = {}; -var w = window.innerWidth * 0.8; -var h = window.innerHeight * 0.8;; -console.log('size : ' + w + ' x ' + h); +var w = parseInt(window.innerWidth * 0.8); +var h = parseInt(window.innerHeight * 0.8); var canvas = $('#c'); canvas.attr('width',w).attr('height',h); var c = canvas[0]; @@ -11,6 +10,8 @@ var scene = new RB.Scene(c); var fontFamily = "Domestic Manners, Arial, helvetica, sans serif"; var pop = new Audio('pop.ogg'); var currentObj = null; +$('#newWidth').val(w); +$('#newHeight').val(h); scene.add( scene.rect(w, h, 'white') ); scene.update(); @@ -177,7 +178,17 @@ cg.createTextFromInput = function(e){ pop.play(); } } +cg.createImageFromInput= function(e){ + var key = e.keyCode || e.which; + var imgUrl = $('#newImgUrl').val(); + + if(key == 13){ + + cg.createImage(imgUrl); + $('#newImgUrl').val(''); + } +} cg.saveImage = function(){ var data = c.toDataURL('png'); // $.ajax({ diff --git a/gege.css b/gege.css index 3d669c1..4c9a40b 100644 --- a/gege.css +++ b/gege.css @@ -53,7 +53,7 @@ margin: 0; padding: 0; } -h1, h2 +h1, h2, h3 { text-transform: uppercase; background-color: transparent; @@ -243,3 +243,8 @@ text-decoration: underline; position: fixed; } +#newWidth, #newHeight{ + + width: 70px ; +display : inline; +}