Skip to content

Commit

Permalink
Updated renderings
Browse files Browse the repository at this point in the history
  • Loading branch information
henrypoydar committed Aug 5, 2009
1 parent 15e64eb commit 83c0fae
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
1 change: 1 addition & 0 deletions README.mdown
Expand Up @@ -26,6 +26,7 @@ The [Processing.js](http://processingjs.org) Javascript extension is used to dis

* Sketches to include attached images
* Separate production deploy
* Preview on creation
* Endless pagination
* Start/stop animated documents
* Image uploading
Expand Down
2 changes: 1 addition & 1 deletion _attachments/views/home.html
Expand Up @@ -6,5 +6,5 @@

<p class="about">
<b>What's going on here?</b>
This is a simple study in non-repeated form, shape, color and animation. Art from code, code from art. The <a href="http://www.processing.org">Processing</a> programming language and <a href="http://www.processingjs.org">Processing.js</a> Javascript extension are used to generate unique renderings based on template sketches. Bothe the template sketches and resulting renderings are stored in <a href="http://couchdb.apache.org/">CouchDB</a> documents. <a href="#/credits">Lots of other neat-o technologies and libraries</a> are also used here.
This is a simple study in non-repeated form, shape, color and animation. The <a href="http://www.processing.org">Processing</a> programming language and <a href="http://www.processingjs.org">Processing.js</a> Javascript extension are used to generate unique renderings based on template sketches. Both the template sketches and resulting renderings are stored as <a href="http://couchdb.apache.org/">CouchDB</a> documents. <a href="#/credits">Lots of other neat-o technologies and libraries</a> are also used here.
</p>
4 changes: 2 additions & 2 deletions _attachments/views/renderings/show.html
Expand Up @@ -4,7 +4,7 @@
</div>

<p class="caption">
<%= item.template_algorithm.name %>
<%= item.sketch.name %>
<br />
<%= timestamp %>
<br />
Expand All @@ -24,6 +24,6 @@

<div class="source_code">
<pre>
<%= item.template_algorithm.code %>
<%= item.sketch.code %>
</pre>
</div>
2 changes: 1 addition & 1 deletion lib/javascripts/application.js
Expand Up @@ -2,7 +2,7 @@ $(document).ready(function() {
$('#flash').click(function() { $(this).fadeOut('fast'); });
$('a.toggle_grid').live("click", function() { $('.overlay').toggleClass('grid'); });
$('a.toggle_palette').live("click", function() { $('ul.palette').toggle(); });
$('a.toggle_source').live("click", function() { $('.source').toggle(); });
$('a.toggle_source').live("click", function() { $('.source_code').toggle(); });

$('input.preview').live("click", function() {
$('canvas.preview').each(function() {
Expand Down
75 changes: 39 additions & 36 deletions lib/javascripts/controller.js
Expand Up @@ -196,45 +196,48 @@
var ctx = this;
var tid = ctx.params['sketch_id'];

var thumbnail_canvas = scaleCanvas($('canvas#view')[0],150,120);
var palette_canvas = scaleCanvas($('canvas#view')[0],15,12);

couchapp.db.saveDoc(
{
type: 'rendering',
created_at: new Date().toJSON(),
sketch_algorithm: {
file: APP_DATA.sketch_algorithms[tid].file,
name: APP_DATA.sketch_algorithms[tid].name,
code: $.ajax({
url: ('processing/' + APP_DATA.sketch_algorithms[tid].file),
async: false
}).responseText
},
"_attachments": {
"rendering.png": {
"content_type": "image\/png", "data": encodeCanvas($('canvas#view')[0])
},
"thumbnail.png": {
"content_type": "image\/png", "data": encodeCanvas(thumbnail_canvas)
},
"palette.png": {
"content_type": "image\/png", "data": encodeCanvas(palette_canvas)
}
},
palette: hexPaletteFromCanvas(palette_canvas)
}, {
couchapp.db.openDoc(tid, {
success: function(json) {
//console.log('stored doc: ', json)
flash = {
message: "Stored a rendering of '" + APP_DATA.sketch_algorithms[tid].name +
"' - <a href='#/rendering/" + json.id + "'>view</a>",
css_class: "success"
};
ctx.redirect('#/renderings');
//console.log(json);
var thumbnail_canvas = scaleCanvas($('canvas#view')[0],150,120);
var palette_canvas = scaleCanvas($('canvas#view')[0],15,12);
couchapp.db.saveDoc(
{
type: 'rendering',
created_at: new Date().toJSON(),
sketch: {
name: json.name,
code: json.code,
id: json._id,
revision: json._rev
},
"_attachments": {
"rendering.png": {
"content_type": "image\/png", "data": encodeCanvas($('canvas#view')[0])
},
"thumbnail.png": {
"content_type": "image\/png", "data": encodeCanvas(thumbnail_canvas)
},
"palette.png": {
"content_type": "image\/png", "data": encodeCanvas(palette_canvas)
}
},
palette: hexPaletteFromCanvas(palette_canvas)
}, {
success: function(jsonb) {
//console.log('stored doc: ', json)
flash = {
message: "Stored a rendering of '" + json.name +
"' - <a href='#/rendering/" + jsonb.id + "'>view</a>",
css_class: "success"
};
ctx.redirect('#/renderings');
}
});

}
});

});

get('#/credits', function() {
Expand Down

0 comments on commit 83c0fae

Please sign in to comment.