bend text

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

bend text

Thomas Leonard Gertz
I have tried this, but it doesnot make a perfect circle.
Howto?

st="Thomas Leonard Gertz";
width=140 ;
thickness=2 ;
chars=len(st)+1 ;
degrees=180 ;
for (i = [1:chars]) {
        translate([ i*width/chars,sin(i*degrees/chars)*width/2,0])
        linear_extrude(thickness)
        text(st[i-1]);
}
translate([width/2,0,0])
rotate_extrude(angle=degrees) translate([width/2,0])
square([thickness,thickness]);




-----
Thomas Leonard Gertz
Kerteminde, Danmark
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thomas Leonard Gertz
Kerteminde, Danmark
Reply | Threaded
Open this post in threaded view
|

Re: bend text

thehans
Well, the main issue is that you need a "cos" function on your x
coordinate to pair with the "sin" function on the y.  Besides that, do
you really want to only translate the letters into place, or would you
want them rotated along the curve?

I have a bearing mockup design that includes its own curved text
module which you could try if you want the letters orientation to
follow the curve:
https://www.thingiverse.com/thing:2419115/files

Hans

On Sat, Jul 7, 2018 at 9:58 AM Thomas Leonard Gertz <[hidden email]> wrote:

>
> I have tried this, but it doesnot make a perfect circle.
> Howto?
>
> st="Thomas Leonard Gertz";
> width=140 ;
> thickness=2 ;
> chars=len(st)+1 ;
> degrees=180 ;
> for (i = [1:chars]) {
>         translate([     i*width/chars,sin(i*degrees/chars)*width/2,0])
>         linear_extrude(thickness)
>         text(st[i-1]);
> }
> translate([width/2,0,0])
> rotate_extrude(angle=degrees) translate([width/2,0])
> square([thickness,thickness]);
>
>
>
>
> -----
> Thomas Leonard Gertz
> Kerteminde, Danmark
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

Thomas Leonard Gertz
I donot know why but it works without cos or sin only PI.



-----
Thomas Leonard Gertz
Kerteminde, Danmark
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thomas Leonard Gertz
Kerteminde, Danmark
Reply | Threaded
Open this post in threaded view
|

Re: bend text

cbernhardt
Something like this?
<http://forum.openscad.org/file/t1309/text_on_circle.jpg>



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

Troberg
In reply to this post by Thomas Leonard Gertz
What you do is not a circle, it's half a sine wave.

Is it something like this you want to do?

st="Thomas Leonard Gertz";
width=140 ;
thickness=2 ;
chars=len(st)+1 ;
degrees=180 ;
for (i = [1:chars]) {
        rotate([0,0,90-i*(180/chars)])
                translate([0,width/2,0])
        linear_extrude(thickness)
        text(st[i-1],halign="center");
}

rotate_extrude(angle=degrees) translate([width/2,0])
square([thickness,thickness]);



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

Troberg
I turned it into a more generic module for this (works best with fixed width
fonts):

module
circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){
       
        chars=len(mytext)+1;
       
        for (i = [1:chars]) {
                        rotate([0,0,(top?1:-1)*(degrees/2-i*(degrees/chars))])
                        translate([0,(top?1:-1)*radius-(top?0:textsize/2),0])
                        //linear_extrude(thickness)
                        text(mytext[i-1],halign="center",font=myfont,size=textsize);
        }
}

circletext("My text goes here",textsize=20,degrees=160,top=true);

circletext("Text can be underneath as
well",textsize=15,degrees=180,top=false);



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

cacb
On 2018-07-11 10:14, Troberg wrote:
> I turned it into a more generic module for this (works best with fixed
> width
> fonts):

That's a quite nice result and a general solution.

A related challenge is to position text on non-flat surfaces, e.g. like
this
https://www.thingiverse.com/thing:2054654

But then the characters must also change shape (in the general case).

Carsten Arnholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

NateTG
> But then the characters must also change shape (in the general case).

Yeah, you need plastic transforms or userland access to geometry so you can
implement them youself.

It also gets more challenging when you deal with shapes like spheres that
have intrinsic curvature.




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

shadowwynd
In reply to this post by cacb
For the specific case of a cylinder, the text can be rotated and extruded.
For sufficiently large strings of text, the effect is pretty good as is, but
each character is still a linear segment.  Intersecting with a
high-resolution cylinder gives a fairly smooth curve over the text as a
whole.

module
circletext(mytext,textsize=20,myfont="Arial",radius=100,thickness=1,degrees=360,top=true){
       
        chars=len(mytext)+1;
       
        for (i = [1:chars]) {
                       
rotate([0,0,(top?1:-1)*(degrees/2-i*(degrees/chars))])
                       
translate([0,(top?1:-1)*radius-(top?0:textsize/2),0])
                                                rotate ([90,0,0])
                        linear_extrude(thickness)
                                                text(mytext[i-1],halign="center",font=myfont,size=textsize);
        }
}

intersection() {
        cylinder (r=120, h=300, $fn=1000);
        circletext("Text can be underneath as
well",textsize=15,degrees=180,top=false, thickness=20);
}



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
jsc
Reply | Threaded
Open this post in threaded view
|

Re: bend text

jsc
One minor improvement might be to use a technique I came up with to bend an
image into a cylinder: https://www.thingiverse.com/thing:322720

Instead of rotating each character separately, render the text into a flat
"stamp", then "emboss" that into a cylinder by rotating the cylinder and
advancing the plate a small amount each time. Intersecting with the cylinder
instead of differencing against it would produce a positive model.

This has the advantage that the error can be arbitrarily minimized, and you
get whatever kerning/character spacing benefits the text system provides
instead of having each character be spaced by an identical amount.

The downside is that it is computationally complex, and I don't think it is
possible to know the horizontal extent of the text string so that has to be
approximated somehow or adjusted until appropriate.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

NateTG


I extracted text geometry from postscript and then triangulated and deformed
that in userland

This rendered in about 10 seconds.

cylindertext.stl <http://forum.openscad.org/file/t2140/cylindertext.stl>  



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

Alexander Pruss
In reply to this post by jsc
"I don't think it is possible to know the horizontal extent of the text
string"

I just wrote a library that lets you get horizontal extents of text strings
for a number of common fonts: https://www.thingiverse.com/thing:3004457



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

William Adams-2

On Mon, Jul 16, 2018 at 12:31 PM, Alexander Pruss <[hidden email]> wrote:
"I don't think it is possible to know the horizontal extent of the text
string"

I just wrote a library that lets you get horizontal extents of text strings
for a number of common fonts: https://www.thingiverse.com/thing:3004457



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: bend text

Alexander Pruss
Another way is to use Hershey fonts where you have full userland access to
the lines. I wrote a quick library that does full uv mapping of text.
https://www.thingiverse.com/thing:3010934

To fit to a circle of radius 20, do:

mapHershey("Hello World!", f="let(angle=-u*180/(PI*r),r1=r+v)
[r1*cos(angle),r1*sin(angle),0]", size=10, extraParameters=[["r",20]])
cylinder(d=1,h=5);

(The cylinder() at the end is the profile of the virtual stylus with which
the text is drawn.)





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org