Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
B
baka-fx
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Jules LEMARCHAND
baka-fx
Validations
5e34e54d
Valider
5e34e54d
rédigé
2 years ago
par
ultrakatiz
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
added star shape
parent
057ba5b0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
shape.lua
+3
-1
3 ajouts, 1 suppression
shape.lua
shape/circle.lua
+1
-1
1 ajout, 1 suppression
shape/circle.lua
shape/star.lua
+140
-0
140 ajouts, 0 suppression
shape/star.lua
avec
144 ajouts
et
2 suppressions
shape.lua
+
3
−
1
Voir le fichier @
5e34e54d
require
"baka-fx.shape.potato"
require
"baka-fx.shape.circle"
require
"baka-fx.shape.star"
shape
=
{
potato
=
potato
,
circle
=
circle
circle
=
circle
,
star
=
star
}
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
shape/circle.lua
+
1
−
1
Voir le fichier @
5e34e54d
...
...
@@ -60,4 +60,4 @@ function circle(radius, keypoints, clockwise)
end
return
str
end
\ No newline at end of file
end
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
shape/star.lua
0 → 100644
+
140
−
0
Voir le fichier @
5e34e54d
--[[
[Description]
Draws a star with bezier curves.
[Usage]
star(outradius, inradius)
star(outradius, inradius, branches)
star(outradius, inradius, branches, roundness)
star(outradius, inradius, branches, roundness, clockwise)
[Arguments]
outradius: outer radius of the star, in pixels
inradius: inner radius of the star, in pixels (default a function of outradius)
branches: number of branches, positive integer >= 2 (default 5)
roundness: roundness of the branches, between 0 and 1 (default 0)
clockwise: drawing direction, boolean (default false)
[Notes]
The star is drawn so that it always has a branch pointing straight up.
This function does not include drawing tags, only vector commands.
If no inradius is specified and there are 5 or more branches, the inradius
is set to outradius * sin(pi/2 - 2pi/n) / cos(pi/n) where n is the number
of branches. This makes it so the edges of the branches are aligned.
If no inradius is specified and there are less than 5 branches, the inradius
is set to outradius / 2.
--]]
function
star
(
outradius
,
inradius
,
branches
,
roundness
,
clockwise
)
roundness
=
roundness
or
0
branches
=
branches
or
5
branches
=
branches
>=
2
and
branches
or
5
local
halfpi
=
math.pi
/
2
local
mult
=
clockwise
and
-
1
or
1
local
alpha
=
math.pi
/
branches
inradius
=
inradius
or
(
branches
<
5
and
outradius
/
2
or
outradius
*
math.sin
(
halfpi
-
2
*
alpha
)
/
math.cos
(
alpha
))
local
inpoints
=
{}
local
outpoints
=
{}
for
i
=
1
,
branches
do
local
oa
=
(
2
*
(
i
-
1
))
*
mult
*
alpha
-
halfpi
local
ia
=
oa
+
mult
*
alpha
outpoints
[
i
]
=
{
a
=
oa
,
x
=
outradius
*
math.cos
(
oa
),
y
=
outradius
*
math.sin
(
oa
)
}
inpoints
[
i
]
=
{
a
=
ia
,
x
=
inradius
*
math.cos
(
ia
),
y
=
inradius
*
math.sin
(
ia
)
}
end
outpoints
[
branches
+
1
]
=
outpoints
[
1
]
inpoints
[
0
]
=
inpoints
[
branches
]
local
str
=
""
-- No roundness => draw straight lines
if
roundness
<
0
.
001
then
str
=
"m "
..
outpoints
[
1
].
x
..
" "
..
outpoints
[
1
].
y
..
" "
for
i
=
1
,
branches
do
local
ip
=
inpoints
[
i
]
local
op
=
outpoints
[
i
+
1
]
str
=
str
..
"l "
..
ip
.
x
..
" "
..
ip
.
y
..
" "
..
"l "
..
op
.
x
..
" "
..
op
.
y
..
" "
end
return
str
end
local
b
=
outradius
-
inradius
*
math.cos
(
alpha
)
local
hi
=
(
b
-
roundness
*
(
outradius
-
inradius
))
*
math.cos
(
halfpi
-
2
*
alpha
)
local
ho
=
roundness
*
(
outradius
-
inradius
)
*
math.tan
(
halfpi
-
2
*
alpha
)
local
beta
=
halfpi
-
alpha
local
l
=
inradius
+
(
1
-
roundness
)
*
(
outradius
-
inradius
)
for
i
=
1
,
branches
do
local
op
=
outpoints
[
i
]
local
x
=
l
*
math.cos
(
op
.
a
)
local
y
=
l
*
math.sin
(
op
.
a
)
outpoints
[
i
].
x
=
x
outpoints
[
i
].
y
=
y
outpoints
[
i
].
h1
=
{
x
=
x
+
ho
*
math.cos
(
op
.
a
-
mult
*
halfpi
),
y
=
y
+
ho
*
math.sin
(
op
.
a
-
mult
*
halfpi
)
}
outpoints
[
i
].
h2
=
{
x
=
x
+
ho
*
math.cos
(
op
.
a
+
mult
*
halfpi
),
y
=
y
+
ho
*
math.sin
(
op
.
a
+
mult
*
halfpi
)
}
local
ip0
=
inpoints
[
i
-
1
]
local
ip1
=
inpoints
[
i
]
inpoints
[
i
-
1
].
h2
=
{
x
=
ip0
.
x
+
hi
*
math.cos
(
ip0
.
a
+
mult
*
beta
),
y
=
ip0
.
y
+
hi
*
math.sin
(
ip0
.
a
+
mult
*
beta
)
}
inpoints
[
i
].
h1
=
{
x
=
ip1
.
x
+
hi
*
math.cos
(
ip1
.
a
-
mult
*
beta
),
y
=
ip1
.
y
+
hi
*
math.sin
(
ip1
.
a
-
mult
*
beta
)
}
end
inpoints
[
branches
].
h2
=
inpoints
[
0
].
h2
inpoints
[
0
].
h1
=
inpoints
[
branches
].
h1
str
=
"m "
..
outpoints
[
1
].
x
..
" "
..
outpoints
[
1
].
y
..
" "
for
i
=
1
,
branches
do
local
op0
=
outpoints
[
i
]
local
op1
=
outpoints
[
i
+
1
]
local
ip
=
inpoints
[
i
]
str
=
str
..
"b "
..
op0
.
h2
.
x
..
" "
..
op0
.
h2
.
y
..
" "
..
ip
.
h1
.
x
..
" "
..
ip
.
h1
.
y
..
" "
..
ip
.
x
..
" "
..
ip
.
y
..
" "
..
"b "
..
ip
.
h2
.
x
..
" "
..
ip
.
h2
.
y
..
" "
..
op1
.
h1
.
x
..
" "
..
op1
.
h1
.
y
..
" "
..
op1
.
x
..
" "
..
op1
.
y
..
" "
end
return
str
end
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter