add CreateSolidFill request

This commit is contained in:
Andrey Sidorov 2014-03-29 23:52:51 +11:00
parent f0d25c325e
commit 5b4bcbbe92

View file

@ -183,6 +183,13 @@ exports.requireExt = function(display, callback)
X.pack_stream.flush(); X.pack_stream.flush();
} }
ext.CreateSolidFill = function(pid, r, g, b, a)
{
X.seq_num++;
X.pack_stream.pack('CCSLSSSS', [ext.majorOpcode, 33, 4, pid, floatToFix(r), floatToFix(g), floatToFix(b), floatToFix(a)]);
X.pack_stream.flush();
}
ext.RadialGradient = function(pid, p1, p2, r1, r2, stops) ext.RadialGradient = function(pid, p1, p2, r1, r2, stops)
{ {
// TODO: merge with linear gradient // TODO: merge with linear gradient
@ -369,10 +376,14 @@ exports.requireExt = function(display, callback)
X.seq_num++; X.seq_num++;
var numGlyphs = glyphs.length; var numGlyphs = glyphs.length;
var imageBytes = 0; var imageBytes = 0;
for (var i = 0; i < numGlyphs; i++) var glyphPaddedLength;
//imageBytes += glyphs[i].image.length; var glyphLength;
imageBytes += xutil.padded_length(glyphs[i].image.length); for (var i = 0; i < numGlyphs; i++) {
//var paddedLength = xutil.padded_length(imageBytes); glyphLength = glyphs[i].image.length;
if (glyphLength % 4 !== 0)
throw new Error('Glyph image length must be divisible by 4!');
imageBytes += glyphLength;
}
console.log(imageBytes); console.log(imageBytes);
var len = numGlyphs * 4 + imageBytes/4 + 3; var len = numGlyphs * 4 + imageBytes/4 + 3;
// TODO: check length, use bigReq // TODO: check length, use bigReq
@ -384,10 +395,11 @@ exports.requireExt = function(display, callback)
//X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]); //X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
//console.log('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]); //console.log('CCSLLL', [ext.majorOpcode, 20, 0, len+1, gsid, glyphs.length]);
debugger;
for (i = 0; i < numGlyphs; i++) { for (i = 0; i < numGlyphs; i++) {
var id = glyphs[i].id; var id = glyphs[i].id;
console.log('============= added glyph ', id, String.fromCharCode(id)); console.log('============= added glyph ', id, String.fromCharCode(id));
X.pack_stream.pack('L', id); X.pack_stream.pack('L', [id]);
} }
for (i = 0; i < numGlyphs; i++) for (i = 0; i < numGlyphs; i++)
{ {
@ -484,6 +496,7 @@ exports.requireExt = function(display, callback)
// 11 - colormap or none // 11 - colormap or none
ext.QueryPictFormat(function(err, formats) { ext.QueryPictFormat(function(err, formats) {
console.log(formats);
for (var i=0; i < formats.formats.length; ++i) { for (var i=0; i < formats.formats.length; ++i) {
var f = formats.formats[i]; var f = formats.formats[i];
if (f[2] == 1 && f[10] == 1) if (f[2] == 1 && f[10] == 1)