new icon script

This commit is contained in:
rolux 2011-08-07 18:30:14 +00:00
parent 05112101cc
commit 59273eba79
12 changed files with 47 additions and 48 deletions

View file

@ -20,13 +20,13 @@ import sys
static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static') static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_icon(frame, timeline, icon): def render_icon(frame, timeline, icon):
icon_width = 512 icon_width = 1024
icon_height = 512 icon_height = 1024
icon_image = Image.new('RGBA', (icon_width, icon_height), (0, 0, 0, 0)) icon_image = Image.new('RGBA', (icon_width, icon_height), (0, 0, 0, 0))
frame_width = icon_width frame_width = icon_width
frame_ratio = 4 / 3 frame_ratio = 1
frame_height = int(round(frame_width / frame_ratio)) frame_height = int(round(frame_width / frame_ratio))
frame_image = Image.open(frame) if frame else Image.new('RGB', (512, 384), (0, 0, 0)) frame_image = Image.open(frame) if frame else Image.new('RGB', (1024, 768), (0, 0, 0))
frame_image_ratio = frame_image.size[0] / frame_image.size[1] frame_image_ratio = frame_image.size[0] / frame_image.size[1]
if frame_ratio < frame_image_ratio: if frame_ratio < frame_image_ratio:
frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.ANTIALIAS) frame_image = frame_image.resize((int(frame_height * frame_image_ratio), frame_height), Image.ANTIALIAS)
@ -36,13 +36,20 @@ def render_icon(frame, timeline, icon):
frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.ANTIALIAS) frame_image = frame_image.resize((frame_width, int(frame_width / frame_image_ratio)), Image.ANTIALIAS)
top = int((frame_image.size[1] - frame_height) / 2) top = int((frame_image.size[1] - frame_height) / 2)
frame_image = frame_image.crop((0, top, frame_width, top + frame_height)) frame_image = frame_image.crop((0, top, frame_width, top + frame_height))
mask_image = Image.open(os.path.join(static_root, 'png', 'icon.mask.png'))
icon_image.paste(frame_image, (0, 0)) icon_image.paste(frame_image, (0, 0))
timeline_image = Image.open(timeline) if timeline else Image.new('RGB', (512, 128), (0, 0, 0)) timeline_left = 64
timeline_image = timeline_image.resize((icon_width, 128), Image.ANTIALIAS) timeline_top = 832
icon_image.paste(timeline_image, (0, icon_height - 128)) timeline_width = 896
timeline_height = 128
timeline_image = Image.new('RGB', (timeline_width + 8, timeline_height + 8), (255, 255, 255))
mask_image = Image.open(os.path.join(static_root, 'png', 'iconTimelineOuterMask.png'))
icon_image.paste(timeline_image, (timeline_left - 4, timeline_top - 4), mask=mask_image)
timeline_image = Image.open(timeline) if timeline else Image.new('RGB', (timeline_width, timeline_height), (0, 0, 0))
timeline_image = timeline_image.resize((timeline_width, timeline_height), Image.ANTIALIAS)
mask_image = Image.open(os.path.join(static_root, 'png', 'iconTimelineInnerMask.png'))
icon_image.paste(timeline_image, (timeline_left, timeline_top), mask=mask_image)
# we're using jpegs with border-radius # we're using jpegs with border-radius
# mask_image = Image.open(os.path.join(static_root, 'png', 'icon.mask.png')) # mask_image = Image.open(os.path.join(static_root, 'png', 'iconMask.png'))
# icon_image.putalpha(mask_image) # icon_image.putalpha(mask_image)
icon_image.save(icon) icon_image.save(icon)

View file

@ -4,7 +4,7 @@
<title>{{sitename}} API</title> <title>{{sitename}} API</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" type="image/png" href="/static/png/icon.16.png"/> <link rel="shortcut icon" type="image/png" href="/static/png/icon16.png"/>
<link rel="stylesheet" type="text/css" href="/static/css/highlight.css"/> <link rel="stylesheet" type="text/css" href="/static/css/highlight.css"/>
<script type="text/javascript" src="/static/oxjs/build/jquery/jquery.js"></script> <script type="text/javascript" src="/static/oxjs/build/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/js/jquery/jquery.tmpl.min.js"></script> <script type="text/javascript" src="/static/js/jquery/jquery.tmpl.min.js"></script>

View file

