Git Product home page Git Product logo

fabric.curvedtext's Introduction

fabric.curvedtext's People

Contributors

adamgaskins avatar akkivaghasiya5 avatar asturur avatar dragondgold avatar effepi avatar mariavilaro avatar sikitomi avatar syrusbp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabric.curvedtext's Issues

Spacing and Radius Issue : Needs as per the canvas size.

I needs your help urgently !!!

As i am working on fabric js text feature stuck at some level

Below is the text curve made by someone
http://jsfiddle.net/EffEPi/qpJTz/

I needs to make same feature but some issue in terms of spacing.

Can i manage to space and radius accordingly the canvas area while adding text ?
for example if i put text it should take a curve according to the canvas area and then i can change manually.

As now its like just fix the area if small or big canvas its take a fixed curve and fixed spacing so if user puts big text its creating circle with very bad shape and all

Broken on Fabric 2.0

Hello,

I see you updated the code to work with fabric 2.0 beta, and it works with fabric beta, however, the newest master version does not work:

08:32:01.885 fabric.curvedText.js:39 Uncaught TypeError: Cannot set property 'backgroundColor' of undefined
at fabric.curvedText.js:39
at fabric.curvedText.js:566
08:32:01.928 jquery-git.js:3873 jQuery.Deferred exception: fabric.CurvedText is not a constructor TypeError: fabric.CurvedText is not a constructor
at HTMLDocument. (file:///C:/wamp/www/CurvedTest/index.html:46:20)
at mightThrow (http://code.jquery.com/jquery-git.js:3589:29)
at process (http://code.jquery.com/jquery-git.js:3657:12) undefined
jQuery.Deferred.exceptionHook @ jquery-git.js:3873
08:32:01.930 jquery-git.js:3882 Uncaught TypeError: fabric.CurvedText is not a constructor
at HTMLDocument. (index.html:46)
at mightThrow (jquery-git.js:3589)
at process (jquery-git.js:3657)

All the best

Support for shadows, text grouping and new line

I'm working on a little app where the user will be able to save and load saving the json string on a NoSQL DB.

Its works all right, but I'm having issues saving several text properties, like it would be shadow. This is a string of my of my test

{  
    "objects":[  
        {  
            "type":"group",
            "originX":"left",
            "originY":"top",
            "left":128.91,
            "top":-4.09,
            "width":228.41,
            "height":197.06,
            "fill":"rgb(0,0,0)",
            "stroke":null,
            "strokeWidth":1,
            "strokeDashArray":null,
            "strokeLineCap":"butt",
            "strokeLineJoin":"miter",
            "strokeMiterLimit":10,
            "scaleX":1,
            "scaleY":1,
            "angle":0,
            "flipX":false,
            "flipY":false,
            "opacity":1,
            "shadow":null,
            "visible":true,
            "clipTo":null,
            "backgroundColor":"",
            "fillRule":"nonzero",
            "globalCompositeOperation":"source-over",
            "id":"G1447269255066651",
            "objects":[  
                {  
                    "type":"curvedText",
                    "originX":"left",
                    "originY":"top",
                    "left":-51.2,
                    "top":-42.07,
                    "width":56.46,
                    "height":62.06,
                    "fill":"rgb(0,0,0)",
                    "stroke":null,
                    "strokeWidth":1,
                    "strokeDashArray":null,
                    "strokeLineCap":"butt",
                    "strokeLineJoin":"miter",
                    "strokeMiterLimit":10,
                    "scaleX":1,
                    "scaleY":1,
                    "angle":90.45,
                    "flipX":false,
                    "flipY":false,
                    "opacity":1,
                    "shadow":null,
                    "visible":true,
                    "clipTo":null,
                    "backgroundColor":"",
                    "fillRule":"nonzero",
                    "globalCompositeOperation":"source-over",
                    "id":"CT14472691661461451",
                    "text":"My",
                    "fontSize":40,
                    "fontWeight":"normal",
                    "fontFamily":"Times New Roman",
                    "fontStyle":"",
                    "lineHeight":1.16,
                    "textDecoration":"",
                    "textAlign":"left",
                    "textBackgroundColor":"",
                    "radius":"100.00",
                    "spacing":"10.00",
                    "reverse":false,
                    "effect":"curved",
                    "range":5,
                    "smallFont":10,
                    "largeFont":30
                },
                {  
                    "type":"curvedText",
                    "originX":"left",
                    "originY":"top",
                    "left":14.8,
                    "top":-98.02,
                    "width":98.91,
                    "height":195.35,
                    "fill":"rgb(0,0,0)",
                    "stroke":null,
                    "strokeWidth":1,
                    "strokeDashArray":null,
                    "strokeLineCap":"butt",
                    "strokeLineJoin":"miter",
                    "strokeMiterLimit":10,
                    "scaleX":1,
                    "scaleY":1,
                    "angle":0.41,
                    "flipX":false,
                    "flipY":false,
                    "opacity":1,
                    "shadow":null,
                    "visible":true,
                    "clipTo":null,
                    "backgroundColor":"",
                    "fillRule":"nonzero",
                    "globalCompositeOperation":"source-over",
                    "id":"CT14472691898188172",
                    "text":"ScrapBook",
                    "fontSize":40,
                    "fontWeight":"normal",
                    "fontFamily":"Times New Roman",
                    "fontStyle":"",
                    "lineHeight":1.16,
                    "textDecoration":"",
                    "textAlign":"left",
                    "textBackgroundColor":"",
                    "radius":"100.00",
                    "spacing":"10.00",
                    "reverse":false,
                    "effect":"curved",
                    "range":5,
                    "smallFont":10,
                    "largeFont":30
                }
            ]
        }
    ],
    "background":""
}

The shadow property its null, and it must be filled with the shadow left, top, right and color values. Where do I need to adjust the code for this to be saved and loaded onto the object? I can't find where to adjust the code.

Also, I'm getting an issue. When I try to group the curved elements, the position and rotation of some of the selected texts is altered.

As you can notice in the json, there's 2 curved text elements in a group. In order to achieve my desired position of the curved texts, I had to move them and rotate them around so when I select them to group them, I end up with the desired outcome.

As a final note, it would be nice to be able to write the text on several lines and that this line breaks appear correctly. I had't been able to figure out how to add this, but i'm pretty sure that when I get to find a line break, I need to increase the text group top position by the height of the letters, or something alike

Exporting then Loading from jSON causes an error

When exporting the canvas to jSON then reloading from jSON causes an error:

  • TypeError: Cannot read property 'async' of undefined

To replicate:

var canvas          = new fabric.Canvas('canvas');
var default_text = 'This is Curved Text';
$('#add-text-curved').click(function(){
var textSample = new fabric.curvedText(default_text, {
    left: 200,
    top: 200,
    fontFamily: 'arial',
    fill: '#000000'
    originX: 'center',
    hasRotatingPoint: true,
    align: 'center',
    radius: 70
});
canvas.add(textSample).renderAll();
var data = JSON.stringify(canvas)
canvas.clear();
canvas.loadFromJSON(data)

Preview here: http://jsfiddle.net/fxLqx/

Uncaught TypeError: Cannot read property 'object' of undefined

In my fabric.curvedText perfectly work in my magento application. But that same not work in prestashop 1.7.x. In core file show the error
" var fabric=global.fabric||(global.fabric={}),
extend=fabric.util.object.extend,
clone=fabric.util.object.clone;
"
Uncaught TypeError: Cannot read property 'object' of undefined.

Letter spacing issue with curved text.

Hi @EffEPi ,
Love your work on "curved text" for fabricjs. I myself was working with fabricjs for a customization design lab, and have added your plugin. But there seems to be an issue with letter spacing whenever applying some text with some stylish fonts. I tried solving the issue with changing the radius, spacing and even the following lines in the source code :
// align = (this.spacing / 1.85) * (this.text.length - 1);
// angleRadians = (curAngle * (Math.PI / 180)).toFixed(2);
but all in vein.

Can you please give me an optimal solution for this.

Loads of thanks in advance.....

Spacing between Text (any font)

While I was using a script to hat uses this library as a base, I saw that the actual Curved text comes (sometimes) with a rather weird spacing. I think this is a problem related to two/three letters in particular, such as a-i-o.

I'm not a programmer myself, so I can't really help, but I still wanted to point it out.

Hoping someone will resolve this bug.

Good day.

Reverse bug

If you use a negative radius or reverse: true, the position (only y) of the circle seems to change with every letter you add to your text-string.

Curved Text and SVG

I am facing a problem while adding svg and curved text on my canvas using fabric js 2.0.3, it replies as

"Uncaught (in promise) TypeError: Cannot read property 'fromObject' of undefined"

Rendering issue

Hi,

I noticed an issue in this great tool and don't know what to do, any help would be appreciated

The _render is method is called twice and hence the response is very slow in IE10/11 but not on all systems.

How can we improve the performance of it? It is very slow on IE10 and 11 for most of the machines on some it works fine. However, this one works fine http://jsfiddle.net/NHs8t/ on these browsers but don't know what the difference is

I would really appreciate your help..

Fahad

fabric.CurvedText errors after init

I only copy instance from index.html and past in my script js, after I see this error

fabric.curvedText.js:39 Uncaught TypeError: Cannot set property 'backgroundColor' of undefined at fabric.curvedText.js:39 at fabric.curvedText.js:566 (anonymous) @ fabric.curvedText.js:39 (anonymous) @ fabric.curvedText.js:566

script.js:100 Uncaught TypeError: fabric.CurvedText is not a constructor at window.onload (script.js:100)

Bounding Box if off

Hi EffEPi,

Nice plugin. Thanks for devoting your time to make curve text available. I have a question though, is there anyway to make the curve text fit nicely inside its bounding border/control box? Right now the text is at a lower right corner and if radius or spacing is increase or reverse is set then the text is at one place and the control box is at another place, very hard to resize/rotate...I've been looking at the code and couldn't figure out why, is that because function _calcBounds() return incorrect value?

For anyone wondering about this repo

Unfortunately the creator of this repo passed away earlier this year after an illness, which is why it hasn't been maintained

I will be attempting to update the repo to be compatible with v2 of fabric.

if anyone is interested in potentially collaborating on this, feel free to email me, address is in my profile

text is not removable nor editable

i've tried your script, its a cool idea but problem is after i add the text, it's non editable or removable the error i get is

Uncaught TypeError: Cannot call method 'indexOf' of undefined

Loading curvedText via JSON no longer works in fabricJS 1.7.3

Both the following fiddles are exactly the same apart from the version of fabricJS being used.

1.7.2 version:
http://jsfiddle.net/yynr4hu2/

1.7.3 version:
http://jsfiddle.net/v0djnj5n/

The 1.7.2. version works fine, the 1.7.3. version does not. The saving process seems fine, but when loading the JSON nothing seems to happen.

Looking at the release notes of 1.7.3 ( https://github.com/kangax/fabric.js/releases/tag/v1.7.3 ) it seems that a change to :

"Improvement: Better error managment in loadFromJSON #3586"

may be responsible. Any ideas?

Rendering curvedText

First of all thanks for this addon, I was waiting a long time for something like this.

I notice that when curvedText is active, changes like color, stroke, transparence, etc does not take effect until mouse is over selected text.

In other way, I can't aply shadow, blur, shadowoffset. in Json log appears those values, but not in canvas.

Sorry for my English, I'm a Spanish developer.

Thanks again.

Incorrect rendering after save/reload

I'm working on a small app where you can prepare a design (curved text included) on fronted which will be rendered later with nodejs.

First, thank you for the library: it is really really useful.

I noticed one small bug: The curved text is not rendered correctly after you call canvas.toJSON() and canvas.loadFromJSON() if the radius or spacing got updated.

Steps to reproduce:

  • Create a CurvedText (radius=100)
  • Update the radius to 150
  • canvas.toJSON()
  • canvas.loadFromJSON()
  • You will notice that the position of the first rendered letter is not the same as it was before saving.

http://jsfiddle.net/yrmek0es/

Thank

first letter always displaying

Why the first letter is alaways displaying.
I explain :

  • when I edit my text and remove all characters, the first one steel appears until I type another one.

Why it doesn't disappear like any other character or like in text object ?

I test it on "official" fiddle : http://jsfiddle.net/EffEPi/qpJTz/

It's not very important but it's a lit bit disturbing for users.

How to check if rendering is finished or not

I want to know when the rendering is finished for the effect?
I want to call a function on parent but _render is called multiple times, render is called before, initialize is called at the start.

Can we add any function like finished?

Curved Text Effects

Curved Text Effects :
I just try this library. It's working fine. But I can't found the solution to apply effects (curved, arc, STRAIGHT, smallToLarge, largeToSmallTop, largeToSmallBottom, bulge) to curved text.
Please help me to solve this issue.
Thanks in advance.

Curved Text / reverse curved Text direction gets changed

Hi
I am using this library for generating curved/reverse curved text, with it's initial configuration and I am getting my result rotated 90 deg.
Here is the code :

var textSample = new fabric.CurvedText("Text", {
      radius: 100,
      spacing  : 20,
      fontSize : 50,
      percentage : 10
});

and I am getting this result
screenshot from 2019-01-17 11-09-31

it's rotated to 90 deg.

Do I need any further configuration to fix this ?

can't see canvas or access canvas objects after instantiate new curvedText.

First of all thanks for the plugin. It's been a lifesaver for the application I'm creating.

I'm having a few problems with accessing the canvas or the curved text objects after they've been added. So here's an example of my code.

var canvas = new fabric.StaticCanvas('canvas');

//this works
console.log(canvas);

fabric.Image.fromURL('http://url/IMG_0007.jpg', function(oImg) {
canvas.add(oImg);
});

//still works
console.log(canvas);

topLineText = new fabric.CurvedText('Happy Birthday!',{
left: 613,
top: 0,
textAlign: 'center',
fill: '#fff',
radius: 414,
fontSize: 100,
spacing: 6,
fontFamily: 'Mystery Quest',
strokeWidth: 3,
stroke: '#3B3A30'
});
canvas.add(topLineText).renderAll();

//breaks here, returns nothing. I'm not sure how i would access the new curved text.
console.log(canvas);

//this works to get image
oImg = canvas.getObjects()[0];

//but nothing here for text
console.log( canvas.getObjects()[1]);

Any help would be appreciated. Thanks

Can't Remove Object

how to remove curvedText object ?

i use canvas.getActiveObject().remove() in another object is working , but if i use this code in curvedText not working , why ?
help me :)

Other objects lose coords if curvedText object behind them

Made my fiddle, based on original curvedText fiddle. http://jsfiddle.net/qpJTz/283/ we just can't see the circle, because he moved down. If we start dragging curvedText to the top, we'll see the circle, seems like he joined this group of letters. So in my project i'm using sendToBack function, and when i'm apply this function to curvedText objects, ALL other objects lose their coords. It's a critical bug, i counting on your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.