Skip to content

Commit db31d56

Browse files
author
Batiste Bieler
committed
Try to convert svg into canvas... It doesn't work well.
1 parent 7f97c7a commit db31d56

File tree

6 files changed

+221
-8
lines changed

6 files changed

+221
-8
lines changed

settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
SITE_ID = 1
1717
USE_I18N = True
1818
MEDIA_ROOT = join(__dir__, 'static')
19-
MEDIA_URL = '/media/'
19+
20+
MEDIA_URL = '/static/'
2021
SECRET_KEY = 'nv8(yg*&1-lon-8i-3jcs0y!01+rem*54051^5xt#^tzujdj!c'
2122
TEMPLATE_LOADERS = (
2223
'django.template.loaders.filesystem.load_template_source',

static/characters.html

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,39 @@
77
<script src="jquery.js" type="text/javascript"></script>
88
<script src="jscolor/jscolor.js" type="text/javascript"></script>
99

10-
<canvas id="myCanvasElt" width=288 height=32></canvas>
10+
<canvas id="canvas1" width=288 height=32></canvas>
1111

1212
<input id="hair-colors" class="color" value="200,255,200">
1313

1414
<input type="button" value="Change color" id="change">
1515
<div id="" style="width:50px;height:50px"></div>
1616

17+
<br>
18+
<canvas id="canvas2" width=200 height=200></canvas>
19+
20+
21+
1722
<script>
1823

19-
var canvas = document.getElementById('myCanvasElt');
24+
var canvas2 = document.getElementById('canvas2');
25+
var ctx = canvas2.getContext('2d');
26+
ctx.translate(50,50);
27+
//ctx.save();
28+
ctx.fillStyle = "rgba(255,198,82,1)";
29+
ctx.arc(0, 0, 20, 0, Math.PI, true);
30+
ctx.quadraticCurveTo(-16, 18, 0, 20);
31+
ctx.quadraticCurveTo(16, 18, 20, 0);
32+
ctx.fill();
33+
ctx.closePath();
34+
35+
ctx.fillStyle = "rgba(255,10,10,1)";
36+
ctx.beginPath();
37+
ctx.quadraticCurveTo(0, 0, 0, 50);
38+
ctx.quadraticCurveTo(-50, 0, 10, 0);
39+
ctx.fill();
40+
41+
42+
var canvas = document.getElementById('canvas1');
2043
var ctx = canvas.getContext('2d');
2144
var canvasData = ctx.createImageData(canvas.width, canvas.height);
2245
var cdata = canvasData.data;

static/face.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<html><body><div style='text-align:center;' width='100%' height='1054'><canvas id='ctx1265906275097' width='744' height='1052'>Your browser does not support the &lt;CANVAS&gt; element !</canvas><script>/* generated with svg2canvas by Pierre Lindenbaum http://plindenbaum.blogspot.com [email protected] */function paint1265906275097(){var canvas=document.getElementById('ctx1265906275097');if (!canvas.getContext) return;var c=canvas.getContext('2d');c.fillStyle="white";c.strokeStyle="black";c.globalAlpha="1.0";c.lineWidth="1";c.lineCap="butt";c.lineJoin="round";c.mitterLimit="1";c.font="normal normal 12 Courier";c.setTransform(1.3696999,0.0,0.0,1.6243031,-362.68286,-223.3787);c.fillStyle="#ffde84";c.strokeStyle="#000000";c.lineWidth="1";c.lineJoin="miter";c.beginPath();c.moveTo(395.47,207.12);c.bezierCurveTo(355.59,285.37,273.73,337.94,180.73,345.03);c.bezierCurveTo(87.73,352.11,-2.28,312.64,-55.39,241.47);c.bezierCurveTo(-108.51,170.30,-116.66,78.25,-76.77,0.00);c.lineTo(-76.77,0.00);c.bezierCurveTo(-76.77,-39.33,-42.40,-71.22,-0.00,-71.22);c.bezierCurveTo(42.40,-71.22,76.77,-39.33,76.77,0.00);c.closePath();c.fill();c.stroke();c.setTransform(1.0,0.0,0.0,1.0,0.0,0.0);c.setTransform(0.93521279,0.0,0.0,0.82648487,-283.74858,-18.336492);c.fillStyle="#ffffff";c.strokeStyle="black";c.lineWidth="1";c.lineJoin="round";c.beginPath();c.moveTo(485.88,173.28);c.bezierCurveTo(446.28,347.54,297.27,450.01,153.06,402.16);c.bezierCurveTo(8.84,354.31,-75.96,174.26,-36.37,0.00);c.lineTo(-36.37,0.00);c.bezierCurveTo(-36.37,-24.27,-20.08,-43.94,0.00,-43.94);c.bezierCurveTo(20.08,-43.94,36.37,-24.27,36.37,0.00);c.closePath();c.fill();c.stroke();c.setTransform(1.0,0.0,0.0,1.0,0.0,0.0);c.setTransform(0.41860464,0.0,0.0,0.45454546,-34.638825,46.828241);c.fillStyle="#333333";c.beginPath();c.moveTo(455.58,176.56);c.bezierCurveTo(424.76,263.80,350.79,327.59,261.54,343.90);c.bezierCurveTo(172.29,360.21,81.32,326.56,22.89,255.62);c.bezierCurveTo(-35.54,184.69,-52.54,87.24,-21.72,0.00);c.lineTo(NaN,NaN);c.closePath();c.fill();c.stroke();c.setTransform(1.0,0.0,0.0,1.0,0.0,0.0);c.setTransform(0.89354612,0.0,0.0,0.82648487,-319.31716,-17.380783);c.fillStyle="#ffffff";c.beginPath();c.moveTo(485.88,173.28);c.bezierCurveTo(446.28,347.54,297.27,450.01,153.06,402.16);c.bezierCurveTo(8.84,354.31,-75.96,174.26,-36.37,0.00);c.lineTo(-36.37,0.00);c.bezierCurveTo(-36.37,-24.27,-20.08,-43.94,0.00,-43.94);c.bezierCurveTo(20.08,-43.94,36.37,-24.27,36.37,0.00);c.closePath();c.fill();c.stroke();c.setTransform(1.0,0.0,0.0,1.0,0.0,0.0);c.setTransform(0.41860464,0.0,0.0,0.45454546,-85.187075,47.818092);c.fillStyle="#333333";c.beginPath();c.moveTo(455.58,176.56);c.bezierCurveTo(424.76,263.80,350.79,327.59,261.54,343.90);c.bezierCurveTo(172.29,360.21,81.32,326.56,22.89,255.62);c.bezierCurveTo(-35.54,184.69,-52.54,87.24,-21.72,0.00);c.lineTo(NaN,NaN);c.closePath();c.fill();c.stroke();c.setTransform(1.0,0.0,0.0,1.0,0.0,0.0);c.fillStyle="#ff0000";c.strokeStyle="#000000";c.lineWidth="1.53083968";c.lineJoin="miter";c.beginPath();c.moveTo(207.38,129.79);c.bezierCurveTo(65.89,84.40,123.16,57.88,123.16,57.88);c.lineTo(207.38,129.79);c.closePath();c.fill();c.stroke();c.lineWidth="1.14557302";c.beginPath();c.moveTo(213.96,102.10);c.bezierCurveTo(112.79,107.05,126.92,54.04,126.92,54.04);c.lineTo(213.96,102.10);c.closePath();c.fill();c.stroke();c.beginPath();c.moveTo(55.91,120.50);c.bezierCurveTo(64.72,21.13,160.69,56.11,160.69,56.11);c.lineTo(55.91,120.50);c.closePath();c.fill();c.stroke();c.beginPath();c.moveTo(154.66,56.32);c.bezierCurveTo(161.49,114.87,72.57,104.91,72.57,104.91);c.lineTo(154.66,56.32);c.closePath();c.fill();c.stroke();c.lineWidth="1.66629374";c.beginPath();c.moveTo(78.85,69.51);c.bezierCurveTo(113.73,-11.31,209.65,90.26,209.65,90.26);c.lineTo(78.85,69.51);c.closePath();c.fill();c.stroke();}paint1265906275097();</script></div>
2+
<div><i>Author: Pierre Lindenbaum ( <a href='mailto:[email protected]'>[email protected]</a> ) <a href='http://plindenbaum.blogspot.com'>http://plindenbaum.blogspot.com</a></i></div></body></html>

static/face.svg

Lines changed: 188 additions & 0 deletions
Loading

static/svg2canvas.jar

134 KB
Binary file not shown.

urls.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
('^a/save_map', 'save_map'),
1212
('^a/effect', 'effect'),
1313
('^a/fight/new', 'fight_new'),
14+
1415
)
1516

16-
urlpatterns += patterns('django.views.static',
17-
(r'^%s(?P<path>.*)$' % settings.MEDIA_URL.lstrip('/'),
18-
'serve', {
19-
'document_root': settings.MEDIA_ROOT,
20-
'show_indexes': True })
17+
urlpatterns += patterns('',
18+
('^static/(?P<path>.*)$', 'django.views.static.serve',
19+
{'document_root': settings.MEDIA_ROOT, 'show_indexes':True}),
2120
)
2221

0 commit comments

Comments
 (0)