@ -3,7 +3,7 @@
<head> <head>
<title>{{settings.SITENAME}}</title> <title>{{settings.SITENAME}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" type="image/png" href="/static/png/icon.16.png"/> <link rel="shortcut icon" type="image/png" href="/static/png/icon16.png"/>
<script type='text/javascript'> <script type='text/javascript'>
if(typeof(console)=='undefined') { if(typeof(console)=='undefined') {
console = {}; console = {};

View file

@ -3,12 +3,13 @@
<head> <head>
<title>{{settings.SITENAME}}</title> <title>{{settings.SITENAME}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="shortcut icon" type="image/png" href="/static/png/icon.16.png"/> <link rel="shortcut icon" type="image/png" href="/static/png/icon16.png"/>
<script type='text/javascript'> <script type='text/javascript'>
if(typeof(console)=='undefined') { if (typeof(console) == 'undefined') {
console = {}; console = {
console.log = function() {}; log: function() {}
} };
}
</script> </script>
<script type="text/javascript" src="/static/oxjs/build/jquery/jquery.js"></script> <script type="text/javascript" src="/static/oxjs/build/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/js/jquery/jquery.tmpl.min.js"></script> <script type="text/javascript" src="/static/js/jquery/jquery.tmpl.min.js"></script>

View file

@ -1,13 +1,8 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.UI = (function() { pandora.UI = (function() {
return { return {
set: function(obj) { set: function(/*{key: val} or key, val*/) {
if (arguments.length == 2) { var obj = Ox.makeObject(arguments);
// translate (key, value) to {key: value}
var obj_ = {};
obj_[arguments[0]] = arguments[1];
obj = obj_;
}
$.each(obj, function(key, val) { $.each(obj, function(key, val) {
Ox.print('key', key, 'val', val); Ox.print('key', key, 'val', val);
var i = 0, var i = 0,
@ -24,7 +19,6 @@ pandora.UI = (function() {
} }
}); });
Ox.len(obj) && pandora.api.setUI(obj); Ox.len(obj) && pandora.api.setUI(obj);
//alert('set ' + JSON.stringify(obj))
} }
} }
}()); }());

View file

@ -165,36 +165,33 @@ pandora.ui.mainMenu = function() {
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: function(event, data) {
var value = data.checked[0].id;
if (data.id == 'find') { if (data.id == 'find') {
var id = data.checked[0].id; pandora.$ui.findSelect.selectItem(value);
pandora.$ui.findSelect.selectItem(id); } else if (data.id == 'movieview') {
} else if (data.id == 'icons') { var id = document.location.pathname.split('/')[1];
if (value == 'info')
url(id + '/info');
else
url(id);
} else if (data.id == 'ordermovies') {
pandora.$ui.list.sortList(pandora.user.ui.lists[pandora.user.ui.list].sort[0].key, value == 'ascending' ? '' : '-');
} else if (data.id == 'sortmovies') {
var operator = pandora.getSortOperator(value);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.selectItem(value);
pandora.$ui.list.sortList(value, operator);
pandora.URL.set(pandora.Query.toString());
} else if (data.id == 'viewicons') {
pandora.UI.set({icons: value})
var $list = !pandora.user.ui.item ? pandora.$ui.list : pandora.$ui.browser; var $list = !pandora.user.ui.item ? pandora.$ui.list : pandora.$ui.browser;
/* /*
list.options({ list.options({
item: item:
}); });
*/ */
} else if (data.id == 'movieview') {
var view = data.checked[0].id;
var id = document.location.pathname.split('/')[1];
if (view == 'info')
url(id + '/info');
else
url(id);
} else if (data.id == 'ordermovies') {
var id = data.checked[0].id;
pandora.$ui.list.sortList(pandora.user.ui.lists[pandora.user.ui.list].sort[0].key, id == 'ascending' ? '' : '-');
} else if (data.id == 'sortmovies') {
var id = data.checked[0].id,
operator = pandora.getSortOperator(id);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.selectItem(id);
pandora.$ui.list.sortList(id, operator);
pandora.URL.set(pandora.Query.toString());
} else if (data.id == 'viewmovies') { } else if (data.id == 'viewmovies') {
var view = data.checked[0].id; url('#view=' + value);
url('#view=' + view);
} }
}, },
click: function(event, data) { click: function(event, data) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 799 B

BIN
static/png/iconMask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
static/png/iconTimeline.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB