-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircletext.pl
More file actions
30 lines (25 loc) · 880 Bytes
/
circletext.pl
File metadata and controls
30 lines (25 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/env perl
use lib "../lib";
use CAD::OpenSCAD;
circleText(text=>"Perl & OpenSCAD ",size=>10,height=>4,font=>"Times New Roman");
sub circleText{
my %params=@_;
die "no text to circleText()" unless exists $params{text};
$params{size}//=10;
$params{height}//=3;
$params{radius}//=(length $params{text})*$params{size}/6;
my $index=0;
my $output=new OpenSCAD;
my @labels=();
for (reverse split //,$params{text}){
my $label="char$index";
$output->text($_,{text=>$_,size=>$params{size},font=>$params{font}})
->linear_extrude($label,$_,$params{height})
->translate($label,[-$params{size}/2,-$params{size}/2,0,])
->rotate($label,[0,0,270])
->translate($label,[$params{radius},0,0,])
->rotate($label,180+(360*$index++/(length $params{text})));
push @labels, $label;
}
$output->build (@labels)->save("circletext")
}