toSVG method not working on extended class with Fabric.js
Date : March 29 2020, 07:55 AM
like below fixes the issue Every "class" in Fabric (rectangle, circle, image, path, etc.) knows how to output its SVG markup. The method responsible for it is toSVG. You can see toSVG of fabric.Rect, for example, or fabric.Text one. Since you created subclass of fabric.Rect here and didn't specify toSVG, toSVG of the next object in prototype chain is used. The next "class" in the inheritance chain happens to be fabric.Rect, so you're seeing a result of fabric.Rect.prototype.toSVG. toSVG: function() {
var label = new fabric.Text(this.label, {
originX: 'left',
originY: 'top',
left: this.left - this.width / 2,
top: this.top - this.height / 2,
fontSize: 20,
fill: '#333',
fontFamily: 'Helvetica'
});
return this.callSuper('toSVG') + label.toSVG();
}
|
DirectShow: How to get the physical address of delivery buffer return by IMediaSample::GetPointer method
Date : March 29 2020, 07:55 AM
Hope that helps You ask the address you anyway have by calling IMediaSample::GetPointer, so it appears that you already have what you ask for Output pin is responsible for memory allocator on the pin, so your decoder can use its own memory allocator with IMediaSample::GetPointer method in particular. You can use the buffers you allocate, and share with HW decoder implementation (also, you can have specific alignment there etc. or vice versa get the buffer from decoder for further use in DirectShow pipeline). I see it's Win CE, however anyway it does not seem very likely that excessive memcpy is visually slow, perhaps you have other bottlenecks as well.
|
Fabric.js Image.fromURL not working in Firefox
Tag : jquery , By : Angelo Giannatos
Date : March 29 2020, 07:55 AM
hop of those help? I figured out what was wrong. I was not passing an event to the getPointer() function. This code now works fine: $('#scene').droppable({
drop: function(e, ui) {
if ($(e.target).attr('id') === 'scene') {
var pointer = canvas.getPointer(e);
fabric.Image.fromURL(ui.draggable[0].currentSrc, function (img) {
img.filters.push(new fabric.Image.filters.Resize({scaleX: 0.2, scaleY: 0.2}));
img.set({
left: pointer.x - 20,
top: pointer.y - 20,
width: 52,
height: 52
});
canvas.clear();
canvas.add(img);
canvas.renderAll();
});
}
}
});
|
Fabric not working if not initialised in didFinishLaunchingWithOptions method
Date : March 29 2020, 07:55 AM
it helps some times I have contacted Fabric support, it seems their logic is completely based on app life cycle and it work properly if we initialise the Faric object other than didFinishLauch method.. So we ended up changing the logic in my app.. We are initialising Fabric for first time even if user not yet accepted in OptIn page, but not logging any custom events if he not opted-in. And then from the second launch it works as per his decision on OptIn page.
|
Fabric.js library Rect() method not working correctly
Date : March 29 2020, 07:55 AM
wish helps you You should use the built in fabric.js functions to calculate the mouse position over the canvas. So instead of your code just use canvas.getPointer(opt.e) this will give you the exact top and left to use. var canvas = new fabric.Canvas('c',{
backgroundColor:'#555',selection:false
});
canvas.requestRenderAll();
var crop = {
enable: false
};
var rectangle = new fabric.Rect({
originX: 'left',
originY: 'top',
fill: 'fill',
stroke: '#ccc',
strokeDashArray: [2, 2],
width: 1,
height: 1,
visible: false
});
canvas.add(rectangle);
canvas.on("mouse:down", function(o) {
var point = canvas.getPointer(o.e);
originLeft = point.x;
originTop = point.y;
rectangle.set({
left: point.x,
top: point.y,
width:1,
height:1
})
crop.enable = true;
rectangle.visible = true;
canvas.bringToFront(rectangle);
canvas.requestRenderAll();
});
canvas.on("mouse:move", function(o) {
if (crop.enable) {
var point = canvas.getPointer(o.e);
if (originLeft > point.x) {
rectangle.set({
left: Math.abs(point.x)
});
}
if (originTop > point.y) {
rectangle.set({
top: Math.abs(point.y)
});
}
rectangle.set({
width: Math.abs(originLeft - point.x),
height: Math.abs(originTop - point.y)
});
canvas.requestRenderAll();
}
});
canvas.on("mouse:up", function(options) {
crop.enable = false;
});
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas width="400" height="400" id="c"></canvas>
|