Compare commits

..

3 Commits

Author SHA1 Message Date
Robert Sheldon 34ce2c2d21 more tweaks but this is looking less likely 2019-09-10 02:32:18 -04:00
Robert Sheldon c23784ec08 tweak 2019-09-07 17:10:30 -04:00
Robert Sheldon e477350153 begin implementing choc stem 2019-09-07 16:59:29 -04:00
96 changed files with 5630 additions and 23420 deletions

View File

@ -1 +0,0 @@
nodejs 14.1.0

View File

@ -1,16 +0,0 @@
CHANGELOG:
V2.0.0:
* added $fa values for minkowski and shape - so you can customize how much rounding there is
* rejiggered `key.scad` pipeline for more clarity and less shapes
* implemented "3d_surface" dish - still in beta
* super cool though, you can even change the distribution of points on the surface! just make sure you use monotonically increasing functions
* created "hull" folder to house different ways of creating the overall key shape
* promoted "feature" folder to first-class folder with keytext and switch clearance as new residents
* wrote this changelog!
* implemented `$inner_shape_type`, use "flat" for less geometry or "disable" to make a completely solid key easily. didn't help render rounded keys though
* side-printed keycaps are first class! you can use the `sideways()` modifier to set up sideways keycaps that have flat sides to print on.
* it's much easier to make quick artisans now that the inside of the keycap is differenced from any additive features placed on top
* `$linear_extrude_shape` and `$skin_extrude_shape` retired in favor of `$hull_shape_type`
* added regular_polygon shape and octagonal and hexagonal key profiles
* added beta kailh choc
* Finally got ISO Enter working correctly!

View File

@ -1,675 +0,0 @@
### GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
### Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom
to share and change all versions of a program--to make sure it remains
free software for all its users. We, the Free Software Foundation, use
the GNU General Public License for most of our software; it applies
also to any other work released this way by its authors. You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you
have certain responsibilities if you distribute copies of the
software, or if you modify it: responsibilities to respect the freedom
of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the
manufacturer can do so. This is fundamentally incompatible with the
aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for
individuals to use, which is precisely where it is most unacceptable.
Therefore, we have designed this version of the GPL to prohibit the
practice for those products. If such problems arise substantially in
other domains, we stand ready to extend this provision to those
domains in future versions of the GPL, as needed to protect the
freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish
to avoid the special danger that patents applied to a free program
could make it effectively proprietary. To prevent this, the GPL
assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS
#### 0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of
an exact copy. The resulting work is called a "modified version" of
the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user
through a computer network, with no transfer of a copy, is not
conveying.
An interactive user interface displays "Appropriate Legal Notices" to
the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
#### 1. Source Code.
The "source code" for a work means the preferred form of the work for
making modifications to it. "Object code" means any non-source form of
a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users can
regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same
work.
#### 2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey,
without conditions so long as your license otherwise remains in force.
You may convey covered works to others for the sole purpose of having
them make modifications exclusively for you, or provide you with
facilities for running those works, provided that you comply with the
terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for
you must do so exclusively on your behalf, under your direction and
control, on terms that prohibit them from making any copies of your
copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the
conditions stated below. Sublicensing is not allowed; section 10 makes
it unnecessary.
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such
circumvention is effected by exercising rights under this License with
respect to the covered work, and you disclaim any intention to limit
operation or modification of the work as a means of enforcing, against
the work's users, your or third parties' legal rights to forbid
circumvention of technological measures.
#### 4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
#### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
#### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of
sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal,
family, or household purposes, or (2) anything designed or sold for
incorporation into a dwelling. In determining whether a product is a
consumer product, doubtful cases shall be resolved in favor of
coverage. For a particular product received by a particular user,
"normally used" refers to a typical or common use of that class of
product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected
to use, the product. A product is a consumer product regardless of
whether the product has substantial commercial, industrial or
non-consumer uses, unless such uses represent the only significant
mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to
install and execute modified versions of a covered work in that User
Product from a modified version of its Corresponding Source. The
information must suffice to ensure that the continued functioning of
the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or
updates for a work that has been modified or installed by the
recipient, or for the User Product in which it has been modified or
installed. Access to a network may be denied when the modification
itself materially and adversely affects the operation of the network
or violates the rules and protocols for communication across the
network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
#### 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions; the
above requirements apply either way.
#### 8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your license
from a particular copyright holder is reinstated (a) provisionally,
unless and until the copyright holder explicitly and finally
terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to
60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
#### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run
a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
#### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
#### 11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned
or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on
the non-exercise of one or more of the rights that are specifically
granted under this License. You may not convey a covered work if you
are a party to an arrangement with a third party that is in the
business of distributing software, under which you make payment to the
third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties
who would receive the covered work from you, a discriminatory patent
license (a) in connection with copies of the covered work conveyed by
you (or copies made from those copies), or (b) primarily for and in
connection with specific products or compilations that contain the
covered work, unless you entered into that arrangement, or that patent
license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
#### 12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under
this License and any other pertinent obligations, then as a
consequence you may not convey it at all. For example, if you agree to
terms that obligate you to collect a royalty for further conveying
from those to whom you convey the Program, the only way you could
satisfy both those terms and this License would be to refrain entirely
from conveying the Program.
#### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
#### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions
of the GNU General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in
detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies that a certain numbered version of the GNU General Public
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that numbered version or
of any later version published by the Free Software Foundation. If the
Program does not specify a version number of the GNU General Public
License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions
of the GNU General Public License can be used, that proxy's public
statement of acceptance of a version permanently authorizes you to
choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
#### 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
CORRECTION.
#### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively state
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper
mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands \`show w' and \`show c' should show the
appropriate parts of the General Public License. Of course, your
program's commands might be different; for a GUI interface, you would
use an "about box".
You should also get your employer (if you work as a programmer) or
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. For more information on this, and how to apply and follow
the GNU GPL, see <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your
program into proprietary programs. If your program is a subroutine
library, you may consider it more useful to permit linking proprietary
applications with the library. If this is what you want to do, use the
GNU Lesser General Public License instead of this License. But first,
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.

111
README.md
View File

@ -1,113 +1,64 @@
# Parametric Mechanical Keycap Library
![a slightly askew welcome picture](assets/welcome.png)
![Welcome!](assets/welcome.png)
This library is a keycap and keyset construction library for mechanical keyboards, written in openSCAD.
Relevant links:
* Thingiverse: https://www.thingiverse.com/thing:2783650
* Shapeways: https://www.shapeways.com/designer/rsheldiii/creations
* Buy me a coffee: https://ko-fi.com/rsheldiii, but only if you want to!
# V2.0.0 Cutover
As of February 19th, 2022, the v2.0.0 branch has been merged into master.
This branch completely rewrote key.scad to be much simpler and faster. If you're just starting out, please use master and report any bugs you find.
If you branched off this repo previously, merging to master will probably break any additions you've made. If you need the prior version of the code for whatever reason, v1.1.0 is master just before the v2.0.0 merge. I will be backporting bugfixes to the v1 branch, so if you see v1.1.1 or higher, use that instead.
## How to run
#### OpenSCAD Proper (recommended way)
#### Thingiverse Customizer
If you are technically inclined at all, this is definitely the best way to run the code. It's not very hard!
First, you'll need OpenSCAD: http://www.openscad.org/downloads.html. I highly recommend installing the development snapshot, as they generally support more features and are relatively stable. Development snapshots are listed in their own section on the downloads page.
After you have openSCAD installed, you need to download the code and run it. running `git clone https://github.com/rsheldiii/openSCAD-projects.git` if you have git, or downloading [this zip](https://github.com/rsheldiii/openSCAD-projects/archive/master.zip) and extracting the directory should do it.
To make your own key, all you need to do is open `keys.scad` with openSCAD and modify this line:
```
dcs_row(5) legend("⇪", size=9) key();
```
To be whatever you want. For example, this is for a ctrl key on an OEM keyboard:
```u(1.25) oem_row(3) legend("ctrl", size=4.5) key();```
It is possible to edit this project with an external editor by checking off Design => 'Automatic Reload and Preview' in OpenSCAD.
All examples below assume you are running the library on your computer with OpenSCAD.
The easiest (though not the best) way to run this program is to boot it up in [Thingiverse's Customizer](https://www.thingiverse.com/apps/customizer/run?thing_id=2783650). Explanations of each option are provided, as well as some default variables. Twiddle the variables to see how the keycap changes!
#### OpenSCAD Customizer
If you're not technically inclined enough to start programming in OpenSCAD (it's easier than you think), you can look into [getting OpenSCAD's customizer working](https://github.com/rsheldiii/KeyV2/wiki/Getting-the-OpenSCAD-Customizer-working).
If you find that the Thingiverse Customizer is timing out, but you're not technically inclined enough to start programming in OpenSCAD, you can look into [getting OpenSCAD's customizer working](https://github.com/rsheldiii/KeyV2/wiki/Getting-the-OpenSCAD-Customizer-working).
`customizer.scad` is auto-generated from the other files in this repository due to a quirk with how OpenSCAD shows customizer settings. It should be perpetually kept up to date, but there may be some bugs. feel free to open an issue if you find one!
#### OpenSCAD Proper
#### Thingiverse Customizer
First, you'll need OpenSCAD: http://www.openscad.org/downloads.html. I highly recommend installing the development snapshot, as they are much further along than the current stable release (as of writing, 2015.03-3).
The easiest and buggiest way to run this program is to boot it up in [Thingiverse's Customizer](https://www.thingiverse.com/apps/customizer/run?thing_id=2783650). Explanations of each option are provided, as well as some default variables. Twiddle the variables to see how the keycap changes!
After you have openSCAD installed, you need to download the code and run it. running `git clone https://github.com/rsheldiii/openSCAD-projects.git` if you have git, or downloading [this zip](https://github.com/rsheldiii/openSCAD-projects/archive/master.zip) and extracting the code should do it. Then all you need to do is open `keys.scad` with openSCAD and you are set! It is possible to edit this project with an external editor by checking off Design => Automatic Reload and Preview in OpenSCAD.
Unfortunately I don't think I can update the Thingiverse customizer without breaking it, so you don't get all the cool new features I've been developing over the past couple years.
All examples below assume you are running the library on your computer with OpenSCAD.
## High-level overview
## Let's Go! I wanna make a custom keycap!
This library supports Cherry and Alps switches, and has pre-defined key profiles for SA, DSA, DCS, G20, Hi-Pro and (some form of) OEM keycaps. `keys.scad` is the entry point for everything but the most technical use. Pre-programmed key profiles can be found in the `key_profiles` directory.
At the highest level this library supports Cherry and Alps switches, and has pre-defined key profiles for SA, DSA, DCS, G20 and (some form of) OEM keycaps. `keys.scad` is meant as an entry point for everything but the most technical use. Pre-programmed key profiles can be found at the `key_profiles` directory.
Every key starts with default settings (provided in `settings.scad`) that are overridden by each function call. The simplest key you can make would be:
Every key starts with defaults that are overridden by each function call. The simplest cherry key you can make would be:
```
key();
cherry() key();
```
![a bog-standard cherry key](assets/example1.JPG)
which is a bog-standard DCS row 5 (number / function row) keycap. To change how the key is generated, you can modify the settings directly or add predefined modifier functions like so:
which is a bog-standard DCS row 5 keycap. To change key profile or make varying width keys, you can use the row and unit length functions, like so:
```
// directly modified setting
$stem_inset = 1;
// settings changed through modifier function
sa_row(2) 2u() key();
sa_row(2) 2u() cherry() key();
```
You can chain as many modifier functions as you like!
![a 2 unit SA row 2 cherry key](assets/example2.JPG)
## Modifier functions
## What if I want to customize my keycaps?
There is a bevy of supporting functions to customize your keycaps. You can add a brim to more easily print the stem with `brimmed_stem_support`, make 2x2 keycaps with `2u() 2uh()`, add legends, rotate stems, and more. All these functions manipulate the settings available to you in [`settings.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/settings.scad), though [some of them](https://github.com/rsheldiii/KeyV2/blob/851ececdb297c77bfbcd0a7cb4cdbc5e21970396/src/key_transformations.scad#L128) are quite complex.
These modifier functions can be found in [`key_profiles/`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_profiles) for different keycap profiles, [`key_types.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_types.scad) for predefined settings for common keys (spacebar, left shift, etc), [`key_sizes.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_sizes.scad) for common unit sizes, and [`key_transformations.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/key_transformations.scad) for everything else. I encourage you to do some sleuthing but for a list of (most) helper functions with explanations, [Check out the wiki!](https://github.com/rsheldiii/KeyV2/wiki/KeyV2-Helper-Documentation)
These modifier functions may not cover every use case; in that case, you may have to write some SCAD yourself.
## Layouts
new to the library and still in a beta state, layouts allows you to generate an entire layout for a keyboard!
It is recommended to print layouts with a brim that extends to the next key.
```
60_percent_default("dcs") key();
```
![a standard 60 percent layout](assets/layout.png)
layouts accept children, so you can use them as a chained function like other modifiers. Be wary of accidentally overriding something the layout does for you though.
There is a bevy of supporting functions to customize your keycaps. You can add a brim to more easily print the stem, switch up the stem support type, make 2x2 keycaps for a POS system, add legends, rotate stems, and more. These functions can be found in `key_profiles/`, `key_sizes.scad`, `key_transformations.scad`, and `key_types.scad` currently, and can be referenced directly in `keys.scad`. For a full list of helper functions with explanations, [Check out the wiki!](https://github.com/rsheldiii/KeyV2/wiki/KeyV2-Helper-Documentation)
#### Example customizations
Let's say you wanted to generate some 2u stabilized keycaps for an Ergodox, you could do something like this:
If you wanted to generate some 2u stabilized keycaps for an Ergodox for instance, you could do something like this:
```
legends = ["Enter", "Escape", "Tab", "Shift"];
for(y=[0:3]) {
translate_u(0,y) 2u() dsa_row() stabilized() cherry() legend(legends[y], [0,0, 6]) key();
translate_u(0,y) 2u() dsa_row() stabilized() cherry() key(inset=true) { keytext(legends[y], [0,0], 6); }
}
```
@ -127,21 +78,19 @@ cherry() key() {
Artisan support also supports _subtracting_ children by doing `key(inset=true) { ... }`, which is super helpful if you want to make keycaps with legends that are not text. The children will be placed just above the middle of the dish as per usual; you will need to translate them downwards (`ex translate([0,0,-1])`) to get them to 'dig in' to the top of the key.
## Tips and tricks
Looking for information or something specific? you could try checking out the [tips and tricks](TIPS_AND_TRICKS.md) section, or the [examples](/examples) directory.
## What if I want to get _really_ technical?
At the base level this library should function well as a key profile design library. by loading up `src/key.scad` (notice no s) you can tweak variables in `src/settings.scad` to prototype your own profiles. There are currently 44 different settings to tweak in `src/settings.scad` including width height and depth of the keycap, dish tilt, top skew, fonts, wall thickness, etc. If you want to see the full list of settings, feel free to browse the file itself: [settings.scad](https://github.com/rsheldiii/KeyV2/blob/master/src/settings.scad) it has lots of comments to help you get started.
### What if I want to get _even_ more technical than that?
Now we're talkin!
At the base level this project should function well as an intensive key profile design library. by loading up `src/key.scad` (notice no s) you can tweak variables in `src/settings.scad` to prototype your own profiles. `key.scad` There are currently ~~44~~ a lot of different settings to tweak in `src/settings.scad` including width height and depth of the keycap, dish tilt, top skew, fonts, wall thickness, etc. If you want to see the full list of settings, feel free to browse the file itself: [settings.scad](https://github.com/rsheldiii/KeyV2/blob/master/src/settings.scad) it has lots of comments to help you get started.
This library should also be abstract enough to handle new dish types, keystems, key layouts, key profiles, and key shapes, in case you want to design your own Typewriter-style keycaps, support buckling spring keyboards or design some kind of triangular dished profile. `src/shapes.scad` `src/stems.scad` and `src/dishes.scad` all have a 'selector' module that should allow you to implement your own creations alongside what already exists in their constituent folders.
This library should be abstract enough to handle new dish types, keystems, and key shapes, in case you want to design your own Typewriter-style keycaps, support buckling spring keyboards or design some kind of triangular dished profile. `src/shapes.scad` `src/stems.scad` and `src/dishes.scad` all have a 'selector' module that should allow you to implement your own creations alongside what already exists in their constituent folders.
If you're interested in this, it may help to read the [Technical Design of a keycap](https://github.com/rsheldiii/KeyV2/wiki/Technical-Design-of-a-Keycap) wiki page.
Here's an example of tweaking the settings and code to make a 'stop sign' key profile:
Here's an example of tweaking the settings and code to make a 'stoinstancep sign' key profile:
In `key_shape()` in `shapes.scad`:
@ -189,7 +138,7 @@ Prints from this library are still challenging, despite all efforts to the contr
1. If your stem isn't fitting in the switch, try upping the slop factor, accessed by giving your keystem function a numeric value (eg `cherry(0.5) key()`). This will lengthen the cross and decrease the overall size of the keystem. The default value is 0.3, and represents millimeters. Note that even if you have a resin printer, you should probably keep the default value; keys printed with 0 slop will barely fit on the stem.
2. If your keystem breaks off the bed mid-print, you can enable a brim by adding the `brimmed_stem_support()` modifier. This will give a solid base for the keystem to anchor into.
2. If your keystem breaks off the bed mid-print, you can enable a brim by adding the `brimmed()` modifier. This will give a solid base for the keystem to anchor into.
3. If you are unsatisfied with the quality of the top surface, you can try printing the keycap on a different surface than the bottom, though it may impact the quality of the stem.
@ -198,8 +147,6 @@ Prints from this library are still challenging, despite all efforts to the contr
That's it, if you have any questions feel free to open an issue or leave a comment on thingiverse!
## TODO:
moved to [TODO doc](./TODO.md)
## Contributions welcome
My lists of key profiles and layouts are not exhaustive at all, if you want to contribute feel free to make a PR with your changes and we can work together on getting it merged!
* replace linear_extrude_shape_hull with skin_extrude_shape_hull or something, to enable concave extrusions
* replace current ISO enter shape with one that works for `skin()`
* generate dishes via math?

View File

@ -1,73 +0,0 @@
# WIP Tips and Tricks section
just want to make sure I put this here, I'm going to make this a much better document later
## Fully sculpted caps
Fully sculpted keycaps are caps that also tilt inwards / outwards, cupping your fingers a bit.
Most profiles should support this now; you pass in a "column" value after the row value, and the cap will calculate how much extra height and tilt for that column.
the way this works is the program projects a large, imaginary cylinder that it inscribes the top of the keycaps into. Thus, the height and tilt can be tweaked by changing the `$double_sculpt_radius`, which changes the radius of that imaginary cylinder.
At the end of the day though, all the columnular sculpting is doing is adding extra height and y tilt to the top of the key. if you have some other aim than fitting to a cylinder you can control this directly with appropriate changes to `$top_tilt_y` and `$total_depth`, or perhaps changing the `side_tilt()` and `extra_side_tilt_height()` functions in [`functions.scad`](https://github.com/rsheldiii/KeyV2/blob/master/src/functions.scad) which are what the row profiles use.
## skin mode
SA, HiPro and DSA keycaps take _forever_ to render. This is a multifaceted issue that I don't want to get into here, but suffice to say _one_ of the reasons it takes so long is how the keycap is constructed from multiple, smaller slices. OpenSCAD takes more time to render the more objects you have, regardless of how they interact. Enter `$hull_shape_type = "skin"`.
`skin()` is a list comprehension function available [here](https://github.com/openscad/list-comprehension-demos/blob/master/skin.scad). The gist of it is that instead of having x number of keycap slices unioned together, we give `skin()` a set of profiles and it makes a single object out of it for us. This reduces the number of objects per keycap, which makes it easier to render them.
One current limitation of `skin()` is that I suck at math and can't translate [rounded_square](https://github.com/rsheldiii/KeyV2/blob/master/src/shapes/rounded_square.scad) into a function, which means that we miss out on the very nice bowing exhibited on these profiles. once we can translate that to math however, we'll be in business.
## Printing upside down
still in beta, but using `upside_down()` in a method chain will rotate keycaps to be upside down. This makes the stem print better and requires no support, but generally the top of the keycap comes out worse - unless it is flat. Worth noting that you can probably set `$stem_inner_slop` to 0 if you print upside down - elephant's foot is the largest contributor to stems not fitting correctly.
### "doubleshot" letters with a regular printer
While printing upside down, you can do yourself a favor and embed some legends! use code like below:
```
legends = ["F1", "1", "q", "a", "z", ""];
for (x = [0:1:4]) {
translate_u(0,-x) legend(legends[x]) g20_row(3, 0) upside_down() {
$stem_support_type = "disable";
key(true);
dished() {
legends($inset_legend_depth);
}
}
}
```
and comment out either `key(true)` or the whole `dished` segment. This code generates keycaps with inset legends and the legends that fit inside those insets.
Run just the legends through your slicer first and make sure to turn off anything like skirts or brims, it should print your legends in a single layer on your print bed. Leave them there, swap filaments, and then print the rest of the keycaps around them in a different color. The result is pretty impressive. They aren't quite doubleshot, since the main benefit of doubleshots is the plastic goes all the way through the keycap, but they look incredibly impressive for what they are.
### No stem support
If you're printing updside down you'll want to disable stem supports. you can change the `$stem_support_type`, or just use the `no_stem_support()` modifier function
## front print legends and location / font size
still in beta, set `$front_print_legends = true` to have legends print on the front instead of the top of the keycaps.
## Clearance check
doing some funky stuff and want to make sure your keycap won't hit the keyswitch? set `$clearance_check = true` and a red-colored depressed switch will show up in preview, cutting away at what contacts the switch.
## Envelope
the 'envelope' of a keycap is used to clip geometry - most notably the dishing at the top of the keycap. if something doesn't look right, you can drop `%envelope()` right next to `key()` to see if it's the envelope cutting things off:
```
g20_row() legend("Q", [0,0], 3) {
key();
%envelope();
}
```
## stem inset
If you want the more refined top surface that printing upright brings, but you are having a bad time with elephant's foot, you can enable some `$stem_inset` and see if that helps. you'll have to figure out what support works best for you.

13
TODO.md
View File

@ -1,13 +0,0 @@
TODO:
* implement key_shape_at_progress which allows you to query for the exact 2d outline of the keycap at a given height
* this makes certain functions easier - building the envelope for instance
* requires breaking out shape_slice, and creating a polygon of the skin_shape_slice slices
* dishes add / remove height from keycaps, particularly spherical dishes
* a bandaid solution would be to allow you to modify where the keytop is along the progression of the keycap
* you can't just set a new total_depth because of how width_difference and height_difference work
* the true solution would be to rewrite how the dishes work to make them very graduated at the edges
* implement regular polygon for skin extrusions
* switch to skin-shaped extrusions by default
* kailh choc has a non-square key unit; should I get that working for layouts etc?
* move everything over to layouts requiring a child key
* add an "errors" or "warnings" or "suggestions" echo section in key.scad, right when the key is being made, so the errors don't get lost / repeated

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 MiB

After

Width:  |  Height:  |  Size: 41 KiB

File diff suppressed because it is too large Load Diff

View File

@ -11,8 +11,6 @@ row = 1; // [5,1,2,3,4,0]
// What does the top of your key say?
legend = "";
$using_customizer = true;
include <src/settings.scad>
include <src/key_sizes.scad>
@ -20,7 +18,8 @@ include <src/key_profiles.scad>
include <src/key_types.scad>
include <src/key_transformations.scad>
include <src/key_helpers.scad>
include <src/key.scad>
use <src/key.scad>
key_profile(key_profile, row) legend(legend) {
key();

View File

@ -1,32 +0,0 @@
include <../includes.scad>
/* here's how to use the legends() command.
The first argument is the legend itself, which can also be a whole string.
The second argument is the "position" of the legend relative to center.
Legends currently have to all be inset or outset at the same time, but you
can have as many of them as you want.
The numbers used are some magic constant, so just fudge them until it looks good.
*/
/* $outset_legends = true; */
legends = [
["a", "b", "c", "d"],
["e", "f", "g", "h"],
["i", "j", "k", "l"],
];
$font_size = 4;
for (x=[0:len(legends)-1]) {
translate_u(x,0) {
legend(legends[x][0], [-1,-1]) {
legend(legends[x][1], [-1,1]) {
legend(legends[x][2], [1,-1]) {
front_legend(legends[x][3]) {
key();
}
}
}
}
}
}

View File

@ -1,29 +0,0 @@
include <../includes.scad>
/* use this file to generate multimaterial models for making keycaps with a
different material for the key top.
This would be great to use with flexible filament, to make squishy-topped
keys.
You don't need a multimaterial printer to use these files since it's hard
height cutoff. You could print the bottom, leave the prints on the bed, and
then print the top in a different material. Be careful though! your start
gcode may crash into the prints.
*/
depth = 1;
// swap the debug()s to render opposite part
/* debug() */ difference() { // intersection() {
key();
top_of_key() {
translate([-total_key_width(),-total_key_height(),-$total_depth - depth]) cube([total_key_width()*2, total_key_height()*2, $total_depth]);
}
}
debug() intersection() {
key();
top_of_key() {
translate([-total_key_width(),-total_key_height(),-$total_depth - depth]) cube([total_key_width()*2, total_key_height()*2, $total_depth]);
}
}

View File

@ -1,16 +0,0 @@
include <../includes.scad>
/* in this example we'll use some openSCAD to generate files for printing inset
legends with a multimaterial printer.
*/
legends = ["F1", "1", "q", "a", "z", ""];
for (x = [0:1:4]) {
translate_u(0,-x) legend(legends[x]) dcs_row(x, 0) {
// swap the debug()s to render opposite part
debug() key(true);
/* debug() */ dished() {
legends($inset_legend_depth);
}
}
}

View File

@ -1,6 +0,0 @@
include <../includes.scad>
// plates are currently generated via the same layout arrays as layouts are.
// just pass the layout to plate() and it'll do it's job using hull().
// still in beta
plate(60_percent_default_layout);

View File

@ -1,28 +0,0 @@
include <../includes.scad>
/* Printing keycaps on their side is an easy way to get a nice, smooth top
surface, with some caveats:
1. one of the sides won't look as good as the other
2. any amount of top tilt makes the sides of the keycap not flat, so we have
to force them to be flat by making the keytop a trapezoid
sideways() does the magic for you.
Note that this won't work at all with side sculpted keycaps, skin_shape_hull,
and double sculpted aka full sculpted keycaps either. Getting it to work with
skin_shape_hull is the easiest, getting it to work with full sculpting is a
lot harder, and side sculpting is obviously impossible by nature
*/
legends = ["F1", "1", "q", "a", "z"];
for (x = [0:4]) {
translate_u(0,-x) dcs_row(x) sideways() front_legend(legends[x], size=5) {
$stem_support_type = "disable";
$dish_type = "disable";
/* $top_tilt = 30; */
union() {
key();
}
}
}

View File

@ -1,53 +0,0 @@
include <../includes.scad>
/*
In this example, we harness full sculpting and simple_layout to make a set of SA
keys that look a lot like the key wells on a dactyl, dactyl manuform, or kinesis
SA keys render faster with skin_extrude_shape = true, but then they don't get
the nice flaring on the sides... yet.
*/
// to turn on full sculpting
$double_sculpted = true;
// to make the font fit
$font_size = 4;
// change this to make the full sculpting more or less aggressive. 200 is default
$double_sculpt_radius = 200;
// This is the exact column stagger from the dactyl transposed onto the
// rows of the preonic default layout. the second array is for modifying the
// values up or down - making all the 0's -1's would make each key 1mm lower
// for instance. I'd suggest going as low as you can without cutting off any stems
extra_column_height = [5.64, 5.64, 0, -3, 0, 0, 0, 0, 0, -3, 0, 5.64, 5.64] + [0,0,0,0,0,0,0,0,0,0,0,0,0];
// required for double_sculpted_column
row_length = len(preonic_default_layout[0]);
simple_layout(preonic_default_layout) {
// this union is here because, for some reason, you cannot modify special variables
// that are modified in the scope directly above.
union() {
// row declarations treat column 0 as perfectly center, so if we just used
// $column we'd have a ridiculously looking left-leaning keyboard.
// this function transforms the actual column value into a "2hands" column
// value, aka for a board with 2 "keywells", one for each hand
column_value = double_sculpted_column($column, row_length, "2hands");
/* echo("column value", column_value); */
sa_row($row+1, column_value){
// uh oh, now I need two of them...
union() {
// uncomment when prototyping for faster prototypes!
/* $dish_type = "disable"; */
/* $stem_support_type = "disable"; */
// here's where the magic happens and we actually add the extra column height
$total_depth = $total_depth + extra_column_height[$column];
key();
// this generates separate legends for the keys
/* legend(preonic_default_legends[$row][$column]) legends(); */
}
}
}
}

View File

@ -1,34 +0,0 @@
include <../includes.scad>
/* Don't have a multimaterial printer but still want cool "doubleshot" legends?
with a couple tricks, you can! We just have to print upside down with no
dish.
Here's how to use this file:
1. modify it as you see fit
2. render the legends and the keycaps separately
3. run the legends through your 3d printer. make sure they are a single layer
4. LEAVE THEM on the bed
5. change filaments
6. run the keycaps over the legends. MAKE SURE they line up! PrusaSlicer
centers models on the bed
7. voila!
8. use a powder-coated bed for extra points
*/
legends = ["F1", "1", "q", "a", "z", ""];
for (x = [0:1:4]) {
translate_u(0,-x) dcs_row(x, 0) upside_down() legend(legends[x]) {
$dish_type = "disable";
$inset_legend_depth = 0.2; // whatever layer height you use
union() {
// swap the debug()s to render opposite part
debug() key(true);
/* debug() */ dished() {
legends($inset_legend_depth);
}
}
}
}

0
gulpfile.js Normal file → Executable file
View File

View File

@ -1,9 +0,0 @@
use <src/key.scad>
include <src/settings.scad>
include <src/key_sizes.scad>
include <src/key_profiles.scad>
include <src/key_types.scad>
include <src/key_transformations.scad>
include <src/key_helpers.scad>
include <src/key_layouts.scad>

View File

@ -5,16 +5,24 @@
// without having to rely on this file. Unfortunately that means setting tons of
// special variables, but that's a limitation of SCAD we have to work around
include <./includes.scad>
use <src/key.scad>
include <src/settings.scad>
include <src/key_sizes.scad>
include <src/key_profiles.scad>
include <src/key_types.scad>
include <src/key_transformations.scad>
include <src/key_helpers.scad>
// example key
dcs_row(5) legend("⇪", size=9) key();
// example row
/* for (x = [0:1:4]) {
translate_u(0,-x) dcs_row(x) key();
} */
u(1) choc() {
flared_support() tined_stem_support() sa_row(1){
$stem_support_height = 2;
low_profile() {
key();
}
}
}
// example layout
/* preonic_default("dcs") key(); */
/* translate_u(1,0) u(1) choc() row_profile("oem") low_profile() key(); */

36
keysets.scad Normal file
View File

@ -0,0 +1,36 @@
/*use <key.scad>*/
// NEED to include, not use this, even with the default variables set. don't know why
include <keys.scad>
60_percent = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,2],
[1.5,1,1,1,1,1,1,1,1,1,1,1,1,1.5],
[1.75,1,1,1,1,1,1,1,1,1,1,1,2.25],
[2.25,1,1,1,1,1,1,1,1,1,1,2.75],
[1.25,1.25,1.25,6.25,1.25,1.25,1.25,1.25]
];
function sum(list, x=0) =
len(list) <= 1 ?
x + list[0] :
sum([for (x = [1: len(list) - 1]) list[x]], x+list[0]);
for (row = [0:len(60_percent)-1]){
for(column = [0:len(60_percent[row])-1]) {
columnDist = sum([for (x = [0 : column]) 60_percent[row][x]]);
a = 60_percent[row][column];
translate_u(columnDist - (a/2), -row) g20_row(3) u(a) cherry() { // (row+4) % 5 + 1
if (a == 6.25) {
spacebar() key();
} else if (a == 2.25) {
lshift() key();
} else if (a == 2) {
backspace() key();
} else if (a == 2.75) {
rshift() key();
} else {
key();
}
}
}
}

View File

@ -5,10 +5,12 @@ module OpenSCAD
Dir.chdir File.dirname(filename)
lines = lines.flat_map do |line|
# please note we do not implement `use` at all
if line =~ /(include|use)\s*<(.*)>/
# File.readlines("./#{$2}")
expand("./#{$2}")
# in lieu of actually implementing `use`, we can just cull this final line from key.scad
elsif line =~ /example\_key\(\);/
""
else
line
end

4410
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,9 +23,9 @@
"dependencies": {
"gulp-changed": "^3.2.0",
"gulp-changed-in-place": "^2.3.0",
"gulp-shell": "^0.8.0"
"gulp-shell": "^0.6.5"
},
"devDependencies": {
"gulp": "4.0.2"
"gulp": "github:gulpjs/gulp#4.0"
}
}

View File

@ -1,4 +1 @@
// a safe theoretical distance between two vertices such that they don't collapse. hard to use
SMALLEST_POSSIBLE = 1/128;
$fs=0.1;
$unit=19.05;

View File

@ -4,10 +4,6 @@ include <dishes/cylindrical.scad>
include <dishes/old_spherical.scad>
include <dishes/sideways_cylindrical.scad>
include <dishes/spherical.scad>
include <dishes/squared_spherical.scad>
include <dishes/squared_scoop.scad>
include <dishes/flat.scad>
include <dishes/3d_surface.scad>
//geodesic looks much better, but runs very slow for anything above a 2u
geodesic=false;
@ -16,22 +12,17 @@ geodesic=false;
module dish(width, height, depth, inverted) {
if($dish_type == "cylindrical"){
cylindrical_dish(width, height, depth, inverted);
} else if ($dish_type == "spherical") {
}
else if ($dish_type == "spherical") {
spherical_dish(width, height, depth, inverted);
} else if ($dish_type == "sideways cylindrical"){
}
else if ($dish_type == "sideways cylindrical"){
sideways_cylindrical_dish(width, height, depth, inverted);
} else if ($dish_type == "old spherical") {
}
else if ($dish_type == "old spherical") {
old_spherical_dish(width, height, depth, inverted);
} else if ($dish_type == "3d surface") {
3d_surface_dish(width, height, depth, inverted);
} else if ($dish_type == "flat") {
flat_dish(width, height, depth, inverted);
} else if ($dish_type == "disable") {
// else no dish
} else if ($dish_type == "squared spherical") {
squared_spherical_dish(width, height, depth, inverted=inverted);
} else if ($dish_type == "squared scoop") {
squared_scoop_dish(width, height, depth, inverted=inverted);
} else {
echo("WARN: $dish_type unsupported");
}

View File

@ -1,16 +0,0 @@
include <../libraries/3d_surface.scad>
module 3d_surface_dish(width, height, depth, inverted) {
echo(inverted ? "inverted" : "not inverted");
// scale_factor is dead reckoning
// it doesn't have to be dead reckoning for anything but sculpted sides
// we know the angle of the sides from the width difference, height difference,
// skew and tilt of the top. it's a pain to calculate though
scale_factor = 1.05;
// the edges on this behave differently than with the previous dish implementations
scale([width*scale_factor/$3d_surface_size/2,height*scale_factor/$3d_surface_size/2,depth])
rotate([inverted ? 0:180,0,180])
polar_3d_surface(size=$3d_surface_size, step=$3d_surface_step, bottom=-10);
/* %scale([width*scale_factor/$3d_surface_size/2,height*scale_factor/$3d_surface_size/2,depth]) rotate([180,0,0]) polar_3d_surface(bottom=-10); */
}

View File

@ -1,3 +0,0 @@
module flat_dish(width, height, depth, inverted){
cube([width + 100,height + 100, depth], center=true);
}

View File

@ -1,8 +1,4 @@
module spherical_dish(width, height, depth, inverted){
// these variables take into account corner_radius and corner_sculpting, resulting in a more correct dish
// they don't fix the core issue though (dishes adding / subtracting height on the edges of the keycap), so I've disabled them
// new_width = $key_shape_type == "sculpted_square" ? width - distance_between_circumscribed_and_inscribed($corner_radius + $corner_sculpting(1)) : width;
// new_height = $key_shape_type == "sculpted_square" ? height - distance_between_circumscribed_and_inscribed($corner_radius + $corner_sculpting(1)) : height;
//same thing as the cylindrical dish here, but we need the corners to just touch - so we have to find the hypotenuse of the top
chord = pow((pow(width,2) + pow(height, 2)),0.5); //getting diagonal of the top

View File

@ -1,34 +0,0 @@
module squared_scoop_dish(height, width, depth, r=0.5, inverted=false, num=4, den=5){
// changable numerator/denoninator on where to place the square's corners
// for example, num=2, den=3 means the dish will happen at 1/3 and 2/3 the
// width and the height. Defaults to 4/5. Customizable when calling
// this module
//
// This was initially intended for the scoop on the HiPro, since that's what
// it uses. Use "hipro_row()" if that's what you'd like. However, I do NOT
// know how close the inner square is for the HiPro keycaps. In fact, it could
// just be a sphere, in which the "squared spherical" scoop is more appropriate.
// If, however, it the "squared scoop" makes sense, you can adjust where the square
// lands with the num (numerator) and den (denominator) variables. For instance,
// "3" and "4" mean 3/4 of the width/height is where the flat part starts.
chord = pow(pow(height/2, 2) + pow(width/2, 2),0.5);
direction = inverted ? -1 : 1;
//This is the set of points to hull around for the scoop
points=[
[height/den - height/2, width/den - width/2, -chord],
[num*height/den - height/2, width/den - width/2, -chord],
[height/den - height/2, num*width/den - width/2, -chord],
[num*height/den - height/2, num*width/den - width/2, -chord]
];
resize([height,width,depth])
hull() {
shape_slice(1,0,0);
for(i=[0:len(points)-1]) {
translate(points[i])
sphere(r=r,$fn=64);
}
}
}

View File

@ -1,22 +0,0 @@
module squared_spherical_dish(width, height, depth, inverted=false) {
chord = pow(pow(height / 2, 2) + pow(width / 2, 2),0.5);
direction = inverted ? -1 : 1;
r=max(height,width,chord) / 5;
// ^^^^^ Nothing special about this code to figure out r.
// I just modeled up 1u, 1.25u, 1.5u, 2u, 2.25u, and 2.75u
// keys and messed around until I came up with something that
// looked reasonable for all key sizes. This just seems to work
// well for all sizes
translate([-width / 2, -height / 2, 0 * direction]) {
resize([width, height, depth])
hull() {
cube([chord,chord,0.001]);
// Use something larger in this translate than -depth
// (like -chord) if you want more of a defined circle
// in the keywell
translate([chord/2, chord/2, -depth])
sphere(r=r, $fn=128);
}
}
}

View File

@ -1,5 +0,0 @@
// features are any premade self-contained objects that go on top or inside
include <features/key_bump.scad>
include <features/clearance_check.scad>
include <features/legends.scad>

View File

@ -1,24 +0,0 @@
// a fake cherry keyswitch, abstracted out to maybe replace with a better one later
module cherry_keyswitch() {
union() {
hull() {
cube([15.6, 15.6, 0.01], center=true);
translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true);
}
hull() {
cube([15.6, 15.6, 0.01], center=true);
translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true);
}
}
}
//approximate (fully depressed) cherry key to check clearances
module clearance_check() {
if($stem_type == "cherry" || $stem_type == "cherry_rounded"){
color($warning_color){
translate([0,0,3.6 + $stem_inset - 5]) {
cherry_keyswitch();
}
}
}
}

View File

@ -1,26 +0,0 @@
module keytext(text, position, font_size, font_face, depth) {
woffset = (top_total_key_width()/3.5) * position[0];
hoffset = (top_total_key_height()/3.5) * -position[1];
translate([woffset, hoffset, -depth]){
color($tertiary_color) linear_extrude(height=$dish_depth + depth){
text(text=text, font=font_face, size=font_size, halign="center", valign="center");
}
}
}
module legends(depth=0) {
if (len($front_legends) > 0) {
front_of_key() {
for (i=[0:len($front_legends)-1]) {
rotate([90,0,0]) keytext($front_legends[i][0], $front_legends[i][1], $front_legends[i][2], $front_legends[i][3], depth);
}
}
}
if (len($legends) > 0) {
top_of_key() {
for (i=[0:len($legends)-1]) {
keytext($legends[i][0], $legends[i][1], $legends[i][2], $legends[i][3], depth);
}
}
}
}

View File

@ -1,12 +1,9 @@
include <constants.scad>
include <settings.scad>
// I use functions when I need to compute special variables off of other special variables
// functions need to be explicitly included, unlike special variables, which
// just need to have been set before they are used. hence this file
function stem_height() = $total_depth - ($dish_depth * ($inverted_dish ? -1 : 1)) - $stem_inset;
// cherry stem dimensions
function outer_cherry_stem(slop) = [7.2 - slop * 2, 5.5 - slop * 2];
@ -19,15 +16,11 @@ function outer_box_cherry_stem(slop) = [6 - slop, 6 - slop];
// .005 purely for aesthetics, to get rid of that ugly crosshatch
function cherry_cross(slop, extra_vertical = 0) = [
// horizontal tine
[4.03 + slop, 1.25 + slop / 3],
[4.03 + slop, 1.15 + slop / 3],
// vertical tine
[1.15 + slop / 3, 4.23 + extra_vertical + slop / 3 + SMALLEST_POSSIBLE],
[1.25 + slop / 3, 4.23 + extra_vertical + slop / 3 + SMALLEST_POSSIBLE],
];
// TODO add side_sculpting
function key_width_at_progress(progress = 0) = $bottom_key_width + ($unit * ($key_length - 1)) - $width_difference;
function key_height_at_progress(progress = 0) = $bottom_key_height + ($unit * ($key_height - 1)) - $height_difference + $side_sculpting(progress);
// actual mm key width and height
function total_key_width(delta = 0) = $bottom_key_width + $unit * ($key_length - 1) - delta;
function total_key_height(delta = 0) = $bottom_key_height + $unit * ($key_height - 1) - delta;
@ -35,24 +28,3 @@ function total_key_height(delta = 0) = $bottom_key_height + $unit * ($key_height
// actual mm key width and height at the top
function top_total_key_width() = $bottom_key_width + ($unit * ($key_length - 1)) - $width_difference;
function top_total_key_height() = $bottom_key_height + ($unit * ($key_height - 1)) - $height_difference;
function side_tilt(column) = asin($unit * column / $double_sculpt_radius);
// tan of 0 is 0, division by 0 is nan, so we have to guard
function extra_side_tilt_height(column) = side_tilt(column) ? ($double_sculpt_radius - ($unit * abs(column)) / tan(abs(side_tilt(column)))) : 0;
// (I think) extra length of the side of the keycap due to the keytop being tilted.
// necessary for calculating flat sided keycaps
function vertical_inclination_due_to_top_tilt() = sin($top_tilt) * (top_total_key_height() - $corner_radius * 2) * 0.5;
// how much you have to expand the front or back of the keytop to make the side
// of the keycap a flat plane. 1 = front, -1 = back
// I derived this through a bunch of trig reductions I don't really understand.
function extra_keytop_length_for_flat_sides() = ($width_difference * vertical_inclination_due_to_top_tilt()) / ($total_depth);
// adds uniform rounding radius for round-anything polyRound
function add_rounding(p, radius)=[for(i=[0:len(p)-1])[p[i].x,p[i].y, radius]];
// computes millimeter length from unit length
function unit_length(length) = $unit * (length - 1) + 18.16;
// if you have a radius of an inscribed circle, this function gives you the extra length for the radius of the circumscribed circle
// and vice versa. used to find the edge of a rounded_square
function distance_between_circumscribed_and_inscribed(radius) = (pow(2, 0.5) - 1) * radius;

View File

@ -1,19 +0,0 @@
include <hulls/skin.scad>
include <hulls/linear_extrude.scad>
include <hulls/hull.scad>
// basic key shape, no dish, no inside
// which is only used for dishing to cut the dish off correctly
// $height_difference used for keytop thickness
// extra_slices is a hack to make inverted dishes still work
module shape_hull(thickness_difference, depth_difference, extra_slices = 0){
render() {
if ($hull_shape_type == "skin") {
skin_extrude_shape_hull(thickness_difference, depth_difference, extra_slices);
} else if ($hull_shape_type == "linear extrude") {
linear_extrude_shape_hull(thickness_difference, depth_difference, extra_slices);
} else {
hull_shape_hull(thickness_difference, depth_difference, extra_slices);
}
}
}

View File

@ -1,37 +0,0 @@
module hull_shape_hull(thickness_difference, depth_difference, extra_slices = 0) {
for (index = [0:$height_slices - 1 + extra_slices]) {
hull() {
placed_shape_slice(index / $height_slices, thickness_difference, depth_difference);
placed_shape_slice((index + 1) / $height_slices, thickness_difference, depth_difference);
}
}
}
module placed_shape_slice(progress, thickness_difference, depth_difference) {
skew_this_slice = $top_skew * progress;
x_skew_this_slice = $top_skew_x * progress;
depth_this_slice = ($total_depth - depth_difference) * progress;
tilt_this_slice = -$top_tilt / $key_height * progress;
y_tilt_this_slice = $double_sculpted ? (-$top_tilt_y / $key_length * progress) : 0;
translate([x_skew_this_slice, skew_this_slice, depth_this_slice]) {
rotate([tilt_this_slice,y_tilt_this_slice,0]){
shape_slice(progress, thickness_difference, depth_difference);
}
}
}
module shape_slice(progress, thickness_difference, depth_difference) {
linear_extrude(height = SMALLEST_POSSIBLE, scale = 1){
key_shape(
[
total_key_width(thickness_difference),
total_key_height(thickness_difference)
],
[$width_difference, $height_difference],
progress
);
}
}

View File

@ -1,18 +0,0 @@
// corollary is hull_shape_hull
// extra_slices unused, only to match argument signatures
module linear_extrude_shape_hull(thickness_difference, depth_difference, extra_slices = 0){
height = $total_depth - depth_difference;
width_scale = top_total_key_width() / total_key_width();
height_scale = top_total_key_height() / total_key_height();
translate([0,$linear_extrude_height_adjustment,0]){
linear_extrude(height = height, scale = [width_scale, height_scale]) {
translate([0,-$linear_extrude_height_adjustment,0]){
key_shape(
[total_key_width(), total_key_height()],
[thickness_difference, thickness_difference]
);
}
}
}
}

View File

@ -1,34 +0,0 @@
// use skin() instead of successive hulls. much more correct, and looks faster
// too, in most cases. successive hull relies on overlapping faces which are
// not good. But, skin works on vertex sets instead of shapes, which makes it
// a lot more difficult to use
module skin_extrude_shape_hull(thickness_difference, depth_difference, extra_slices = 0 ) {
skin([
for (index = [0:$height_slices + extra_slices])
let(
progress = (index / $height_slices),
skew_this_slice = $top_skew * progress,
x_skew_this_slice = $top_skew_x * progress,
depth_this_slice = ($total_depth - depth_difference) * progress,
tilt_this_slice = -$top_tilt / $key_height * progress,
y_tilt_this_slice = $double_sculpted ? (-$top_tilt_y / $key_length * progress) : 0
)
skin_shape_slice(progress, thickness_difference, skew_this_slice, x_skew_this_slice, depth_this_slice, tilt_this_slice, y_tilt_this_slice)
]);
}
function skin_shape_slice(progress, thickness_difference, skew_this_slice, x_skew_this_slice, depth_this_slice, tilt_this_slice, y_tilt_this_slice) =
transform(
translation([x_skew_this_slice,skew_this_slice,depth_this_slice]),
transform(
rotation([tilt_this_slice,y_tilt_this_slice,0]),
skin_key_shape([
total_key_width(0) - thickness_difference,
total_key_height(0) - thickness_difference,
],
[$width_difference, $height_difference],
progress,
thickness_difference
)
)
);

View File

@ -1,129 +1,168 @@
// files
include <constants.scad>
include <functions.scad>
include <shapes.scad>
include <stems.scad>
include <stem_supports.scad>
include <dishes.scad>
include <supports.scad>
include <features.scad>
include <hulls.scad>
include <key_features.scad>
include <libraries/geodesic_sphere.scad>
// for skin hulls
use <libraries/scad-utils/transformations.scad>
use <libraries/scad-utils/lists.scad>
use <libraries/scad-utils/shapes.scad>
use <libraries/skin.scad>
// key shape including dish. used as the outside and inside shape in hollow_key(). allows for itself to be shrunk in depth and width / height
module shape(thickness_difference, depth_difference=0){
/* [Hidden] */
SMALLEST_POSSIBLE = 1/128;
$fs = .1;
$unit = 19.05;
blue = [.2667,.5882,1];
color2 = [.5412, .4784, 1];
purple = [.4078, .3569, .749];
yellow = [1, .6941, .2];
transparent_red = [1,0,0, 0.15];
// key shape including dish. used as the ouside and inside shape in keytop(). allows for itself to be shrunk in depth and width / height
module shape(thickness_difference, depth_difference){
dished(depth_difference, $inverted_dish) {
color($primary_color) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 200 : 0);
color(blue) shape_hull(thickness_difference, depth_difference, $inverted_dish ? 2 : 0);
}
}
// shape of the key but with soft, rounded edges. much more realistic, MUCH more complex. orders of magnitude more complex
module rounded_shape() {
color($primary_color) minkowski(){
color(blue) minkowski(){
// half minkowski in the z direction
shape($minkowski_radius * 2, $minkowski_radius/2);
minkowski_object();
}
}
// minkowski places this object at every vertex of the other object then mashes
// it all together
module minkowski_object() {
// alternative minkowski shape that needs the bottom of the keycap to be trimmed
/* sphere(1); */
difference(){
sphere(r=$minkowski_radius, $fa=360/$minkowski_facets);
sphere(r=$minkowski_radius, $fn=20);
translate([0,0,-$minkowski_radius]){
cube($minkowski_radius * 2, center=true);
}
}
}
}
module envelope(depth_difference=0, extra_floor_depth=0) {
size = 1.5;
// basic key shape, no dish, no inside
// which is only used for dishing to cut the dish off correctly
// $height_difference used for keytop thickness
// extra_slices is a hack to make inverted dishes still work
module shape_hull(thickness_difference, depth_difference, extra_slices = 0){
render() {
if ($linear_extrude_shape) {
linear_extrude_shape_hull(thickness_difference, depth_difference, extra_slices);
} else {
hull_shape_hull(thickness_difference, depth_difference, extra_slices);
}
}
}
// corollary is hull_shape_hull
// extra_slices unused, only to match argument signatures
module linear_extrude_shape_hull(thickness_difference, depth_difference, extra_slices = 0){
height = $total_depth - depth_difference;
width_scale = top_total_key_width() / total_key_width();
height_scale = top_total_key_height() / total_key_height();
translate([0,$linear_extrude_height_adjustment,0]){
linear_extrude(height = height, scale = [width_scale, height_scale]) {
translate([0,-$linear_extrude_height_adjustment,0]){
key_shape(total_key_width(thickness_difference), total_key_height(thickness_difference));
}
}
}
}
module hull_shape_hull(thickness_difference, depth_difference, extra_slices = 0) {
for (index = [0:$height_slices - 1 + extra_slices]) {
hull() {
translate([0,0,extra_floor_depth]) cube([key_width_at_progress(extra_floor_depth / $total_depth) * size, key_height_at_progress(extra_floor_depth / $total_depth) * size, 0.01], center = true);
top_placement(SMALLEST_POSSIBLE + depth_difference){
cube([top_total_key_width() * size, top_total_key_height() * size, 0.01], center = true);
shape_slice(index / $height_slices, thickness_difference, depth_difference);
shape_slice((index + 1) / $height_slices, thickness_difference, depth_difference);
}
}
}
// for when you want to take the dish out of things
// used for adding the dish to the key shape and making sure stems don't stick out the top
// creates a bounding box 1.5 times larger in width and height than the keycap.
module dished(depth_difference = 0, inverted = false) {
intersection() {
children();
difference(){
union() {
// envelope is needed to "fill in" the rest of the keycap. intersections with small objects are much faster than differences with large objects
envelope(depth_difference, $stem_inset);
if (inverted) top_placement(depth_difference) color($secondary_color) _dish(inverted);
module shape_slice(progress, thickness_difference, depth_difference) {
skew_this_slice = $top_skew * progress;
depth_this_slice = ($total_depth - depth_difference) * progress;
tilt_this_slice = -$top_tilt / $key_height * progress;
translate([0, skew_this_slice, depth_this_slice]) {
rotate([tilt_this_slice,0,0]){
linear_extrude(height = SMALLEST_POSSIBLE){
key_shape(
[
total_key_width(thickness_difference),
total_key_height(thickness_difference)
],
[$width_difference, $height_difference],
progress
);
}
if (!inverted) top_placement(depth_difference) color($secondary_color) _dish(inverted);
// %top_placement(depth_difference) _dish();
}
}
}
// for when you want something to only exist inside the keycap.
// used for the support structure
module inside() {
intersection() {
shape($wall_thickness, $keytop_thickness);
children();
}
}
// put something at the top of the key, with no adjustments for dishing
module top_placement(depth_difference) {
translate([$dish_skew_x, $top_skew + $dish_skew_y, $total_depth - depth_difference]){
rotate([-$top_tilt / $key_height,0,0]){
children();
}
}
}
// just to DRY up the code
// TODO is putting special vars in function signatures legal
module _dish(inverted=$inverted_dish) {
translate([$dish_offset_x,0,0]) color($secondary_color)
dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, inverted);
// %dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, inverted);
module _dish() {
dish(top_total_key_width() + $dish_overdraw_width, top_total_key_height() + $dish_overdraw_height, $dish_depth, $inverted_dish);
}
// puts its children at each keystem position provided
module keystem_positions(positions) {
for (connector_pos = positions) {
translate(connector_pos) {
rotate([0, 0, $stem_rotation]){
module envelope(depth_difference) {
s = 1.5;
hull(){
cube([total_key_width() * s, total_key_height() * s, 0.01], center = true);
top_placement(SMALLEST_POSSIBLE + depth_difference){
cube([top_total_key_width() * s, top_total_key_height() * s, 0.01], center = true);
}
}
}
module dished_for_show() {
difference(){
union() {
envelope();
if ($inverted_dish) top_placement(0) _dish();
}
if (!$inverted_dish) top_placement(0) _dish();
}
}
// for when you want to take the dish out of things
// used for adding the dish to the key shape and making sure stems don't stick out the top
// creates a bounding box 1.5 times larger in width and height than the keycap.
module dished(depth_difference, inverted = false) {
intersection() {
children();
difference(){
union() {
envelope(depth_difference);
if (inverted) top_placement(depth_difference) _dish();
}
if (!inverted) top_placement(depth_difference) _dish();
}
}
}
module support_for(positions, stem_type) {
keystem_positions(positions) {
color($tertiary_color) supports($support_type, stem_type, $stem_throw, $total_depth - $stem_throw);
}
}
module stems_for(positions, stem_type) {
keystem_positions(positions) {
color($tertiary_color) stem(stem_type, stem_height(), $stem_slop, $stem_throw);
if ($stem_support_type != "disable") {
color($quaternary_color) stem_support($stem_support_type, stem_type, $stem_support_height, $stem_slop);
}
}
}
// put something at the top of the key, with no adjustments for dishing
module top_placement(depth_difference=0) {
top_tilt_by_height = -$top_tilt / $key_height;
top_tilt_y_by_length = $double_sculpted ? (-$top_tilt_y / $key_length) : 0;
// minkowski_height = $rounded_key ? $minkowski_radius : 0;
translate([$top_skew_x + $dish_skew_x, $top_skew + $dish_skew_y, $total_depth - depth_difference]){
rotate([top_tilt_by_height, top_tilt_y_by_length,0]){
children();
}
}
}
// puts its children at the center of the dishing on the key, including dish height
// puts it's children at the center of the dishing on the key, including dish height
// more user-friendly than top_placement
module top_of_key(){
// if there is a dish, we need to account for how much it digs into the top
@ -136,125 +175,141 @@ module top_of_key(){
}
}
module front_of_key() {
// all this math is to take top skew and tilt into account
// we need to find the new effective height and depth of the top, front lip
// of the keycap to find the angle so we can rotate things correctly into place
total_depth_difference = sin(-$top_tilt) * (top_total_key_height()/2);
total_height_difference = $top_skew + (1 - cos(-$top_tilt)) * (top_total_key_height()/2);
module keytext(text, position, font_size, depth) {
woffset = (top_total_key_width()/3.5) * position[0];
hoffset = (top_total_key_height()/3.5) * -position[1];
translate([woffset, hoffset, -depth]){
linear_extrude(height=$dish_depth){
text(text=text, font=$font, size=font_size, halign="center", valign="center");
}
}
}
angle = atan2(($total_depth - total_depth_difference), ($height_difference/2 + total_height_difference));
hypotenuse = ($total_depth -total_depth_difference) / sin(angle);
translate([0,-total_key_height()/2,0]) {
rotate([-(90-angle), 0, 0]) {
translate([0,0,hypotenuse/2]){
module keystem_positions(positions) {
for (connector_pos = positions) {
translate(connector_pos) {
rotate([0, 0, $stem_rotation]){
children();
}
}
}
}
module outer_shape() {
if ($rounded_key == true) {
module support_for(positions, stem_type) {
keystem_positions(positions) {
color(yellow) supports($support_type, stem_type, $stem_throw, $total_depth - $stem_throw);
}
}
module stems_for(positions, stem_type) {
keystem_positions(positions) {
color(yellow) stem(stem_type, $total_depth, $stem_slop);
if ($stem_support_type != "disable") {
color(color2) stem_support($stem_support_type, stem_type, $stem_support_height, $stem_slop);
}
}
}
// a fake cherry keyswitch, abstracted out to maybe replace with a better one later
module cherry_keyswitch() {
union() {
hull() {
cube([15.6, 15.6, 0.01], center=true);
translate([0,1,5 - 0.01]) cube([10.5,9.5, 0.01], center=true);
}
hull() {
cube([15.6, 15.6, 0.01], center=true);
translate([0,0,-5.5]) cube([13.5,13.5,0.01], center=true);
}
}
}
//approximate (fully depressed) cherry key to check clearances
module clearance_check() {
if($stem_type == "cherry" || $stem_type == "cherry_rounded"){
color(transparent_red){
translate([0,0,3.6 + $stem_inset - 5]) {
cherry_keyswitch();
}
}
}
}
// legends / artisan support
module artisan(depth) {
top_of_key() {
// outset legend
if (len($legends) > 0) {
for (i=[0:len($legends)-1]) {
keytext($legends[i][0], $legends[i][1], $legends[i][2], depth);
}
}
// artisan objects / outset shape legends
children();
}
}
// key with hollowed inside but no stem
module keytop() {
difference(){
if ($rounded_key) {
rounded_shape();
} else {
shape(0, 0);
}
// translation purely for aesthetic purposes, to get rid of that awful lattice
translate([0,0,-SMALLEST_POSSIBLE]) {
shape($wall_thickness, $keytop_thickness);
}
module inner_shape(extra_wall_thickness = 0, extra_keytop_thickness = 0) {
if ($inner_shape_type == "flat") {
/* $key_shape_type="square"; */
$height_slices = 1;
// if inner_shape is flat, keytop_thickness will be dish_depth less than it should be, since the dish digs in that far.
// so, we add dish_depth here
color($primary_color) shape_hull($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness + $dish_depth, 0);
} else {
shape($wall_thickness + extra_wall_thickness, $keytop_thickness + extra_keytop_thickness);
}
}
// additive objects at the top of the key
module additive_features(inset) {
top_of_key() {
if($key_bump) keybump($key_bump_depth, $key_bump_edge);
if(!inset && $children > 0) color($secondary_color) children();
}
if($outset_legends) legends(0);
// render the clearance check if it's enabled, but don't have it intersect with anything
if ($clearance_check) %clearance_check();
}
// subtractive objects at the top of the key
module subtractive_features(inset) {
top_of_key() {
if (inset && $children > 0) color($secondary_color) children();
}
if(!$outset_legends) legends($inset_legend_depth);
// subtract the clearance check if it's enabled, letting the user see the
// parts of the keycap that will hit the cherry switch
// this is a little confusing as it eats the stem too
/* if ($clearance_check) clearance_check(); */
}
// features inside the key itself (stem, supports, etc)
module inside_features() {
// Stems and stabilizers are not "inside features" unless they are fully
// contained inside the cap. otherwise they'd be cut off when they are
// differenced with the outside shape. this only matters if $stem_inset
// is negative
if ($stem_inset >= 0) stems_and_stabilizers();
if ($support_type != "disable") translate([0, 0, $stem_inset]) support_for($stem_positions, $stem_type);
if ($stabilizer_type != "disable") translate([0, 0, $stem_inset]) support_for($stabilizers, $stabilizer_type);
}
// all stems and stabilizers
module stems_and_stabilizers() {
translate([0, 0, $stem_inset]) {
if ($stabilizer_type != "disable") stems_for($stabilizers, $stabilizer_type);
if ($stem_type != "disable") stems_for($stem_positions, $stem_type);
}
}
// helpers for doubleshot keycaps for now
module inner_total_shape() {
difference() {
inner_shape();
inside_features();
}
}
module outer_total_shape(inset=false) {
outer_shape();
additive_features(inset) {
children();
};
}
// The final, penultimate key generation function.
// takes all the bits and glues them together. requires configuration with special variables.
module key(inset = false) {
difference() {
outer_total_shape(inset) {
children();
};
union(){
// the shape of the key, inside and out
keytop();
if($key_bump) top_of_key() keybump($key_bump_depth, $key_bump_edge);
// additive objects at the top of the key
if(!inset) artisan() children();
// render the clearance check if it's enabled, but don't have it intersect with anything
if ($clearance_check) %clearance_check();
}
if ($inner_shape_type != "disable") {
translate([0,0,-SMALLEST_POSSIBLE]) { // avoids moire
inner_total_shape();
// subtractive objects at the top of the key
if (inset) artisan(0.3) children();
// subtract the clearance check if it's enabled, letting the user see the
// parts of the keycap that will hit the cherry switch
if ($clearance_check) clearance_check();
}
// both stem and support are optional
if ($stem_type != "disable" || ($stabilizers != [] && $stabilizer_type != "disable")) {
dished($keytop_thickness, $inverted_dish) {
translate([0, 0, $stem_inset]) {
/* if ($stabilizer_type != "disable") stems_for($stabilizers, $stabilizer_type); */
if ($stem_type != "disable") {
stems_for($stabilizers, $stabilizer_type);
}
stems_for($stem_positions, $stem_type);
}
}
}
subtractive_features(inset) {
children();
};
}
if ($support_type != "disable"){
inside() {
translate([0, 0, $stem_inset]) {
if ($stabilizer_type != "disable") support_for($stabilizers, $stabilizer_type);
// semi-hack to make sure negative inset stems don't poke through the top of the keycap
if ($stem_inset < 0) {
dished(0, $inverted_dish) {
stems_and_stabilizers();
// always render stem support even if there isn't a stem.
// rendering flat support w/no stem is much more common than a hollow keycap
// so if you want a hollow keycap you'll have to turn support off entirely
support_for($stem_positions, $stem_type);
}
}
}
}
@ -266,6 +321,4 @@ module example_key(){
key();
}
if (!$using_customizer) {
example_key();
}

View File

@ -1,20 +0,0 @@
include <layouts/layout.scad>
include <layouts/preonic/default.scad>
include <layouts/preonic/mit.scad>
include <layouts/planck/default.scad>
include <layouts/planck/mit.scad>
include <layouts/lets_split/default.scad>
include <layouts/project_zen/default.scad>
include <layouts/60_percent/default.scad>
include <layouts/gherkin/default.scad>
include <layouts/gherkin/gherkin_bump.scad>
include <layouts/dactyl_manuform/4x6.scad>
include <layouts/dactyl_manuform/4x6_legends.scad>
include <layouts/plate.scad>

View File

@ -7,48 +7,19 @@ include <key_profiles/oem.scad>
include <key_profiles/dsa.scad>
include <key_profiles/sa.scad>
include <key_profiles/g20.scad>
include <key_profiles/hipro.scad>
include <key_profiles/mt3.scad>
include <key_profiles/grid.scad>
include <key_profiles/regular_polygon.scad>
include <key_profiles/cherry.scad>
include <key_profiles/dss.scad>
include <key_profiles/asa.scad>
include <key_profiles/typewriter.scad>
include <key_profiles/hex.scad>
// man, wouldn't it be so cool if functions were first order
module key_profile(key_profile_type, row, column=0) {
module key_profile(key_profile_type, row) {
if (key_profile_type == "dcs") {
dcs_row(row, column) children();
dcs_row(row) children();
} else if (key_profile_type == "oem") {
oem_row(row, column) children();
oem_row(row) children();
} else if (key_profile_type == "dsa") {
dsa_row(row, column) children();
} else if (key_profile_type == "dss") {
dss_row(row, column) children();
dsa_row(row) children();
} else if (key_profile_type == "sa") {
sa_row(row, column) children();
} else if (key_profile_type == "asa") {
asa_row(row, column) children();
sa_row(row) children();
} else if (key_profile_type == "g20") {
g20_row(row, column) children();
} else if (key_profile_type == "hipro") {
hipro_row(row, column) children();
} else if (key_profile_type == "grid") {
grid_row(row, column) children();
} else if (key_profile_type == "typewriter") {
typewriter_row(row, column) children();
} else if (key_profile_type == "hex") { // reddit.com/r/MechanicalKeyboards/comments/kza7ji
hex_row(row, column) children();
} else if (key_profile_type == "hexagon") {
hexagonal_row(row, column) children();
} else if (key_profile_type == "octagon") {
octagonal_row(row, column) children();
} else if (key_profile_type == "cherry") {
cherry_row(row, column) children();
} else if (key_profile_type == "mt3") {
mt3_row(row, column) children();
g20_row(row) children();
} else if (key_profile_type == "disable") {
children();
} else {

View File

@ -1,44 +0,0 @@
use <../functions.scad>
include <../settings.scad>
module asa_row(row=3, column = 0) {
$key_shape_type = "sculpted_square";
$bottom_key_height = 18.15;
$bottom_key_width = 18.10; // Default (R3)
$total_depth = 10.75; // Default (R3)
$top_tilt = 1.5; // Default (R3)
$width_difference = 6.20;
$height_difference = 6.55;
$dish_type = "spherical";
$dish_depth = 1.3;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 1.75;
$stem_inset = 1.2;
$height_slices = 10;
$corner_radius = 1;
$more_side_sculpting_factor = 0.4;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2);
// this is _incredibly_ intensive
//$rounded_key = true;
if (row == 1){
$total_depth = 10.5;
$top_tilt = 9.33;
children();
} else if (row == 2) {
$total_depth = 9.95;
$top_tilt = 4;
children();
} else if (row == 4){
$total_depth = 12.55;
$top_tilt = 0.43;
children();
}else{
children();
}
}

View File

@ -1,51 +0,0 @@
use <../functions.scad>
include <../settings.scad>
// based off GMK keycap set
module cherry_row(row=3, column=0) {
$bottom_key_width = 18.16;
$bottom_key_height = 18.16;
$width_difference = $bottom_key_width - 11.85;
$height_difference = $bottom_key_height - 14.64;
$dish_type = "cylindrical";
$dish_depth = 0.65;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 2;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
// NOTE: cherry keycaps have this stem inset, but I'm reticent to turn it on
// since it'll be surprising to folks. the height has been adjusted accordingly
// $stem_inset = 0.6;
extra_stem_inset_height = max(0.6 - $stem_inset, 0);
// <= is a hack so you can do these in a for loop. function row = 0
if (row <= 1) {
$total_depth = 9.8 - extra_stem_inset_height + extra_height;
$top_tilt = 0;
children();
} else if (row == 2) {
$total_depth = 7.45 - extra_stem_inset_height + extra_height;
$top_tilt = 2.5;
children();
} else if (row == 3) {
$total_depth = 6.55 - extra_stem_inset_height + extra_height;
$top_tilt = 5;
children();
} else if (row == 3) {
$total_depth = 6.7 + 0.65 - extra_stem_inset_height + extra_height;
$top_tilt = 11.5;
children();
} else if (row >= 4) {
$total_depth = 6.7 + 0.65 - extra_stem_inset_height + extra_height;
$top_tilt = 11.5;
children();
} else {
children();
}
}

View File

@ -1,47 +1,33 @@
use <../functions.scad>
include <../settings.scad>
module dcs_row(row=3, column=0) {
module dcs_row(n=3) {
// names, so I don't go crazy
$bottom_key_width = 18.16;
$bottom_key_height = 18.16;
$width_difference = 6;
$height_difference = 4;
$dish_type = "cylindrical";
$dish_depth = 0.5;
$dish_depth = 1;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 1.75;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
// this dish depth should match the depth of the uberdishing in fully sculpted mode
// but it doesn't, and it's very slight for any reasonable double sculpting
/* $dish_depth = $double_sculpt_radius - sin(acos(top_total_key_width()/2 /$double_sculpt_radius)) * $double_sculpt_radius; */
/* echo("DISH DEPTH", $dish_depth, "column", column); */
// 5/0 is a hack so you can do these in a for loop
if (row == 5 || row == 0) {
$total_depth = 11.5 + extra_height;
if (n == 5) {
$total_depth = 11.5;
$top_tilt = -6;
children();
} else if (row == 1) {
$total_depth = 8.5 + extra_height;
} else if (n == 1) {
$total_depth = 8.5;
$top_tilt = -1;
children();
} else if (row == 2) {
$total_depth = 7.5 + extra_height;
} else if (n == 2) {
$total_depth = 7.5;
$top_tilt = 3;
children();
} else if (row == 3) {
$total_depth = 6 + extra_height;
} else if (n == 3) {
$total_depth = 6;
$top_tilt = 7;
children();
} else if (row == 4) {
$total_depth = 6 + extra_height;
} else if (n == 4) {
$total_depth = 6;
$top_tilt = 16;
children();
} else {

View File

@ -1,44 +1,36 @@
use <../functions.scad>
include <../settings.scad>
module dsa_row(row=3, column = 0) {
module dsa_row(n=3) {
$key_shape_type = "sculpted_square";
$bottom_key_width = 18.24; // 18.4;
$bottom_key_height = 18.24; // 18.4;
$width_difference = 6; // 5.7;
$height_difference = 6; // 5.7;
$top_tilt = row == 5 ? -21 : (row-3) * 7;
$top_tilt = n == 5 ? -21 : (n-3) * 7;
$top_skew = 0;
$dish_type = "spherical";
$dish_depth = 1.2;
$dish_skew_x = 0;
$dish_skew_y = 0;
$height_slices = 10;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2);
$corner_radius = 1;
$more_side_sculpting_factor = 0.4;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
$enable_side_sculpting = true;
// might wanna change this if you don't minkowski
// do you even minkowski bro
$corner_radius = 0.25;
depth_raisers = [0, 3.5, 1, 0, 1, 3];
if (row < 1 || row > 4) {
$total_depth = 8.1 + depth_raisers[row] + extra_height;
if (n == 5) {
$total_depth = 8.1 + depth_raisers[n];
children();
} else if (row == 1) {
$total_depth = 8.1 + depth_raisers[row] + extra_height;
} else if (n == 1) {
$total_depth = 8.1 + depth_raisers[n];
children();
} else if (row == 2) {
$total_depth = 8.1 + depth_raisers[row] + extra_height;
} else if (n == 2) {
$total_depth = 8.1 + depth_raisers[n];
children();
} else if (row == 3) {
$total_depth = 8.1 + depth_raisers[row] + extra_height;
} else if (n == 3) {
$total_depth = 8.1 + depth_raisers[n];
children();
} else if (row == 4) {
$total_depth = 8.1 + depth_raisers[row] + extra_height;
} else if (n == 4) {
$total_depth = 8.1 + depth_raisers[n];
children();
} else {
children();

View File

@ -1,55 +0,0 @@
use <../functions.scad>
include <../settings.scad>
module dss_row(n=3, column=0) {
$key_shape_type = "sculpted_square";
$bottom_key_width = 18.24;
$bottom_key_height = 18.24;
$width_difference = 6;
$height_difference = 6;
$dish_type = "spherical";
$dish_depth = 1.2;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 10;
// might wanna change this if you don't minkowski
// do you even minkowski bro
$corner_radius = 1;
$more_side_sculpting_factor = 0.4;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2);
// this is _incredibly_ intensive
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
// 5th row is usually unsculpted or the same as the row below it
// making a super-sculpted top row (or bottom row!) would be real easy
// bottom row would just be 13 tilt and 14.89 total depth
// top row would be something new entirely - 18 tilt maybe?
if (n <= 1){
$total_depth = 10.5 + extra_height;
$top_tilt = -1;
children();
} else if (n == 2) {
$total_depth = 8.6 + extra_height;
$top_tilt = 3;
children();
} else if (n == 3) {
$total_depth = 7.9 + extra_height;
$top_tilt = 8;
children();
} else if (n == 4){
$total_depth = 9.1 + extra_height;
$top_tilt = 16;
children();
} else {
$total_depth = 7.9 + extra_height;
$top_tilt = 8;
children();
}
}

View File

@ -1,7 +1,4 @@
use <../functions.scad>
include <../settings.scad>
module g20_row(row=3, column = 0) {
module g20_row(n=3) {
$bottom_key_width = 18.16;
$bottom_key_height = 18.16;
$width_difference = 2;
@ -19,26 +16,25 @@ module g20_row(row=3, column = 0) {
//also,
$rounded_key = true;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
$total_depth = 6 + abs((row-3) * 0.5) + extra_height;
if (row == 5 || row == 0) {
if (n == 5) {
$total_depth = 6 + abs((n-3) * 0.5);
$top_tilt = -18.55;
children();
} else if (row == 1) {
$top_tilt = (row-3) * 7 + 2.5;
} else if (n == 1) {
$total_depth = 6 + abs((n-3) * 0.5);
$top_tilt = (n-3) * 7 + 2.5;
children();
} else if (row == 2) {
$top_tilt = (row-3) * 7 + 2.5;
} else if (n == 2) {
$total_depth = 6 + abs((n-3) * 0.5);
$top_tilt = (n-3) * 7 + 2.5;
children();
} else if (row == 3) {
$top_tilt = (row-3) * 7 + 2.5;
} else if (n == 3) {
$total_depth = 6 + abs((n-3) * 0.5);
$top_tilt = (n-3) * 7 + 2.5;
children();
} else if (row == 4) {
$top_tilt = (row-3) * 7 + 2.5;
} else if (n == 4) {
$total_depth = 6 + abs((n-3) * 0.5);
$top_tilt = (n-3) * 7 + 2.5;
children();
} else {
children();

View File

@ -1,50 +0,0 @@
use <../functions.scad>
include <../settings.scad>
module grid_row(row=3, column = 0) {
$bottom_key_width = 18.16;
$bottom_key_height = 18.16;
$width_difference = 1;
$height_difference = 1;
$top_tilt = 0;
$top_skew = 0;
$dish_type = "old spherical";
// something weird is going on with this and legends - can't put it below 1.2 or they won't show
$dish_depth = 1;
$dish_skew_x = 0;
$dish_skew_y = 0;
$hull_shape_type = "linear extrude";
$dish_overdraw_width = -6.5;
$dish_overdraw_height = -6.5;
$minkowski_radius = 0.5;
//also,
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
$total_depth = 7 + abs((row-3) * 0.5) + extra_height;
if (row == 5 || row == 0) {
/* $top_tilt = -18.55; */
children();
} else if (row == 1) {
/* $top_tilt = (row-3) * 7 + 2.5; */
children();
} else if (row == 2) {
/* $top_tilt = (row-3) * 7 + 2.5; */
children();
} else if (row == 3) {
/* $top_tilt = (row-3) * 7 + 2.5; */
children();
} else if (row == 4) {
/* $top_tilt = (row-3) * 7 + 2.5; */
children();
} else {
children();
}
}

View File

@ -1,62 +0,0 @@
include <../constants.scad>
// Regular polygon shapes CIRCUMSCRIBE the sphere of diameter $bottom_key_width
// This is to make tiling them easier, like in the case of hexagonal keycaps etc
// this function doesn't set the key shape, so you can't use it directly without some fiddling
module hex_row(n=3, column=0) {
$bottom_key_width = $unit - 0.5;
$bottom_key_height = $unit - 0.5;
$width_difference = 0;
$height_difference = 0;
$dish_type = "spherical";
$key_shape_type = "hexagon";
$stem_inset = -2.5;
$stem_throw = 3;
// $dish_depth = 1;
$top_skew = 0;
$height_slices = 1;
$stem_support_type = "disable";
$dish_overdraw_width = -8.25;
$dish_overdraw_height = -8.25;
// $corner_radius = 1;
// this is _incredibly_ intensive
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
base_depth = 4;
if (n <= 1){
$total_depth = base_depth + 2.5 + extra_height;
$top_tilt = -13;
children();
} else if (n == 2) {
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = -7;
children();
} else if (n == 3) {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
} else if (n == 4){
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = 7;
children();
} else {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
}
}

View File

@ -1,48 +0,0 @@
use <../functions.scad>
include <../settings.scad>
module hipro_row(row=3, column=0) {
$key_shape_type = "sculpted_square";
$bottom_key_width = 18.35;
$bottom_key_height = 18.17;
$width_difference = ($bottom_key_width - 12.3);
$height_difference = ($bottom_key_height - 12.65);
$dish_type = "squared scoop";
$dish_depth = 0.75;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 10;
$corner_radius = 1;
$more_side_sculpting_factor = 0.4;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2);
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
if (row <= 1){
$total_depth = 13.7 + extra_height;
// TODO I didn't change these yet
$top_tilt = -13;
children();
} else if (row == 2) {
$total_depth = 11.1 + extra_height;
$top_tilt = -7;
children();
} else if (row == 3) {
$total_depth = 11.1 + extra_height;
$top_tilt = 7;
children();
} else if (row == 4 || row == 5){
$total_depth = 12.25 + extra_height;
$top_tilt = 13;
children();
} else {
children();
}
}

View File

@ -1,58 +0,0 @@
use <../functions.scad>
include <../settings.scad>
// This is an imperfect attempt to clone the MT3 profile
module mt3_row(row=3, column=0, deep_dish=false) {
$key_shape_type = "sculpted_square";
$bottom_key_width = 18.35;
$bottom_key_height = 18.6;
$width_difference = ($bottom_key_width - 13.0);
$height_difference = ($bottom_key_height - 13.0);
$dish_type = "squared spherical";
$dish_depth = deep_dish ? 1.6 : 1.2;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 10;
$corner_radius = 0.0125;
$more_side_sculpting_factor = 0.75;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2) * 2;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
if (row == 0){
// TODO I didn't change these yet
$total_depth = 14.7 + extra_height;
$top_tilt = -12.5;
children();
} else if (row == 1) {
$total_depth = 13.1 + extra_height;
$top_tilt = -6;
children();
} else if (row == 2) {
$total_depth = 10.7 + extra_height;
$top_tilt = -6;
children();
} else if (row == 3) {
$total_depth = 10.7 + extra_height;
$top_tilt = 6;
children();
} else if (row == 4){
$total_depth = 11.6 + extra_height;
$top_tilt = 12;
children();
} else if (row >= 5) {
$total_depth = 11.6 + extra_height;
$top_tilt = 0;
children();
} else {
children();
}
}

View File

@ -1,7 +1,4 @@
use <../functions.scad>
include <../settings.scad>
module oem_row(row=3, column = 0) {
module oem_row(n=3) {
$bottom_key_width = 18.05;
$bottom_key_height = 18.05;
$width_difference = 5.8;
@ -13,27 +10,24 @@ module oem_row(row=3, column = 0) {
$top_skew = 1.75;
$stem_inset = 1.2;
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
if (row == 5 || row == 0) {
$total_depth = 11.2 + extra_height;
if (n == 5) {
$total_depth = 11.2;
$top_tilt = -3;
children();
} else if (row == 1) {
$total_depth = 9.45 + extra_height;
} else if (n == 1) {
$total_depth = 9.45;
$top_tilt = 1;
children();
} else if (row == 2) {
$total_depth = 9 + extra_height;
} else if (n == 2) {
$total_depth = 9;
$top_tilt = 6;
children();
} else if (row == 3) {
$total_depth = 9.25 + extra_height;
} else if (n == 3) {
$total_depth = 9.25;
$top_tilt = 9;
children();
} else if (row == 4) {
$total_depth = 9.25 + extra_height;
} else if (n == 4) {
$total_depth = 9.25;
$top_tilt = 10;
children();
} else {

View File

@ -1,68 +0,0 @@
use <../functions.scad>
include <../settings.scad>
include <../constants.scad>
// Regular polygon shapes CIRCUMSCRIBE the sphere of diameter $bottom_key_width
// This is to make tiling them easier, like in the case of hexagonal keycaps etc
// this function doesn't set the key shape, so you can't use it directly without some fiddling
module regular_polygon_row(n=3, column=0) {
$bottom_key_width = $unit - 0.5;
$bottom_key_height = $unit - 0.5;
$width_difference = 0;
$height_difference = 0;
$dish_type = "spherical";
$dish_depth = 0.85;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 1;
$corner_radius = 1;
// this is _incredibly_ intensive
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
base_depth = 7.5;
if (n <= 1){
$total_depth = base_depth + 2.5 + extra_height;
$top_tilt = -13;
children();
} else if (n == 2) {
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = -7;
children();
} else if (n == 3) {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
} else if (n == 4){
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = 7;
children();
} else {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
}
}
module hexagonal_row(n=3, column=0) {
$key_shape_type = "hexagon";
regular_polygon_row(n,column) {
children();
}
}
module octagonal_row(n=3, column=0) {
$key_shape_type = "octagon";
regular_polygon_row(n, column) {
children();
}
}

View File

@ -1,7 +1,4 @@
use <../functions.scad>
include <../settings.scad>
module sa_row(n=3, column=0) {
module sa_row(n=3) {
$key_shape_type = "sculpted_square";
$bottom_key_width = 18.4;
$bottom_key_height = 18.4;
@ -13,42 +10,30 @@ module sa_row(n=3, column=0) {
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 10;
$corner_radius = 1;
$more_side_sculpting_factor = 0.4;
$side_sculpting = function(progress) (1 - progress) * 4.5;
$corner_sculpting = function(progress) pow(progress, 2);
// this is _incredibly_ intensive
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
// might wanna change this if you don't minkowski
// do you even minkowski bro
$corner_radius = 0.25;
// 5th row is usually unsculpted or the same as the row below it
// making a super-sculpted top row (or bottom row!) would be real easy
// bottom row would just be 13 tilt and 14.89 total depth
// top row would be something new entirely - 18 tilt maybe?
if (n <= 1){
$total_depth = 14.89 + extra_height;
if (n == 1 || n == 5){
$total_depth = 14.89;
$top_tilt = -13;
children();
} else if (n == 2) {
$total_depth = 12.925 + extra_height;
$total_depth = 12.925;
$top_tilt = -7;
children();
} else if (n == 3) {
$total_depth = 12.5 + extra_height;
} else if (n == 3 || n == 5) {
$total_depth = 12.5;
$top_tilt = 0;
children();
} else if (n == 4){
$total_depth = 12.925 + extra_height;
$total_depth = 12.925;
$top_tilt = 7;
children();
} else {
$total_depth = 12.5 + extra_height;
$top_tilt = 0;
children();
}
}

View File

@ -1,59 +0,0 @@
use <../functions.scad>
include <../settings.scad>
include <../constants.scad>
// Regular polygon shapes CIRCUMSCRIBE the sphere of diameter $bottom_key_width
// This is to make tiling them easier, like in the case of hexagonal keycaps etc
// this function doesn't set the key shape, so you can't use it directly without some fiddling
module typewriter_row(n=3, column=0) {
$bottom_key_width = $unit - 0.5;
$bottom_key_height = $unit - 0.5;
$width_difference = 0;
$height_difference = 0;
$dish_type = "spherical";
$key_shape_type = "circular";
$inverted_dish = true;
$stem_inset = -4.5;
$stem_throw = 5;
$dish_depth = 4;
$dish_skew_x = 0;
$dish_skew_y = 0;
$top_skew = 0;
$height_slices = 1;
$stem_support_type = "disable";
// $corner_radius = 1;
// this is _incredibly_ intensive
/* $rounded_key = true; */
$top_tilt_y = side_tilt(column);
extra_height = $double_sculpted ? extra_side_tilt_height(column) : 0;
base_depth = 3.5;
if (n <= 1){
$total_depth = base_depth + 2.5 + extra_height;
$top_tilt = -13;
children();
} else if (n == 2) {
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = -7;
children();
} else if (n == 3) {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
} else if (n == 4){
$total_depth = base_depth + 0.5 + extra_height;
$top_tilt = 7;
children();
} else {
$total_depth = base_depth + extra_height;
$top_tilt = 0;
children();
}
}

View File

@ -17,10 +17,6 @@ module 1_5u() {
u(1.5) children();
}
module 1_75u(){
u(1.75) children();
}
module 2u() {
u(2) children();
}
@ -29,10 +25,6 @@ module 2_25u() {
u(2.25) children();
}
module 2_50u() {
u(2.5) children();
}
module 2_75u() {
u(2.75) children();
}

View File

@ -1,14 +1,10 @@
// kind of a catch-all at this point for any directive that doesn't fit in the other files
include <constants.scad>
//TODO duplicate def to not make this a special var. maybe not worth it
unit = 19.05;
module translate_u(x=0, y=0, z=0){
translate([x * $unit, y*$unit, z*$unit]) children();
}
module no_stem_support() {
$stem_support_type = "disable";
children();
translate([x * unit, y*unit, z*unit]) children();
}
module brimmed_stem_support(height = 0.4) {
@ -43,15 +39,9 @@ module rotated() {
children();
}
module vertically_stabilized(mm=12, vertical=true, type=undef) {
stabilized(mm,vertical,type) {
children();
}
}
module stabilized(mm=12, vertical = false, type=undef) {
if (vertical) {
$stabilizer_type = (type ? type : ($stabilizer_type ? $stabilizer_type : "costar_stabilizer"));
$stabilizer_type = type ? type : $stabilizer_type ? $stabilizer_type : "costar_stabilizer";
$stabilizers = [
[0, mm],
[0, -mm]
@ -59,8 +49,7 @@ module stabilized(mm=12, vertical = false, type=undef) {
children();
} else {
$stabilizer_type = (type ? type : ($stabilizer_type ? $stabilizer_type : "costar_stabilizer"));
$stabilizer_type = type ? type : $stabilizer_type ? $stabilizer_type : "costar_stabilizer";
$stabilizers = [
[mm, 0],
@ -91,58 +80,36 @@ module blank() {
children();
}
module cherry(slop = undef) {
$stem_slop = slop != undef ? slop : $stem_slop;
module cherry(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "cherry";
children();
}
module alps(slop = undef) {
$stem_slop = slop != undef ? slop : $stem_slop;
module alps(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "alps";
children();
}
module rounded_cherry(slop = undef) {
$stem_slop = slop != undef ? slop : $stem_slop;
module rounded_cherry(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "rounded_cherry";
children();
}
module box_cherry(slop = undef) {
$stem_slop = slop != undef ? slop : $stem_slop;
module box_cherry(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "box_cherry";
children();
}
module choc(slop = 0.05) {
echo("WARN:\n\n * choc support is experimental.\n * $stem_slop is overridden.\n * it is also recommended to print them upside down if you can\n\n");
$stem_throw = 3;
$stem_slop = slop;
$bottom_key_width = 18;
$bottom_key_height = 17;
module choc(slop) {
$stem_slop = slop ? slop : $stem_slop;
$stem_type = "choc";
children();
}
// a hacky way to make "low profile" keycaps
module low_profile() {
$width_difference = $width_difference / 1.5;
$height_difference = $height_difference / 1.5;
// helps tilted keycaps not have holes if worst comes to worst
$inner_shape_type = "dished";
$top_tilt = $top_tilt / 1.25;
$total_depth = ($total_depth / 2) < 7 ? 7 : $total_depth / 2;
// just to make sure
$stem_throw = 3;
children();
}
module flared_support() {
$support_type = "flared";
children();
@ -158,17 +125,9 @@ module flat_support() {
children();
}
module legend(text, position=[0,0], size=undef, font=undef) {
module legend(text, position=[0,0], size=undef) {
font_size = size == undef ? $font_size : size;
font_face = font == undef ? $font : font;
$legends = [for(L=[$legends, [[text, position, font_size, font_face]]], a=L) a];
children();
}
module front_legend(text, position=[0,0], size=undef, font=undef) {
font_size = size == undef ? $font_size : size;
font_face = font == undef ? $font : font;
$front_legends = [for(L=[$front_legends, [[text, position, font_size, font_face]]], a=L) a];
$legends = [for(L=[$legends, [[text, position, font_size]]], a=L) a];
children();
}
@ -178,113 +137,10 @@ module bump(depth=undef) {
children();
}
// kinda dirty, but it works
// might not work great with fully sculpted profiles yet
// NOTE: this needs to come after row declarations or it won't work
module upside_down() {
if ($stem_inner_slop != 0) {
echo("it is recommended you set inner stem slop to 0 when you use upside_down()");
}
$stem_support_type = "disable";
// $top_tilt*2 because top_placement rotates by top_tilt for us
// first rotate 180 to get the keycaps to face the same direction
rotate([0,0,180]) top_placement() rotate([180+$top_tilt*2,0,0]) {
children();
}
}
module sideways() {
$stem_support_type = "disable";
$key_shape_type = "flat_sided_square";
$dish_overdraw_width = abs(extra_keytop_length_for_flat_sides());
extra_y_rotation = atan2($width_difference/2,$total_depth); // TODO assumes centered top
translate([0,0,cos(extra_y_rotation) * total_key_width()/2])
rotate([0,90 + extra_y_rotation ,0]) children();
}
/* this is hard to explain. we want the angle of the back of the keycap.
* first we draw a line at the back of the keycap perpendicular to the ground.
* then we extend the line created by the slope of the keytop to that line
* the angle of the latter line off the ground is $top_tilt, and
* you can create a right triangle with the adjacent edge being $bottom_key_height/2
* raised up $total_depth. this gets you x, the component of the extended
* keytop slope line, and y, a component of the first perpendicular line.
* by a very similar triangle you get r and s, where x is the hypotenuse of that
* right triangle and the right angle is again against the first perpendicular line
* s is the opposite line in the right triangle required to find q, the angle
* of the back. if you subtract r from $total_depth plus y you can now use these
* two values in atan to find the angle of interest.
*/
module backside() {
$stem_support_type = "disable";
// $key_shape_type = "flat_sided_square";
a = $bottom_key_height;
b = $total_depth;
c = top_total_key_height();
x = (a / 2 - $top_skew) / cos(-$top_tilt) - c / 2;
y = sin(-$top_tilt) * (x + c/2);
r = sin(-$top_tilt) * x;
s = cos(-$top_tilt) * x;
q = atan2(s, (y + b - r));
translate([0,0,cos(q) * total_key_height()/2])
rotate([-90 - q, 0,0]) children();
}
// this is just backside with a few signs switched
module frontside() {
$stem_support_type = "disable";
// $key_shape_type = "flat_sided_square";
a = $bottom_key_height;
b = $total_depth;
c = top_total_key_height();
x = (a / 2 + $top_skew) / cos($top_tilt) - c / 2;
y = sin($top_tilt) * (x + c/2);
r = sin($top_tilt) * x;
s = cos($top_tilt) * x;
q = atan2(s, (y + b - r));
translate([0,0,cos(q) * total_key_height()/2])
rotate([90 + q, 0,0]) children();
}
// emulating the % modifier.
// since we use custom colors, just using the % modifier doesn't work
module debug() {
$primary_color = [0.5,0.5,0.5,0.2];
$secondary_color = [0.5,0.5,0.5,0.2];
$tertiary_color = [0.5,0.5,0.5,0.2];
$quaternary_color = [0.5,0.5,0.5,0.2];
%children();
}
// auto-place children in a grid.
// For this to work all children have to be single keys, no for loops etc
module auto_place() {
num_children = $children;
row_size = round(pow(num_children, 0.5));
for (child_index = [0:num_children-1]) {
x = child_index % row_size;
y = floor(child_index / row_size);
translate_u(x,-y) children(child_index);
}
}
// suggested settings for resin prints
module resin() {
$stem_slop = 0;
$stem_inner_slop = 0;
$stem_support_type = "disable";
module low_profile() {
/* $total_depth = 5.35; */
/* extra ugly hack right now to make sure we don't generate keycaps with insufficient throw */
/* $total_depth = ($total_depth / 2) < 6 ? 6 : $total_depth / 2; */
$stem_throw = 3;
children();
}

View File

@ -1,10 +1,6 @@
include <functions.scad>
use <key_sizes.scad>
use <key_transformations.scad>
module spacebar() {
$inverted_dish = $dish_type != "disable";
$dish_type = $dish_type != "disable" ? "sideways cylindrical" : "disable";
$inverted_dish = true;
$dish_type = "sideways cylindrical";
6_25u() stabilized(mm=50) children();
}
@ -47,19 +43,15 @@ module iso_enter() {
$key_length = 1.5;
$key_height = 2;
$dish_offset_x = -(unit_length(1.5) - unit_length(1.25))/2;
/* $top_tilt = 0; */
$stem_support_type = "disable";
$top_tilt = 0;
$key_shape_type = "iso_enter";
$hull_shape_type = "skin";
$linear_extrude_shape = true;
$linear_extrude_height_adjustment = 19.05 * 0.5;
// this equals (unit_length(1.5) - unit_length(1.25)) / 2
/* $dish_overdraw_width = 2.38125; */
$dish_overdraw_width = 2.38125;
render() {
stabilized(vertical=true) {
children();
}
}
}

View File

@ -1,21 +0,0 @@
include <../layout.scad>
60_percent_default_layout = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,2],
[1.5,1,1,1,1,1,1,1,1,1,1,1,1,1.5],
[1.75,1,1,1,1,1,1,1,1,1,1,1,2.25],
[2.25,1,1,1,1,1,1,1,1,1,1,2.75],
[1.25,1.25,1.25,6.25,1.25,1.25,1.25,1.25]
];
60_percent_legends = [
["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "⌫"],
["tab", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "\\"],
["caps", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "enter"],
["shift", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "shift"],
["ctl", "win", "alt", "", "mnu", "win", "alt", "ctl"],
];
module 60_percent_default(profile) {
layout(60_percent_default_layout, profile, 60_percent_legends, row_sculpting_offset=1) children();
}

View File

@ -1,26 +0,0 @@
include <../layout.scad>
dactyl_manuform_4x6_main = [
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1]
];
dactyl_manuform_4x6_thumbs_l = [
[1.25, 1.25],
[-0.25, 1, 1],
[-0.25, 1, 1]
];
dactyl_manuform_4x6_thumbs_r = [
[1.25, 1.25],
[-0.25, 1, 1],
[-0.25, 1, 1]
];
module dactyl_manuform_4x6(profile) {
layout(dactyl_manuform_4x6_main, profile) children();
translate_u(3,-5) rotate([0,0,25])layout(dactyl_manuform_4x6_thumbs_l, profile, row_override=3) children();
translate_u(7.75,-3.95) rotate([0,0,-25])layout(dactyl_manuform_4x6_thumbs_r, profile, row_override=3) children();
}

View File

@ -1,64 +0,0 @@
include <../layout.scad>
dactyl_manuform_4x6_main = [
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[-1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1]
];
dactyl_manuform_4x6_thumbs_l = [
[1.25, 1.25],
[-0.25, 1, 1],
[-0.25, 1, 1]
];
dactyl_manuform_4x6_thumbs_r = [
[1.25, 1.25],
[-0.25, 1, 1],
[-0.25, 1, 1]
];
dactyl_manuform_4x6_main_legends = [
["ESC", "Q", "W", "E", "R", "T", "", "Y", "U", "I", "O", "P", "{["],
["LS", "A", "S", "D", "F", "G", "", "H", "J", "K", "L", ";:", "'\""],
["TAB", "Z", "X", "C", "V", "B", "", "N", "M", ",<", ".>", "/?", "\\|"],
["", "", "CAPS", "T(1)", "", "", "", "", "", "T(2)", "]}", "", ""]
];
dactyl_manuform_4x6_main_front_legends = [
["F1", "F2", "F3", "F4", "F5", "F6", "", "F7", "F8", "F9", "F10", "F11", "F12"],
["", "", "", "", "", "PGUP", "", "", "UP", "", "", "", ""],
["", "", "", "", "", "PGDN", "", "LFT", "DWN", "RHT", "", "", ""],
["", "", "", "T(0)", "", "", "", "", "", "T(2)", "", "", ""]
];
dactyl_manuform_4x6_thumbs_l_legends = [
["~`", "LCTL"],
["", "RALT", "LCMD"],
["", "MEH", "T(2)"]
];
dactyl_manuform_4x6_thumbs_l_front_legends = [
["", ""],
["", "PSC", "LCMD"],
["", "", "TEMP"]
];
dactyl_manuform_4x6_thumbs_r_legends = [
["", "BKSP"],
["", "ENTR", "CP"],
["", "T(1)", "PST"]
];
dactyl_manuform_4x6_thumbs_r_front_legends = [
["", ""],
["", "", ""],
["", "TEMP", ""]
];
module dactyl_manuform_4x6_legends(profile, row_sculpting_offset=1, column_override=undef) {
layout(dactyl_manuform_4x6_main, profile, legends=dactyl_manuform_4x6_main_legends, front_legends=dactyl_manuform_4x6_main_front_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave") children();
translate_u(3,-5) rotate([0,0,25]) layout(dactyl_manuform_4x6_thumbs_l, profile, legends=dactyl_manuform_4x6_thumbs_l_legends, front_legends=dactyl_manuform_4x6_thumbs_l_front_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave") children();
translate_u(7.75,-3.95) rotate([0,0,-25]) layout(dactyl_manuform_4x6_thumbs_r, profile, legends=dactyl_manuform_4x6_thumbs_r_legends, front_legends=dactyl_manuform_4x6_thumbs_r_front_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave") children();
}

View File

@ -1,18 +0,0 @@
include <../layout.scad>
// negative numbers are used for spacing
gherkin_default_layout = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
];
gherkin_default_legends = [
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "h", "j", "k", "l", ";"],
["z", "x", "c", "v", "b", "n", "m", ",", ".", "/"],
];
module gherkin_default(profile) {
layout(gherkin_default_layout, profile, legends=gherkin_default_legends, row_sculpting_offset=1, row_override=3) children();
}

View File

@ -1,22 +0,0 @@
include <../layout.scad>
// negative numbers are used for spacing
gherkin_bump_mapping = [
[1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1],
[-1, -1, -1, -1, 2, -1, -1, -1, -1],
];
gherkin_bump_legends = [
["q", "w", "e", "r", "t", "", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "", "h", "j", "k", "l", ";"],
["z", "x", "c", "v", "b", "", "n", "m", ",", ".", "/"],
["", "", "", "", "", "", "", "", ""],
];
module gherkin_bump_layout(profile, row_sculpting_offset=1, column_override=undef) {
layout(gherkin_bump_mapping, profile, legends=gherkin_bump_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave") {
children();
};
}

View File

@ -1,21 +0,0 @@
include <../layout.scad>
hhkb_layout = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1.5,1,1,1,1,1,1,1,1,1,1,1,1,1.5],
[1.75,1,1,1,1,1,1,1,1,1,1,1,2.25],
[2.25,1,1,1,1,1,1,1,1,1,1,1.75,1],
[-1.5,1,1.5,6,1.5,1]
];
hhkb_legends = [
["Esc", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "\\", "`"],
["Tab", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "[", "]", "Delete"],
["Ctrl", "a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "Return"],
["Shift", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/", "Shift", "Fn"],
["", "Alt", "Cmd", "", "Cmd", "Alt"],
];
module hhkb_default(profile) {
layout(hhkb_layout, profile, hhkb_legends) children();
}

View File

@ -1,134 +0,0 @@
use <../key_transformations.scad>
use <../key_profiles.scad>
use <../key_sizes.scad>
use <../key_types.scad>
// sums all values, unless a value is negative, in which case it makes it positive
// dirty hack to allow for large gaps in keysets
function abs_sum(list, x=0) =
len(list) <= 1 ?
x + abs(list[0]) :
abs_sum([for (x = [1: len(list) - 1]) list[x]], x+abs(list[0]));
function 2hands(index, total) = ((index+0.5) % (total/2)) - (total/4);
function cresting_wave(index, total, mod=4) = (index < total/2) ? (((index + 0.5) / total)*mod) : -(mod - ((index + 0.5) / total * mod));
function 1hand(index, total) = (index % (total)) - (total/2);
// chooses between all the sculpting options
// checks if column is smack in middle of row - if so, no sculpting
// since we are zero indexed, the 7th row has an index of 6 and is the center of 13. 6*2+1 = 13
function double_sculpted_column(column, row_length, column_sculpt_profile) =
(column*2 + 1 == row_length) ?
0 : (column_sculpt_profile == "2hands") ?
2hands(column, row_length) : (column_sculpt_profile == "1hand") ?
1hand(column, row_length) : (column_sculpt_profile == "cresting_wave") ?
cresting_wave(column, row_length) : 0;
module layout(list, profile="dcs", legends=undef, front_legends=undef, row_sculpting_offset=0, row_override=undef, column_sculpt_profile="2hands", column_override=undef) {
for (row = [0:len(list)-1]){
/* echo("**ROW**:", row); */
row_length = len(list[row]);
for(column = column_override ? column_override : [0:len(list[row])-1]) {
row_sculpting = (row_override != undef ? row_override : row) + row_sculpting_offset;
key_length = list[row][column];
column_value = double_sculpted_column(column, row_length, column_sculpt_profile);
column_distance = abs_sum([for (x = [0 : column]) list[row][x]]);
/* echo("\t**COLUMN**", "column_value", column_value, "column_distance", column_distance); */
// supports negative values for nonexistent keys
if (key_length >= 1) {
translate_u(column_distance - (key_length/2), -row) {
key_profile(profile, row_sculpting, column_value) u(key_length) legend(legends ? legends[row][column] : "") front_legend(front_legends ? front_legends[row][column] : "") cherry() { // (row+4) % 5 + 1
$row = row;
$column = column;
if (key_length == 6.25) {
spacebar() {
if ($children) {
children();
} else {
key();
}
}
} else if (key_length == 2.25) {
lshift() {
if ($children) {
children();
} else {
key();
}
}
} else if (key_length == 2) {
backspace() {
if ($children) {
children();
} else {
key();
}
}
} else if (key_length == 2.75) {
rshift() {
if ($children) {
children();
} else {
key();
}
}
} else {
{
if ($children) {
children();
} else {
key();
}
}
}
}
}
}
}
}
}
// much simpler, decoupled layout function
// requires more setup - it only does what is in the layout array, which is translate
// and key length. you have to do row / column profile yourself and always pass
// children()
// this is probably the way we'll go forward
module simple_layout(list) {
for (row = [0:len(list)-1]){
/* echo("**ROW**:", row); */
for(column = [0:len(list[row])-1]) {
key_length = list[row][column];
column_distance = abs_sum([for (x = [0 : column]) list[row][x]]);
/* echo("\t**COLUMN**", "column_value", column_value, "column_distance", column_distance); */
// supports negative values for nonexistent keys
if (key_length >= 1) {
translate_u(column_distance - (key_length/2), -row) {
u(key_length) { // (row+4) % 5 + 1
$row = row;
$column = column;
if (key_length == 6.25) {
spacebar() children();
} else if (key_length == 2.25) {
lshift() children();
} else if (key_length == 2) {
backspace() children();
} else if (key_length == 2.75) {
rshift() children();
} else {
children();
}
}
}
}
}
}
}

View File

@ -1,13 +0,0 @@
include <../layout.scad>
// negative numbers are used for spacing
lets_split_layout = [
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1]
];
module lets_split_default(profile) {
layout(lets_split_layout, profile, row_sculpting_offset=1) children();
}

View File

@ -1,23 +0,0 @@
include <../layout.scad>
// 0's are to make space for a middle row for just the spacebar so that it
// isn't sculpted with double sculpting. the 0's in the first three rows
// don't _need_ to be there but it's nice to keep track
planck_default_layout = [
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1]
];
planck_default_legends = [
[ "⇥", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "⌫"],
["Esc", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "⏎"],
[ "⇧", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "⇧"],
[ "Fn", "Ctl", "Alt", "Cmd", "Lwr", "", "", "RSE", "←", "↓", "↑", "→"],
];
module planck_default(profile, column_sculpt_profile="2hands") {
layout(planck_default_layout, profile, row_sculpting_offset=1, column_sculpt_profile=column_sculpt_profile) children();
}

View File

@ -1,15 +0,0 @@
include <../layout.scad>
// 0's are to make space for a middle row for just the spacebar so that it
// isn't sculpted with double sculpting. the 0's in the first three rows
// don't _need_ to be there but it's nice to keep track
planck_layout_mapping = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
];
module planck_mit(profile) {
layout(planck_layout_mapping, profile, row_sculpting_offset=1) children();
}

View File

@ -1,29 +0,0 @@
// No support for stabilizers yet - but should be easy enough
// Won't work well for split layouts. or, it'll work fine - but it'll only be
// one plate.
// each corner
module unit_corners(height = 3, radius=3, $fn=24) {
positions = [
[-$key_length/2, -$key_height/2],
[$key_length/2, -$key_height/2],
[$key_length/2, $key_height/2],
[-$key_length/2, $key_height/2],
];
for (position = positions) {
translate_u(position.x, position.y) cylinder(h=height, r=radius, $fn=$fn);
}
}
module switch_hole() {
cube(14, center=true);
}
module plate(layout_object) {
difference() {
hull() {
simple_layout(layout_object) unit_corners();
}
simple_layout(layout_object) switch_hole();
}
}

View File

@ -1,21 +0,0 @@
include <../layout.scad>
preonic_default_layout = [
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1]
];
preonic_default_legends = [
[ "`", "1", "2", "3", "4", "5", "", "6", "7", "8", "9", "0", "-"],
[ "⇥", "Q", "W", "E", "R", "T", "", "Y", "U", "I", "O", "P", "⌫"],
["Esc", "A", "S", "D", "F", "G", "", "H", "J", "K", "L", ";", "⏎"],
[ "⇧", "Z", "X", "C", "V", "B", "", "N", "M", ",", ".", "/", "⇧"],
[ "Fn", "Ctl", "Alt", "Cmd", "Lwr", "", "", "", "RSE", "←", "↓", "↑", "→"],
];
module preonic_default(profile, column_sculpt_profile="2hands") {
layout(preonic_default_layout, profile, column_sculpt_profile=column_sculpt_profile) children();
}

View File

@ -1,21 +0,0 @@
include <../layout.scad>
preonic_mit_layout = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
];
preonic_mit_legends = [
[ "`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-"],
[ "⇥", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "⌫"],
["Esc", "A", "S", "D", "F", "G", "H", "J", "K", "L", ";", "⏎"],
[ "⇧", "Z", "X", "C", "V", "B", "N", "M", ",", ".", "/", "⇧"],
[ "Fn", "Ctl", "Alt", "Cmd", "Lwr", "", "", "RSE", "←", "↓", "↑", "→"],
];
module planck_mit(profile) {
layout(preonic_mit_layout, profile, legends=preonic_mit_legends, row_sculpting_offset=1) children();
}

View File

@ -1,19 +0,0 @@
include <../layout.scad>
project_zen_main = [
[1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5],
[1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5],
[1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5],
[1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5],
[1.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5]
];
project_zen_thumbs = [
[2,2],
[2,2],
];
module project_zen_default(profile) {
layout(project_zen_main, profile) children();
translate_u(4.5,-5) layout(project_zen_thumbs, profile, row_override=3) children();
}

View File

@ -1,79 +0,0 @@
// thanks Paul https://github.com/openscad/list-comprehension-demos/
include <../functions.scad>
module 3d_surface(size=$3d_surface_size, step=$3d_surface_step, bottom=-SMALLEST_POSSIBLE){
function p(x, y) = [ x, y, max(0,$surface_function(x, y) * $corner_smoothing_surface_function(x,y)) ];
function p0(x, y) = [ x, y, bottom ];
function rev(b, v) = b ? v : [ v[3], v[2], v[1], v[0] ];
function face(x, y) = [ p(x, y + step), p(x + step, y + step), p(x + step, y), p(x + step, y), p(x, y), p(x, y + step) ];
function fan(a, i) =
a == 0 ? [ [ 0, 0, bottom ], [ i, -size, bottom ], [ i + step, -size, bottom ] ]
: a == 1 ? [ [ 0, 0, bottom ], [ i + step, size, bottom ], [ i, size, bottom ] ]
: a == 2 ? [ [ 0, 0, bottom ], [ -size, i + step, bottom ], [ -size, i, bottom ] ]
: [ [ 0, 0, bottom ], [ size, i, bottom ], [ size, i + step, bottom ] ];
function sidex(x, y) = [ p0(x, y), p(x, y), p(x + step, y), p0(x + step, y) ];
function sidey(x, y) = [ p0(x, y), p(x, y), p(x, y + step), p0(x, y + step) ];
points = flatten(concat(
// top surface
[ for (x = [ -size : step : size - step ], y = [ -size : step : size - step ]) face(x, y) ],
// bottom surface as triangle fan
[ for (a = [ 0 : 3 ], i = [ -size : step : size - step ]) fan(a, i) ],
// sides
[ for (x = [ -size : step : size - step ], y = [ -size, size ]) rev(y < 0, sidex(x, y)) ],
[ for (y = [ -size : step : size - step ], x = [ -size, size ]) rev(x > 0, sidey(x, y)) ]
));
tcount = 2 * pow(2 * size / step, 2) + 8 * size / step;
scount = 8 * size / step;
tfaces = [ for (a = [ 0 : 3 : 3 * (tcount - 1) ] ) [ a, a + 1, a + 2 ] ];
sfaces = [ for (a = [ 3 * tcount : 4 : 3 * tcount + 4 * scount ] ) [ a, a + 1, a + 2, a + 3 ] ];
faces = concat(tfaces, sfaces);
polyhedron(points, faces, convexity = 8);
}
module polar_3d_surface(size, step, bottom=-SMALLEST_POSSIBLE){
function to_polar(q, size) = q * (90 / size);
function p(x, y) = [
$surface_distribution_function(to_polar(x, size), size),
$surface_distribution_function(to_polar(y, size), size),
max(0,$surface_function($surface_distribution_function(to_polar(x, size), size), $surface_distribution_function(to_polar(y, size), size)) * $corner_smoothing_surface_function($surface_distribution_function(to_polar(x, size), size), $surface_distribution_function(to_polar(y, size), size)))
];
function p0(x, y) = [ x, y, bottom ];
function rev(b, v) = b ? v : [ v[3], v[2], v[1], v[0] ];
function face(x, y) = [ p(x, y + step), p(x + step, y + step), p(x + step, y), p(x + step, y), p(x, y), p(x, y + step) ];
function fan(a, i) =
a == 0 ? [ [ 0, 0, bottom ], [ i, -size, bottom ], [ i + step, -size, bottom ] ]
: a == 1 ? [ [ 0, 0, bottom ], [ i + step, size, bottom ], [ i, size, bottom ] ]
: a == 2 ? [ [ 0, 0, bottom ], [ -size, i + step, bottom ], [ -size, i, bottom ] ]
: [ [ 0, 0, bottom ], [ size, i, bottom ], [ size, i + step, bottom ] ];
function sidex(x, y) = [ p0(x, y), p(x, y), p(x + step, y), p0(x + step, y) ];
function sidey(x, y) = [ p0(x, y), p(x, y), p(x, y + step), p0(x, y + step) ];
points = flatten(concat(
// top surface
[ for (x = [ -size : step : size - step ], y = [ -size : step : size - step ]) face(x, y) ],
// bottom surface as triangle fan
[ for (a = [ 0 : 3 ], i = [ -size : step : size - step ]) fan(a, i) ],
// sides
[ for (x = [ -size : step : size - step ], y = [ -size, size ]) rev(y < 0, sidex(x, y)) ],
[ for (y = [ -size : step : size - step ], x = [ -size, size ]) rev(x > 0, sidey(x, y)) ]
));
tcount = 2 * pow(2 * size / step, 2) + 8 * size / step;
scount = 8 * size / step;
tfaces = [ for (a = [ 0 : 3 : 3 * (tcount - 1) ] ) [ a, a + 1, a + 2 ] ];
sfaces = [ for (a = [ 3 * tcount : 4 : 3 * tcount + 4 * scount ] ) [ a, a + 1, a + 2, a + 3 ] ];
faces = concat(tfaces, sfaces);
polyhedron(points, faces, convexity = 8);
}
// defaults, overridden in functions.scad
// $surface_distribution_function = function(dim, size) sin(dim) * size;
// $surface_function = function(x,y) (sin(acos(x/$3d_surface_size))) * sin(acos(y/$3d_surface_size));

View File

@ -1,687 +0,0 @@
// Library: round-anything
// Version: 1.0
// Author: IrevDev
// Contributors: TLC123
// Copyright: 2020
// License: MIT
function addZcoord(points,displacement)=[for(i=[0:len(points)-1])[points[i].x,points[i].y, displacement]];
function translate3Dcoords(points,tran=[0,0,0],mult=[1,1,1])=[for(i=[0:len(points)-1])[
(points[i].x*mult.x)+tran.x,
(points[i].y*mult.y)+tran.y,
(points[i].z*mult.z)+tran.z
]];
function offsetPolygonPoints(points, offset=0)=
// Work sthe same as the offset does, except for the fact that instead of a 2d shape
// It works directly on polygon points
// It returns the same number of points just offset into or, away from the original shape.
// points= a series of x,y points[[x1,y1],[x2,y2],...]
// offset= amount to offset by, negative numbers go inwards into the shape, positive numbers go out
// return= a series of x,y points[[x1,y1],[x2,y2],...]
let(
isCWorCCW=sign(offset)*CWorCCW(points)*-1,
lp=len(points)
)
[for(i=[0:lp-1]) parallelFollow([
points[listWrap(i-1,lp)],
points[i],
points[listWrap(i+1,lp)],
],thick=offset,mode=isCWorCCW)];
function makeCurvedPartOfPolyHedron(radiiPoints,r,fn,minR=0.01)=
// this is a private function that I'm not expecting library users to use directly
// radiiPoints= serise of x, y, r points
// r= radius of curve that will be put on the end of the extrusion
// fn= amount of subdivisions
// minR= if one of the points in radiiPoints is less than r, it's likely to converge and form a sharp edge,
// the min radius on these converged edges can be controled with minR, though because of legacy reasons it can't be 0, but can be a very small number.
// return= array of [polyhedronPoints, Polyhedronfaces, theLength of a singe layer in the curve]
let(
lp=len(radiiPoints),
radii=[for(i=[0:lp-1])radiiPoints[i].z],
isCWorCCWOverall=CWorCCW(radiiPoints),
dir=sign(r),
absR=abs(r),
fractionOffLp=1-1/fn,
allPoints=[for(fraction=[0:1/fn:1])
let(
iterationOffset=dir*sqrt(sq(absR)-sq(fraction*absR))-dir*absR,
theOffsetPoints=offsetPolygonPoints(radiiPoints,iterationOffset),
polyRoundOffsetPoints=[for(i=[0:lp-1])
let(
pointsAboutCurrent=[
theOffsetPoints[listWrap(i-1,lp)],
theOffsetPoints[i],
theOffsetPoints[listWrap(i+1,lp)]
],
isCWorCCWLocal=CWorCCW(pointsAboutCurrent),
isInternalRadius=(isCWorCCWLocal*isCWorCCWOverall)==-1,
// the radius names are only true for positive r,
// when are r is negative increasingRadius is actually decreasing and vice-vs
// increasingRadiusWithPositiveR is just to verbose of a variable name for my liking
increasingRadius=max(radii[i]-iterationOffset, minR),
decreasingRadius=max(radii[i]+iterationOffset, minR)
)
[theOffsetPoints[i].x, theOffsetPoints[i].y, isInternalRadius? increasingRadius: decreasingRadius]
],
pointsForThisLayer=polyRound(polyRoundOffsetPoints,fn)
)
addZcoord(pointsForThisLayer,fraction*absR)
],
polyhedronPoints=flatternArray(allPoints),
allLp=len(allPoints),
layerLength=len(allPoints[0]),
loopToSecondLastLayer=allLp-2,
sideFaces=[for(layerIndex=[0:loopToSecondLastLayer])let(
currentLayeroffset=layerIndex*layerLength,
nextLayeroffset=(layerIndex+1)*layerLength,
layerFaces=[for(subLayerIndex=[0:layerLength-1])
[
currentLayeroffset+subLayerIndex, currentLayeroffset + listWrap(subLayerIndex+1,layerLength), nextLayeroffset+listWrap(subLayerIndex+1,layerLength), nextLayeroffset+subLayerIndex]
]
)layerFaces],
polyhedronFaces=flatternArray(sideFaces)
)
[polyhedronPoints, polyhedronFaces, layerLength];
function flatternRecursion(array, init=[], currentIndex)=
// this is a private function, init and currentIndex are for the function's use
// only for when it's calling itself, which is why there is a simplified version flatternArray that just calls this one
// array= array to flattern by one level of nesting
// init= the array used to cancat with the next call, only for when the function calls itself
// currentIndex= so the function can keep track of how far it's progressed through the array, only for when it's calling itself
// returns= flatterned array, by one level of nesting
let(
shouldKickOffRecursion=currentIndex==undef?1:0,
isLastIndex=currentIndex+1==len(array)?1:0,
flatArray=shouldKickOffRecursion?flatternRecursion(array,[],0):
isLastIndex?concat(init,array[currentIndex]):
flatternRecursion(array,concat(init,array[currentIndex]),currentIndex+1)
)
flatArray;
function flatternArray(array)=
// public version of flatternRecursion, has simplified params to avoid confusion
// array= array to be flatterned
// return= array that been flatterend by one level of nesting
flatternRecursion(array);
function offsetAllFacesBy(array,offset)=[
// polyhedron faces are simply a list of indices to points, if your concat points together than you probably need to offset
// your faces array to points to the right place in the new list
// array= array of point indicies
// offset= number to offset all indecies by
// return= array of point indices (i.e. faces) with offset applied
for(faceIndex=[0:len(array)-1])[
for(pointIndex=[0:len(array[faceIndex])-1])array[faceIndex][pointIndex]+offset
]
];
function extrudePolygonWithRadius(radiiPoints,h=5,r1=1,r2=1,fn=4)=
// this basically calls makeCurvedPartOfPolyHedron twice to get the curved section of the final polyhedron
// and then goes about assmbling them, as the side faces and the top and bottom face caps are missing
// radiiPoints= series of [x,y,r] points,
// h= height of the extrude (total including radius sections)
// r1,r2= define the radius at the top and bottom of the extrud respectively, negative number flange out the extrude
// fn= number of subdivisions
// returns= [polyhedronPoints, polyhedronFaces]
let(
// top is the top curved part of the extrude
top=makeCurvedPartOfPolyHedron(radiiPoints,r1,fn),
topRadiusPoints=translate3Dcoords(top[0],[0,0,h-r1]),
singeLayerLength=top[2],
topRadiusFaces=top[1],
radiusPointsLength=len(topRadiusPoints), // is the same length as bottomRadiusPoints
// bottom is the bottom curved part of the extrude
bottom=makeCurvedPartOfPolyHedron(radiiPoints,r2,fn),
// Z axis needs to be multiplied by -1 to flip it so the radius is going in the right direction [1,1,-1]
bottomRadiusPoints=translate3Dcoords(bottom[0],[0,0,abs(r2)],[1,1,-1]),
// becaues the points will be all concatenated into the same array, and the bottom points come second, than
// the original indices the faces are points towards are wrong and need to have an offset applied to them
bottomRadiusFaces=offsetAllFacesBy(bottom[1],radiusPointsLength),
// all of the side panel of the extrusion, connecting points from the inner layers of each
// of the curved sections
sideFaces=[for(i=[0:singeLayerLength-1])[
i,
listWrap(i+1,singeLayerLength),
radiusPointsLength + listWrap(i+1,singeLayerLength),
radiusPointsLength + i
]],
// both of these caps are simple every point from the last layer of the radius points
topCapFace=[for(i=[0:singeLayerLength-1])radiusPointsLength-singeLayerLength+i],
bottomCapFace=[for(i=[0:singeLayerLength-1])radiusPointsLength*2-singeLayerLength+i],
finalPolyhedronPoints=concat(topRadiusPoints,bottomRadiusPoints),
finalPolyhedronFaces=concat(topRadiusFaces,bottomRadiusFaces, sideFaces, [topCapFace], [bottomCapFace])
)
[
finalPolyhedronPoints,
finalPolyhedronFaces
];
module polyRoundExtrude(radiiPoints,length=5,r1=1,r2=1,fn=10,convexity=10) {
polyhedronPointsNFaces=extrudePolygonWithRadius(radiiPoints,length,r1,r2,fn);
polyhedron(points=polyhedronPointsNFaces[0], faces=polyhedronPointsNFaces[1], convexity=convexity);
}
// testingInternals();
module testingInternals(){
//example of rounding random points, this has no current use but is a good demonstration
random=[for(i=[0:20])[rnd(0,50),rnd(0,50),/*rnd(0,30)*/1000]];
R =polyRound(random,7);
translate([-25,25,0]){
polyline(R);
}
//example of different modes of the CentreN2PointsArc() function 0=shortest arc, 1=longest arc, 2=CW, 3=CCW
p1=[0,5];p2=[10,5];centre=[5,0];
translate([60,0,0]){
color("green"){
polygon(CentreN2PointsArc(p1,p2,centre,0,20));//draws the shortest arc
}
color("cyan"){
polygon(CentreN2PointsArc(p1,p2,centre,1,20));//draws the longest arc
}
}
translate([75,0,0]){
color("purple"){
polygon(CentreN2PointsArc(p1,p2,centre,2,20));//draws the arc CW (which happens to be the short arc)
}
color("red"){
polygon(CentreN2PointsArc(p2,p1,centre,2,20));//draws the arc CW but p1 and p2 swapped order resulting in the long arc being drawn
}
}
radius=6;
radiipoints=[[0,0,0],[10,20,radius],[20,0,0]];
tangentsNcen=round3points(radiipoints);
translate([10,0,0]){
for(i=[0:2]){
color("red")translate(getpoints(radiipoints)[i])circle(1);//plots the 3 input points
color("cyan")translate(tangentsNcen[i])circle(1);//plots the two tangent poins and the circle centre
}
translate([tangentsNcen[2][0],tangentsNcen[2][1],-0.2])circle(r=radius,$fn=25);//draws the cirle
%polygon(getpoints(radiipoints));//draws a polygon
}
}
function polyRound(radiipoints,fn=5,mode=0)=
/*Takes a list of radii points of the format [x,y,radius] and rounds each point
with fn resolution
mode=0 - automatic radius limiting - DEFAULT
mode=1 - Debug, output radius reduction for automatic radius limiting
mode=2 - No radius limiting*/
let(
p=getpoints(radiipoints), //make list of coordinates without radii
Lp=len(p),
//remove the middle point of any three colinear points, otherwise adding a radius to the middle of a straigh line causes problems
radiiPointsWithoutTrippleColinear=[
for(i=[0:len(p)-1]) if(
// keep point if it isn't colinear or if the radius is 0
!isColinear(
p[listWrap(i-1,Lp)],
p[listWrap(i+0,Lp)],
p[listWrap(i+1,Lp)]
)||
p[listWrap(i+0,Lp)].z!=0
) radiipoints[listWrap(i+0,Lp)]
],
newrp2=processRadiiPoints(radiiPointsWithoutTrippleColinear),
plusMinusPointRange=mode==2?1:2,
temp=[
for(i=[0:len(newrp2)-1]) //for each point in the radii array
let(
thepoints=[for(j=[-plusMinusPointRange:plusMinusPointRange])newrp2[listWrap(i+j,len(newrp2))]],//collect 5 radii points
temp2=mode==2?round3points(thepoints,fn):round5points(thepoints,fn,mode)
)
mode==1?temp2:newrp2[i][2]==0?
[[newrp2[i][0],newrp2[i][1]]]: //return the original point if the radius is 0
CentreN2PointsArc(temp2[0],temp2[1],temp2[2],0,fn) //return the arc if everything is normal
]
)
[for (a = temp) for (b = a) b];//flattern and return the array
function round5points(rp,fn,debug=0)=
rp[2][2]==0&&debug==0?[[rp[2][0],rp[2][1]]]://return the middle point if the radius is 0
rp[2][2]==0&&debug==1?0://if debug is enabled and the radius is 0 return 0
let(
p=getpoints(rp), //get list of points
r=[for(i=[1:3]) abs(rp[i][2])],//get the centre 3 radii
//start by determining what the radius should be at point 3
//find angles at points 2 , 3 and 4
a2=cosineRuleAngle(p[0],p[1],p[2]),
a3=cosineRuleAngle(p[1],p[2],p[3]),
a4=cosineRuleAngle(p[2],p[3],p[4]),
//find the distance between points 2&3 and between points 3&4
d23=pointDist(p[1],p[2]),
d34=pointDist(p[2],p[3]),
//find the radius factors
F23=(d23*tan(a2/2)*tan(a3/2))/(r[0]*tan(a3/2)+r[1]*tan(a2/2)),
F34=(d34*tan(a3/2)*tan(a4/2))/(r[1]*tan(a4/2)+r[2]*tan(a3/2)),
newR=min(r[1],F23*r[1],F34*r[1]),//use the smallest radius
//now that the radius has been determined, find tangent points and circle centre
tangD=newR/tan(a3/2),//distance to the tangent point from p3
circD=newR/sin(a3/2),//distance to the circle centre from p3
//find the angle from the p3
an23=getAngle(p[1],p[2]),//angle from point 3 to 2
an34=getAngle(p[3],p[2]),//angle from point 3 to 4
//find tangent points
t23=[p[2][0]-cos(an23)*tangD,p[2][1]-sin(an23)*tangD],//tangent point between points 2&3
t34=[p[2][0]-cos(an34)*tangD,p[2][1]-sin(an34)*tangD],//tangent point between points 3&4
//find circle centre
tmid=getMidpoint(t23,t34),//midpoint between the two tangent points
anCen=getAngle(tmid,p[2]),//angle from point 3 to circle centre
cen=[p[2][0]-cos(anCen)*circD,p[2][1]-sin(anCen)*circD]
)
//circle center by offseting from point 3
//determine the direction of rotation
debug==1?//if debug in disabled return arc (default)
(newR-r[1]):
[t23,t34,cen];
function round3points(rp,fn)=
rp[1][2]==0?[[rp[1][0],rp[1][1]]]://return the middle point if the radius is 0
let(
p=getpoints(rp), //get list of points
r=rp[1][2],//get the centre 3 radii
ang=cosineRuleAngle(p[0],p[1],p[2]),//angle between the lines
//now that the radius has been determined, find tangent points and circle centre
tangD=r/tan(ang/2),//distance to the tangent point from p2
circD=r/sin(ang/2),//distance to the circle centre from p2
//find the angles from the p2 with respect to the postitive x axis
angleFromPoint1ToPoint2=getAngle(p[0],p[1]),
angleFromPoint2ToPoint3=getAngle(p[2],p[1]),
//find tangent points
t12=[p[1][0]-cos(angleFromPoint1ToPoint2)*tangD,p[1][1]-sin(angleFromPoint1ToPoint2)*tangD],//tangent point between points 1&2
t23=[p[1][0]-cos(angleFromPoint2ToPoint3)*tangD,p[1][1]-sin(angleFromPoint2ToPoint3)*tangD],//tangent point between points 2&3
//find circle centre
tmid=getMidpoint(t12,t23),//midpoint between the two tangent points
angCen=getAngle(tmid,p[1]),//angle from point 2 to circle centre
cen=[p[1][0]-cos(angCen)*circD,p[1][1]-sin(angCen)*circD] //circle center by offseting from point 2
)
[t12,t23,cen];
function parallelFollow(rp,thick=4,minR=1,mode=1)=
//rp[1][2]==0?[rp[1][0],rp[1][1],0]://return the middle point if the radius is 0
thick==0?[rp[1][0],rp[1][1],0]://return the middle point if the radius is 0
let(
p=getpoints(rp), //get list of points
r=thick,//get the centre 3 radii
ang=cosineRuleAngle(p[0],p[1],p[2]),//angle between the lines
//now that the radius has been determined, find tangent points and circle centre
tangD=r/tan(ang/2),//distance to the tangent point from p2
sgn=CWorCCW(rp),//rotation of the three points cw or ccw?let(sgn=mode==0?1:-1)
circD=mode*sgn*r/sin(ang/2),//distance to the circle centre from p2
//find the angles from the p2 with respect to the postitive x axis
angleFromPoint1ToPoint2=getAngle(p[0],p[1]),
angleFromPoint2ToPoint3=getAngle(p[2],p[1]),
//find tangent points
t12=[p[1][0]-cos(angleFromPoint1ToPoint2)*tangD,p[1][1]-sin(angleFromPoint1ToPoint2)*tangD],//tangent point between points 1&2
t23=[p[1][0]-cos(angleFromPoint2ToPoint3)*tangD,p[1][1]-sin(angleFromPoint2ToPoint3)*tangD],//tangent point between points 2&3
//find circle centre
tmid=getMidpoint(t12,t23),//midpoint between the two tangent points
angCen=getAngle(tmid,p[1]),//angle from point 2 to circle centre
cen=[p[1][0]-cos(angCen)*circD,p[1][1]-sin(angCen)*circD],//circle center by offseting from point 2
outR=max(minR,rp[1][2]-thick*sgn*mode) //ensures radii are never too small.
)
concat(cen,outR);
function findPoint(ang1,refpoint1,ang2,refpoint2,r=0)=
let(
m1=tan(ang1),
c1=refpoint1.y-m1*refpoint1.x,
m2=tan(ang2),
c2=refpoint2.y-m2*refpoint2.x,
outputX=(c2-c1)/(m1-m2),
outputY=m1*outputX+c1
)
[outputX,outputY,r];
function beamChain(radiiPoints,offset1=0,offset2,mode=0,minR=0,startAngle,endAngle)=
/*This function takes a series of radii points and plots points to run along side at a consistant distance, think of it as offset but for line instead of a polygon
radiiPoints=radii points,
offset1 & offset2= The two offsets that give the beam it's thickness. When using with mode=2 only offset1 is needed as there is no return path for the polygon
minR=min radius, if all of your radii are set properly within the radii points this value can be ignored
startAngle & endAngle= Angle at each end of the beam, different mode determine if this angle is relative to the ending legs of the beam or absolute.
mode=1 - include endpoints startAngle&2 are relative to the angle of the last two points and equal 90deg if not defined
mode=2 - Only the forward path is defined, useful for combining the beam with other radii points, see examples for a use-case.
mode=3 - include endpoints startAngle&2 are absolute from the x axis and are 0 if not defined
negative radiuses only allowed for the first and last radii points
As it stands this function could probably be tidied a lot, but it works, I'll tidy later*/
let(
offset2undef=offset2==undef?1:0,
offset2=offset2undef==1?0:offset2,
CWorCCW1=sign(offset1)*CWorCCW(radiiPoints),
CWorCCW2=sign(offset2)*CWorCCW(radiiPoints),
offset1=abs(offset1),
offset2b=abs(offset2),
Lrp3=len(radiiPoints)-3,
Lrp=len(radiiPoints),
startAngle=mode==0&&startAngle==undef?
getAngle(radiiPoints[0],radiiPoints[1])+90:
mode==2&&startAngle==undef?
0:
mode==0?
getAngle(radiiPoints[0],radiiPoints[1])+startAngle:
startAngle,
endAngle=mode==0&&endAngle==undef?
getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2])+90:
mode==2&&endAngle==undef?
0:
mode==0?
getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2])+endAngle:
endAngle,
OffLn1=[for(i=[0:Lrp3]) offset1==0?radiiPoints[i+1]:parallelFollow([radiiPoints[i],radiiPoints[i+1],radiiPoints[i+2]],offset1,minR,mode=CWorCCW1)],
OffLn2=[for(i=[0:Lrp3]) offset2==0?radiiPoints[i+1]:parallelFollow([radiiPoints[i],radiiPoints[i+1],radiiPoints[i+2]],offset2b,minR,mode=CWorCCW2)],
Rp1=abs(radiiPoints[0].z),
Rp2=abs(radiiPoints[Lrp-1].z),
endP1a=findPoint(getAngle(radiiPoints[0],radiiPoints[1]), OffLn1[0], startAngle,radiiPoints[0], Rp1),
endP1b=findPoint(getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2]), OffLn1[len(OffLn1)-1], endAngle,radiiPoints[Lrp-1], Rp2),
endP2a=findPoint(getAngle(radiiPoints[0],radiiPoints[1]), OffLn2[0], startAngle,radiiPoints[0], Rp1),
endP2b=findPoint(getAngle(radiiPoints[Lrp-1],radiiPoints[Lrp-2]), OffLn2[len(OffLn1)-1], endAngle,radiiPoints[Lrp-1], Rp2),
absEnda=getAngle(endP1a,endP2a),
absEndb=getAngle(endP1b,endP2b),
negRP1a=[cos(absEnda)*radiiPoints[0].z*10+endP1a.x, sin(absEnda)*radiiPoints[0].z*10+endP1a.y, 0.0],
negRP2a=[cos(absEnda)*-radiiPoints[0].z*10+endP2a.x, sin(absEnda)*-radiiPoints[0].z*10+endP2a.y, 0.0],
negRP1b=[cos(absEndb)*radiiPoints[Lrp-1].z*10+endP1b.x, sin(absEndb)*radiiPoints[Lrp-1].z*10+endP1b.y, 0.0],
negRP2b=[cos(absEndb)*-radiiPoints[Lrp-1].z*10+endP2b.x, sin(absEndb)*-radiiPoints[Lrp-1].z*10+endP2b.y, 0.0],
OffLn1b=(mode==0||mode==2)&&radiiPoints[0].z<0&&radiiPoints[Lrp-1].z<0?
concat([negRP1a],[endP1a],OffLn1,[endP1b],[negRP1b])
:(mode==0||mode==2)&&radiiPoints[0].z<0?
concat([negRP1a],[endP1a],OffLn1,[endP1b])
:(mode==0||mode==2)&&radiiPoints[Lrp-1].z<0?
concat([endP1a],OffLn1,[endP1b],[negRP1b])
:mode==0||mode==2?
concat([endP1a],OffLn1,[endP1b])
:
OffLn1,
OffLn2b=(mode==0||mode==2)&&radiiPoints[0].z<0&&radiiPoints[Lrp-1].z<0?
concat([negRP2a],[endP2a],OffLn2,[endP2b],[negRP2b])
:(mode==0||mode==2)&&radiiPoints[0].z<0?
concat([negRP2a],[endP2a],OffLn2,[endP2b])
:(mode==0||mode==2)&&radiiPoints[Lrp-1].z<0?
concat([endP2a],OffLn2,[endP2b],[negRP2b])
:mode==0||mode==2?
concat([endP2a],OffLn2,[endP2b])
:
OffLn2
)//end of let()
offset2undef==1?OffLn1b:concat(OffLn2b,revList(OffLn1b));
function revList(list)=//reverse list
let(Llist=len(list)-1)
[for(i=[0:Llist]) list[Llist-i]];
function CWorCCW(p)=
let(
Lp=len(p),
e=[for(i=[0:Lp-1])
(p[listWrap(i+0,Lp)].x-p[listWrap(i+1,Lp)].x)*(p[listWrap(i+0,Lp)].y+p[listWrap(i+1,Lp)].y)
]
)
sign(sum(e));
function CentreN2PointsArc(p1,p2,cen,mode=0,fn)=
/* This function plots an arc from p1 to p2 with fn increments using the cen as the centre of the arc.
the mode determines how the arc is plotted
mode==0, shortest arc possible
mode==1, longest arc possible
mode==2, plotted clockwise
mode==3, plotted counter clockwise
*/
let(
isCWorCCW=CWorCCW([cen,p1,p2]),//determine the direction of rotation
//determine the arc angle depending on the mode
p1p2Angle=cosineRuleAngle(p2,cen,p1),
arcAngle=
mode==0?p1p2Angle:
mode==1?p1p2Angle-360:
mode==2&&isCWorCCW==-1?p1p2Angle:
mode==2&&isCWorCCW== 1?p1p2Angle-360:
mode==3&&isCWorCCW== 1?p1p2Angle:
mode==3&&isCWorCCW==-1?p1p2Angle-360:
cosineRuleAngle(p2,cen,p1),
r=pointDist(p1,cen),//determine the radius
p1Angle=getAngle(cen,p1) //angle of line 1
)
[for(i=[0:fn])
let(angleIncrement=(arcAngle/fn)*i*isCWorCCW)
[cos(p1Angle+angleIncrement)*r+cen.x,sin(p1Angle+angleIncrement)*r+cen.y]];
function translateRadiiPoints(radiiPoints,tran=[0,0],rot=0)=
[for(i=radiiPoints)
let(
a=getAngle([0,0],[i.x,i.y]),//get the angle of the this point
h=pointDist([0,0],[i.x,i.y]) //get the hypotenuse/radius
)
[h*cos(a+rot)+tran.x,h*sin(a+rot)+tran.y,i.z]//calculate the point's new position
];
module round2d(OR=3,IR=1){
offset(OR,$fn=100){
offset(-IR-OR,$fn=100){
offset(IR,$fn=100){
children();
}
}
}
}
module shell2d(offset1,offset2=0,minOR=0,minIR=0){
difference(){
round2d(minOR,minIR){
offset(max(offset1,offset2)){
children(0);//original 1st child forms the outside of the shell
}
}
round2d(minIR,minOR){
difference(){//round the inside cutout
offset(min(offset1,offset2)){
children(0);//shrink the 1st child to form the inside of the shell
}
if($children>1){
for(i=[1:$children-1]){
children(i);//second child and onwards is used to add material to inside of the shell
}
}
}
}
}
}
module internalSq(size,r,center=0){
tran=center==1?[0,0]:size/2;
translate(tran){
square(size,true);
offs=sin(45)*r;
for(i=[-1,1],j=[-1,1]){
translate([(size.x/2-offs)*i,(size.y/2-offs)*j])circle(r);
}
}
}
module extrudeWithRadius(length,r1=0,r2=0,fn=30){
n1=sign(r1);n2=sign(r2);
r1=abs(r1);r2=abs(r2);
translate([0,0,r1]){
linear_extrude(length-r1-r2){
children();
}
}
for(i=[0:fn-1]){
translate([0,0,i/fn*r1]){
linear_extrude(r1/fn+0.01){
offset(n1*sqrt(sq(r1)-sq(r1-i/fn*r1))-n1*r1){
children();
}
}
}
translate([0,0,length-r2+i/fn*r2]){
linear_extrude(r2/fn+0.01){
offset(n2*sqrt(sq(r2)-sq(i/fn*r2))-n2*r2){
children();
}
}
}
}
}
function mirrorPoints(radiiPoints,rot=0,endAttenuation=[0,0])= //mirrors a list of points about Y, ignoring the first and last points and returning them in reverse order for use with polygon or polyRound
let(
a=translateRadiiPoints(radiiPoints,[0,0],-rot),
temp3=[for(i=[0+endAttenuation[0]:len(a)-1-endAttenuation[1]])
[a[i][0],-a[i][1],a[i][2]]
],
temp=translateRadiiPoints(temp3,[0,0],rot),
temp2=revList(temp3)
)
concat(radiiPoints,temp2);
function processRadiiPoints(rp)=
[for(i=[0:len(rp)-1])
processRadiiPoints2(rp,i)
];
function processRadiiPoints2(list,end=0,idx=0,result=0)=
idx>=end+1?result:
processRadiiPoints2(list,end,idx+1,relationalRadiiPoints(result,list[idx]));
function cosineRuleBside(a,c,C)=c*cos(C)-sqrt(sq(a)+sq(c)+sq(cos(C))-sq(c));
function absArelR(po,pn)=
let(
th2=atan(po[1]/po[0]),
r2=sqrt(sq(po[0])+sq(po[1])),
r3=cosineRuleBside(r2,pn[1],th2-pn[0])
)
[cos(pn[0])*r3,sin(pn[0])*r3,pn[2]];
function relationalRadiiPoints(po,pi)=
let(
p0=pi[0],
p1=pi[1],
p2=pi[2],
pv0=pi[3][0],
pv1=pi[3][1],
pt0=pi[3][2],
pt1=pi[3][3],
pn=
(pv0=="y"&&pv1=="x")||(pv0=="r"&&pv1=="a")||(pv0=="y"&&pv1=="a")||(pv0=="x"&&pv1=="a")||(pv0=="y"&&pv1=="r")||(pv0=="x"&&pv1=="r")?
[p1,p0,p2,concat(pv1,pv0,pt1,pt0)]:
[p0,p1,p2,concat(pv0,pv1,pt0,pt1)],
n0=pn[0],
n1=pn[1],
n2=pn[2],
nv0=pn[3][0],
nv1=pn[3][1],
nt0=pn[3][2],
nt1=pn[3][3],
temp=
pn[0]=="l"?
[po[0],pn[1],pn[2]]
:pn[1]=="l"?
[pn[0],po[1],pn[2]]
:nv0==undef?
[pn[0],pn[1],pn[2]]//abs x, abs y as default when undefined
:nv0=="a"?
nv1=="r"?
nt0=="a"?
nt1=="a"||nt1==undef?
[cos(n0)*n1,sin(n0)*n1,n2]//abs angle, abs radius
:absArelR(po,pn)//abs angle rel radius
:nt1=="r"||nt1==undef?
[po[0]+cos(pn[0])*pn[1],po[1]+sin(pn[0])*pn[1],pn[2]]//rel angle, rel radius
:[pn[0],pn[1],pn[2]]//rel angle, abs radius
:nv1=="x"?
nt0=="a"?
nt1=="a"||nt1==undef?
[pn[1],pn[1]*tan(pn[0]),pn[2]]//abs angle, abs x
:[po[0]+pn[1],(po[0]+pn[1])*tan(pn[0]),pn[2]]//abs angle rel x
:nt1=="r"||nt1==undef?
[po[0]+pn[1],po[1]+pn[1]*tan(pn[0]),pn[2]]//rel angle, rel x
:[pn[1],po[1]+(pn[1]-po[0])*tan(pn[0]),pn[2]]//rel angle, abs x
:nt0=="a"?
nt1=="a"||nt1==undef?
[pn[1]/tan(pn[0]),pn[1],pn[2]]//abs angle, abs y
:[(po[1]+pn[1])/tan(pn[0]),po[1]+pn[1],pn[2]]//abs angle rel y
:nt1=="r"||nt1==undef?
[po[0]+(pn[1]-po[0])/tan(90-pn[0]),po[1]+pn[1],pn[2]]//rel angle, rel y
:[po[0]+(pn[1]-po[1])/tan(pn[0]),pn[1],pn[2]]//rel angle, abs y
:nv0=="r"?
nv1=="x"?
nt0=="a"?
nt1=="a"||nt1==undef?
[pn[1],sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1])),pn[2]]//abs radius, abs x
:[po[0]+pn[1],sign(pn[0])*sqrt(sq(pn[0])-sq(po[0]+pn[1])),pn[2]]//abs radius rel x
:nt1=="r"||nt1==undef?
[po[0]+pn[1],po[1]+sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1])),pn[2]]//rel radius, rel x
:[pn[1],po[1]+sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1]-po[0])),pn[2]]//rel radius, abs x
:nt0=="a"?
nt1=="a"||nt1==undef?
[sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1])),pn[1],pn[2]]//abs radius, abs y
:[sign(pn[0])*sqrt(sq(pn[0])-sq(po[1]+pn[1])),po[1]+pn[1],pn[2]]//abs radius rel y
:nt1=="r"||nt1==undef?
[po[0]+sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1])),po[1]+pn[1],pn[2]]//rel radius, rel y
:[po[0]+sign(pn[0])*sqrt(sq(pn[0])-sq(pn[1]-po[1])),pn[1],pn[2]]//rel radius, abs y
:nt0=="a"?
nt1=="a"||nt1==undef?
[pn[0],pn[1],pn[2]]//abs x, abs y
:[pn[0],po[1]+pn[1],pn[2]]//abs x rel y
:nt1=="r"||nt1==undef?
[po[0]+pn[0],po[1]+pn[1],pn[2]]//rel x, rel y
:[po[0]+pn[0],pn[1],pn[2]]//rel x, abs y
)
temp;
function invtan(run,rise)=
let(a=abs(atan(rise/run)))
rise==0&&run>0?
0:rise>0&&run>0?
a:rise>0&&run==0?
90:rise>0&&run<0?
180-a:rise==0&&run<0?
180:rise<0&&run<0?
a+180:rise<0&&run==0?
270:rise<0&&run>0?
360-a:"error";
function cosineRuleAngle(p1,p2,p3)=
let(
p12=abs(pointDist(p1,p2)),
p13=abs(pointDist(p1,p3)),
p23=abs(pointDist(p2,p3))
)
acos((sq(p23)+sq(p12)-sq(p13))/(2*p23*p12));
function sum(list, idx = 0, result = 0) =
idx >= len(list) ? result : sum(list, idx + 1, result + list[idx]);
function sq(x)=x*x;
function getGradient(p1,p2)=(p2.y-p1.y)/(p2.x-p1.x);
function getAngle(p1,p2)=p1==p2?0:invtan(p2[0]-p1[0],p2[1]-p1[1]);
function getMidpoint(p1,p2)=[(p1[0]+p2[0])/2,(p1[1]+p2[1])/2]; //returns the midpoint of two points
function pointDist(p1,p2)=sqrt(abs(sq(p1[0]-p2[0])+sq(p1[1]-p2[1]))); //returns the distance between two points
function isColinear(p1,p2,p3)=getGradient(p1,p2)==getGradient(p2,p3)?1:0;//return 1 if 3 points are colinear
module polyline(p, width=0.3) {
for(i=[0:max(0,len(p)-1)]){
color([i*1/len(p),1-i*1/len(p),0,0.5])line(p[i],p[listWrap(i+1,len(p) )],width);
}
} // polyline plotter
module line(p1, p2 ,width=0.3) { // single line plotter
hull() {
translate(p1){
circle(width);
}
translate(p2){
circle(width);
}
}
}
function getpoints(p)=[for(i=[0:len(p)-1])[p[i].x,p[i].y]];// gets [x,y]list of[x,y,r]list
function listWrap(x,x_max=1,x_min=0) = (((x - x_min) % (x_max - x_min)) + (x_max - x_min)) % (x_max - x_min) + x_min; // wraps numbers inside boundaries
function rnd(a = 1, b = 0, s = []) =
s == [] ?
(rands(min(a, b), max( a, b), 1)[0]):(rands(min(a, b), max(a, b), 1, s)[0]); // nice rands wrapper

View File

@ -72,3 +72,66 @@ function profile_segment_length(profile,i) = norm(profile[(i+1)%len(profile)] -
// Generates an array with n copies of value (default 0)
function dup(value=0,n) = [for (i = [1:n]) value];
use <scad-utils/transformations.scad>
use <scad-utils/trajectory_path.scad>
use <scad-utils/trajectory.scad>
use <scad-utils/shapes.scad>
module fakeISOEnter(thickness_difference = 0){
// 1u is the space taken upy by a 1u keycap.
// unit is the space taken up by a unit space for a keycap.
// formula is 1u + unit *(length - 1)
// t is all modifications to the polygon array
t = thickness_difference/2 - (19.02 - 18.16);
function unit(length) = 19.02 * length;
pointArray = [
[19.05 * (-.5) + t, 19.05 * (-1) + t],
[19.05 * (0.5) - t, 19.05 * (-1) + t],
[19.05 * (0.5) - t, 19.05 * (1) - t],
[19.05 * (-0.75) + t, 19.05 * (1) - t],
[19.05 * (-0.75) + t, 19.05 * (0) + t],
[19.05 * (-0.5) + t, 19.05 * (0) + t]
];
/*translate([unit(-.5), unit(-1) + 0.86]){*/
minkowski() {
circle($corner_radius, $fn=20);
offset(r=-$corner_radius * 2, $fn=20) polygon(points=pointArray);
}
/*}*/
}
function isoEnter() = [
[19.05 * (-.5) + (19.02 - 18.16), 19.05 * (-1) + (19.02 - 18.16)],
[19.05 * (0.5) - (19.02 - 18.16), 19.05 * (-1) + (19.02 - 18.16)],
[19.05 * (0.5) - (19.02 - 18.16), 19.05 * (1) - (19.02 - 18.16)],
[19.05 * (-0.75) + (19.02 - 18.16), 19.05 * (1) - (19.02 - 18.16)],
[19.05 * (-0.75) + (19.02 - 18.16), 19.05 * (0) + (19.02 - 18.16)],
[19.05 * (-0.5) + (19.02 - 18.16), 19.05 * (0) + (19.02 - 18.16)]
];
path_definition = [
trajectory(forward = 10, roll = 0),
];
// sweep
path = quantize_trajectories(path_definition, steps=100);
// skin
myLen = len(path)-1;
trans = [ for (i=[0:len(path)-1]) transform(path[i], isoEnter()) ];
translate([0,10,0])
skin(trans);

View File

@ -7,10 +7,7 @@ $key_length = 1.0; // Range not working in thingiverse customizer atm [1:0.25:16
$stem_type = "cherry"; // [cherry, alps, rounded_cherry, box_cherry, filled, disable]
// The stem is the hardest part to print, so this variable controls how much 'slop' there is in the stem
// if your keycaps stick in the switch raise this value
$stem_slop = 0.35; // Not working in thingiverse customizer atm [0:0.01:1]
// broke this out. if your keycaps are falling off lower this value. only works for cherry stems rn
$stem_inner_slop = 0.2;
$stem_slop = 0.3; // Not working in thingiverse customizer atm [0:0.01:1]
// Font size used for text
$font_size = 6;
@ -18,10 +15,6 @@ $font_size = 6;
// Set this to true if you're making a spacebar!
$inverted_dish = false;
// change aggressiveness of double sculpting
// this is the radius of the cylinder the keytops are placed on
$double_sculpt_radius = 200;
// Support type. default is "flared" for easy FDM printing; bars are more realistic, and flat could be for artisans
$support_type = "flared"; // [flared, bars, flat, disable]
@ -29,11 +22,9 @@ $support_type = "flared"; // [flared, bars, flat, disable]
// Supports for the stem, as it often comes off during printing. Reccommended for most machines
$stem_support_type = "tines"; // [tines, brim, disabled]
// make legends outset instead of inset.
// broken off from artisan support since who wants outset legends?
$outset_legends = false;
/* [Advanced] */
/* [Key] */
/* Key */
// Height in units of key. should remain 1 for most uses
$key_height = 1.0;
// Keytop thickness, aka how many millimeters between the inside and outside of the top surface of the key
@ -54,17 +45,10 @@ $height_difference = 4;
$total_depth = 11.5;
// The tilt of the dish in degrees. divided by key height
$top_tilt = -6;
// the y tilt of the dish in degrees. divided by key width.
// for double axis sculpted keycaps and probably not much else
$top_tilt_y = 0;
// How skewed towards the back the top is (0 for center)
$top_skew = 1.7;
// how skewed towards the right the top is. unused, but implemented.
// for double axis sculpted keycaps and probably not much else
$top_skew_x = 0;
/* [Stem] */
/* Stem */
// How far the throw distance of the switch is. determines how far the 'cross' in the cherry switch digs into the stem, and how long the keystem needs to be before supports can start. luckily, alps and cherries have a pretty similar throw. can modify to have stouter keycaps for low profile switches, etc
$stem_throw = 4;
@ -74,24 +58,21 @@ $rounded_cherry_stem_d = 5.5;
// How much higher the stem is than the bottom of the keycap.
// Inset stem requires support but is more accurate in some profiles
// can be negative to make outset stems!
$stem_inset = 0;
// How many degrees to rotate the stems. useful for sideways keycaps
// How many degrees to rotate the stems. useful for sideways keycaps, maybe
$stem_rotation = 0;
// How many degrees to rotate the keycap, but _not_ inside features (the stem).
$keycap_rotation = 0;
/* [Shape] */
/* Shape */
// Key shape type, determines the shape of the key. default is 'rounded square'
$key_shape_type = "rounded_square";
// ISO enter needs to be linear extruded NOT from the center when not using skin. this tells the program how far up 'not from the center' is
// ISO enter needs to be linear extruded NOT from the center. this tells the program how far up 'not from the center' is
$linear_extrude_height_adjustment = 0;
// How many slices will be made, to approximate curves on corners. Leave at 1 if you are not curving corners
// If you're doing fancy bowed keycap sides, this controls how many slices you take
$height_slices = 1;
/* [Dish] */
/* Dish */
// What type of dish the key has. note that unlike stems and supports a dish ALWAYS gets rendered.
$dish_type = "cylindrical"; // [cylindrical, spherical, sideways cylindrical, old spherical, disable]
@ -101,16 +82,12 @@ $dish_depth = 1;
$dish_skew_x = 0;
// How skewed in the y direction (height) the dish is
$dish_skew_y = 0;
$dish_offset_x = 0;
// If you need the dish to extend further, you can 'overdraw' the rectangle it will hit. this was mostly for iso enter and should be deprecated
// If you need the dish to extend further, you can 'overdraw' the rectangle it will hit
$dish_overdraw_width = 0;
// Same as width but for height
$dish_overdraw_height = 0;
/* [Misc] */
/* Misc */
// There's a bevel on the cherry stems to aid insertion / guard against first layer squishing making a hard-to-fit stem.
$cherry_bevel = true;
@ -120,17 +97,15 @@ $stem_support_height = .8;
$font="DejaVu Sans Mono:style=Book";
// Whether or not to render fake keyswitches to check clearances
$clearance_check = false;
// Use linear_extrude instead of hull slices to make the shape of the key
// Should be faster, also required for concave shapes
// what kind of extrusion we use to create the keycap. "hull" is standard, "linear extrude" is legacy, "skin" is new and not well supported.
$hull_shape_type = "hull"; // ["hull", "linear extrude", "skin"]
// This doesn't work very well, but you can try
$linear_extrude_shape = false;
//should the key be rounded? unnecessary for most printers, and very slow
$rounded_key = false;
//minkowski radius. radius of sphere used in minkowski sum for minkowski_key function. 1.75 for G20
$minkowski_radius = .33;
/* [Features] */
/* Features */
//insert locating bump
$key_bump = false;
@ -141,27 +116,12 @@ $key_bump_edge = 0.4;
/* [Hidden] */
// set this to true if you are making double sculpted keycaps
$double_sculpted = false;
//list of legends to place on a key format: [text, halign, valign, size]
//halign = "left" or "center" or "right"
//valign = "top" or "center" or "bottom"
// Currently does not work with thingiverse customizer, and actually breaks it
$legends = [];
//list of front legends to place on a key format: [text, halign, valign, size]
//halign = "left" or "center" or "right"
//valign = "top" or "center" or "bottom"
// Currently does not work with thingiverse customizer, and actually breaks it
$front_legends = [];
// print legends on the front of the key instead of the top
$front_print_legends = false;
// how recessed inset legends / artisans are from the top of the key
$inset_legend_depth = 0.2;
// Dimensions of alps stem
$alps_stem = [4.45, 2.25];
@ -180,72 +140,3 @@ $stabilizers = $key_length >= 6 ? [[-50, 0], [50, 0]] : $key_length >= 2 ? [[-12
// Where the stems are in relation to the center of the keycap, in units. default is one in the center
// Shouldn't work in thingiverse customizer, though it has been...
$stem_positions = [[0,0]];
// colors
$primary_color = [.2667,.5882,1];
$secondary_color = [.4412, .7, .3784];
$tertiary_color = [1, .6941, .2];
$quaternary_color = [.4078, .3569, .749];
$warning_color = [1,0,0, 0.15];
// how many facets circles will have when used in these features
$minkowski_facets = 30;
$shape_facets =30;
// "flat" / "dished" / "disable"
$inner_shape_type = "flat";
// default side_sculpting function, linear
$side_sculpting = function(progress) 0;
$corner_sculpting = function(progress) 0;
// you probably shouldn't touch this, it's internal to sculpted_square
// modify side sculpting with the $side_sculpting function in the key profile files
$more_side_sculpting_factor = 0;
// 3d surface functions (still in beta)
// 3d surface settings
// unused for now
$3d_surface_size = 1;
// 3d surface point resolution. $3d_surface_size / $3d_surface_step = steps per x / y
$3d_surface_step = 1/20;
// monotonically increasing function that distributes the points of the surface mesh
// only for polar_3d_surface right now
// if it's linear it's a grid. sin(dim) * size concentrates detail around the edges
sinusoidal_surface_distribution = function(dim,size) sin(dim) * size;
linear_surface_distribution = function(dim,size) dim;
$surface_distribution_function = sinusoidal_surface_distribution;
// the function that actually determines what the surface is.
// feel free to override, the last one wins
// debug
// $surface_function = function(x,y) 1;
cylindrical_surface = function(x,y) (sin(acos(x/$3d_surface_size)));
spherical_surface = function(x,y) (1 - (x/$3d_surface_size)^2)^0.5 * (1 - (y/$3d_surface_size)^2)^0.5;
// looks a lot like mt3
quartic_surface = function(x,y) (1 - (x/$3d_surface_size)^4)^0.5 * (1 - (y/$3d_surface_size)^4)^0.5;
ripple_surface = function(x,y) cos((x^2+y^2)^0.5 * 50)/4 + 0.75;
rosenbrocks_banana_surface = function(x,y) (pow(1-(x/$3d_surface_size))^2 + 100 * pow((y/$3d_surface_size)-(x/$3d_surface_size)^2)^2)/200 + 0.1;
spike_surface = function(x,y) 1/(((x/$3d_surface_size)^2+(y/$3d_surface_size)^2)^0.5) + .01;
random_surface = function(x,y) sin(rands(0,90,1,x+y)[0]);
bumps_surface = function(x,y) sin(20*x)*cos(20*y)/3+1;
$surface_function = bumps_surface; // bumps_surface;
// can be used to smooth the corners of the 3d surface function, to make the dishes add / subtract less height. can really do anything it's just multiplying, but that's what I use it for
$corner_smoothing_surface_function = function(x,y) 1;
// $corner_smoothing_surface_function = function(x,y) (1 - pow(abs(x), 5)/$3d_surface_size) * (1 - pow(abs(y),5)/$3d_surface_size);
// ripples
/*
// Rosenbrock's banana
/* $
// y=x revolved around the y axis
/* $surface_function = */
/* $surface_function = */

View File

@ -1,15 +1,12 @@
include <constants.scad>
$fs=.1;
unit = 19.05;
include <shapes/ISO_enter.scad>
include <shapes/sculpted_square.scad>
include <shapes/rounded_square.scad>
include <shapes/square.scad>
include <shapes/oblong.scad>
include <shapes/regular_polygon.scad>
// size: at progress 0, the shape is supposed to be this size
// delta: at progress 1, the keycap is supposed to be size - delta
// progress: how far along the transition you are.
// it's not always linear - specifically sculpted_square
module key_shape(size, delta, progress = 0) {
if ($key_shape_type == "iso_enter") {
ISO_enter_shape(size, delta, progress);
@ -17,31 +14,11 @@ module key_shape(size, delta, progress = 0) {
sculpted_square_shape(size, delta, progress);
} else if ($key_shape_type == "rounded_square") {
rounded_square_shape(size, delta, progress);
} else if ($key_shape_type == "flat_sided_square") {
// rounded_square_shape handles this
rounded_square_shape(size, delta, progress);
} else if ($key_shape_type == "square") {
square_shape(size, delta, progress);
} else if ($key_shape_type == "oblong") {
oblong_shape(size, delta, progress);
} else if ($key_shape_type == "hexagon") {
regular_polygon_shape(size, delta, progress);
} else if ($key_shape_type == "octagon") {
regular_polygon_shape(size, delta, progress, sides=8);
} else if ($key_shape_type == "circular") {
regular_polygon_shape(size, delta, progress, sides=36);
} else {
echo("Warning: unsupported $key_shape_type");
}
}
function skin_key_shape(size, delta, progress = 0, thickness_difference) =
$key_shape_type == "rounded_square" ?
skin_rounded_square(size, delta, progress, thickness_difference) :
$key_shape_type == "sculpted_square" ?
skin_sculpted_square_shape(size, delta, progress, thickness_difference) :
$key_shape_type == "square" ?
skin_square_shape(size, delta, progress, thickness_difference) :
$key_shape_type == "iso_enter" ?
skin_iso_enter_shape(size, delta, progress, thickness_difference) :
echo("Warning: unsupported $key_shape_type for skin shape. disable skin_extrude_shape or pick a new shape");

View File

@ -1,14 +1,9 @@
include <../functions.scad>
include <../libraries/round-anything/polyround.scad>
width_ratio = unit_length(1.25) / unit_length(1.5);
height_ratio = unit_length(1) / unit_length(2);
// corollary is rounded_square
// NOT 3D
module ISO_enter_shape(size, delta, progress){
width = size[0];
height = size[1];
function unit_length(length) = unit * (length - 1) + 18.16;
// in order to make the ISO keycap shape generic, we are going to express the
@ -17,53 +12,23 @@ module ISO_enter_shape(size, delta, progress){
// and wants to pass just width and height, we make these ratios to know where
// to put the elbow joint
delta = delta / 2;
width_ratio = unit_length(1.25) / unit_length(1.5);
height_ratio = unit_length(1) / unit_length(2);
pointArray = [
[ 0-delta.x, 0-delta.y], // top right
[ 0-delta.x, -height+delta.y], // bottom right
[-width * width_ratio+delta.x, -height+delta.y], // bottom left
[-width * width_ratio + delta.x,-height * height_ratio+delta.y], // inner middle point
[ -width + delta.x,-height * height_ratio + delta.y], // outer middle point
[ -width + delta.x, 0-delta.y] // top left
[ 0, 0], // top right
[ 0, -height], // bottom right
[-width * width_ratio, -height], // bottom left
[-width * width_ratio,-height * height_ratio], // inner middle point
[ -width,-height * height_ratio], // outer middle point
[ -width, 0] // top left
];
minkowski(){
circle(r=$corner_radius);
circle(r=corner_size);
// gives us rounded inner corner
offset(r=-$corner_radius*2) {
offset(r=-corner_size*2) {
translate([(width * width_ratio)/2, height/2]) polygon(points=pointArray);
}
}
}
function iso_enter_vertices(size, delta, progress, thickness_difference) = [
[ 0-delta.x/2 * progress - thickness_difference/8, 0 - delta.y / 2 * progress - thickness_difference/8], // top right
[ 0-delta.x/2 * progress - thickness_difference/8, -size[1] + delta.y / 2 * progress + thickness_difference/8], // bottom right
[-size[0] * width_ratio + delta.x/2 * progress + thickness_difference/8, -size[1] + delta.y / 2 * progress + thickness_difference/8], // bottom left
[-size[0] * width_ratio + delta.x/2 * progress + thickness_difference/8,-size[1] * height_ratio + delta.y / 2 * progress + thickness_difference/2], // inner middle point
[ -size[0] + delta.x/2 * progress + thickness_difference/8,-size[1] * height_ratio + delta.y / 2 * progress + thickness_difference/2], // outer middle point
[ -size[0] + delta.x/2 * progress + thickness_difference/8, 0 - delta.y / 2 * progress - thickness_difference/8] // top left
] + [
[(size[0] * width_ratio)/2, size[1]/2 ],
[(size[0] * width_ratio)/2, size[1]/2 ],
[(size[0] * width_ratio)/2, size[1]/2 ],
[(size[0] * width_ratio)/2, size[1]/2 ],
[(size[0] * width_ratio)/2, size[1]/2 ],
[(size[0] * width_ratio)/2, size[1]/2 ]
];
// no rounding on the corners at all
function skin_iso_enter_shape(size, delta, progress, thickness_difference) =
polyRound(
add_rounding(
iso_enter_vertices(
size,
[delta.x - $side_sculpting(progress), delta.y - $side_sculpting(progress)],
progress,
thickness_difference
),
$corner_radius + $corner_sculpting(progress)
),
$shape_facets
);

View File

@ -1,14 +0,0 @@
// we do this weird key_shape_type check here because rounded_square uses
// square_shape, and we want flat sides to work for that too.
// could be refactored, idk
module regular_polygon_shape(size, delta, progress, sides=6){
// https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/undersized_circular_objects
fudge = 1/cos(180/sides);
diameter = (size.x - delta.x * progress - $corner_radius*2) * fudge;
offset(r=$corner_radius) rotate([0,0,360/sides/2]) circle(d = diameter, $fn=sides);
}
// TODO not implemented
function skin_regular_polygon_shape(size, delta, progress, thickness_difference, sides=6) = echo("skin regular polygon not implemented");

View File

@ -1,12 +1,22 @@
include <square.scad>
include <../libraries/round-anything/polyround.scad>
module rounded_square_shape(size, delta, progress, center = true) {
offset(r=$corner_radius, $fa=360/$shape_facets){
square_shape([size.x - $corner_radius*2, size.y - $corner_radius*2], delta, progress);
}
}
width = size[0];
height = size[1];
// for skin
function skin_rounded_square(size, delta, progress, thickness_difference) =
polyRound(add_rounding(rectangle_profile(size - (delta * progress)), $corner_radius), $shape_facets/4);
width_difference = delta[0];
height_difference = delta[1];
// computed values for this slice
extra_width_this_slice = (width_difference) * progress;
extra_height_this_slice = (height_difference) * progress;
extra_corner_radius_this_slice = ($corner_radius);
offset(r=extra_corner_radius_this_slice){
square(
[
width - extra_width_this_slice - extra_corner_radius_this_slice * 2,
height - extra_height_this_slice - extra_corner_radius_this_slice * 2
],
center=center
);
}
}

View File

@ -1,5 +1,13 @@
// rounded square shape with additional sculpting functions to better approximate
// When sculpting sides, how much in should the tops come
$side_sculpting_factor = 4.5;
// When sculpting corners, how much extra radius should be added
$corner_sculpting_factor = 1;
// When doing more side sculpting corners, how much extra radius should be added
$more_side_sculpting_factor = 0.4;
// side sculpting functions
// bows the sides out on stuff like SA and DSA keycaps
function side_sculpting(progress) = (1 - progress) * $side_sculpting_factor;
@ -13,9 +21,9 @@ module sculpted_square_shape(size, delta, progress) {
width_difference = delta[0];
height_difference = delta[1];
// makes the sides bow
extra_side_size = $side_sculpting(progress);
extra_side_size = side_sculpting(progress);
// makes the rounded corners of the keycap grow larger as they move upwards
extra_corner_size = $corner_sculpting(progress);
extra_corner_size = corner_sculpting(progress);
// computed values for this slice
extra_width_this_slice = (width_difference - extra_side_size) * progress;
@ -27,66 +35,13 @@ module sculpted_square_shape(size, delta, progress) {
height - extra_height_this_slice
];
offset(r = extra_corner_radius_this_slice, $fa=360/$shape_facets) {
offset(r = extra_corner_radius_this_slice) {
offset(r = -extra_corner_radius_this_slice) {
side_rounded_square(square_size, r = $more_side_sculpting_factor * progress);
}
}
}
function new_side_rounded_square(size, r, cornerRadius=0) =
let(
width = (size.x - r)/2,
height = (size.y - r)/2,
// fudge numbers! the radius conflict resolution in polyround smooths out
// the entire shape based on the ratios between conflicting radii. bumping
// these up makes the whole shape more fluid
widthRadius = r ? width*8 : 0,
heightRadius = r ? height*8 : 0,
bow = r/2,
// close enough :/
facets = 360 / $shape_facets/2,
points = [
[-width,-height,cornerRadius],
[0,-height-bow,widthRadius],
[width,-height,cornerRadius],
[width + bow,0,heightRadius],
[width,height,cornerRadius],
[0,height + bow,widthRadius],
[-width,height,cornerRadius],
[-width-bow,0,heightRadius]
]
) polyRound(points,facets);
function skin_sculpted_square_shape(size, delta, progress, thickness_difference) =
let(
width = size[0],
height = size[1],
width_difference = delta[0],
height_difference = delta[1],
// makes the sides bow
extra_side_size = $side_sculpting(progress),
// makes the rounded corners of the keycap grow larger as they move upwards
extra_corner_size = $corner_sculpting(progress),
// computed values for this slice
extra_width_this_slice = (width_difference - extra_side_size) * progress,
extra_height_this_slice = (height_difference - extra_side_size) * progress,
extra_corner_radius_this_slice = ($corner_radius + extra_corner_size),
square_size = [
width - extra_width_this_slice - thickness_difference,
height - extra_height_this_slice - thickness_difference
]
) new_side_rounded_square(square_size, $more_side_sculpting_factor * progress, extra_corner_radius_this_slice);
module side_rounded_square(size, r) {
iw = size.x - 2 * r;
ih = size.y - 2 * r;
@ -96,10 +51,10 @@ module side_rounded_square(size, r) {
sw = iw / resolution;
union() {
if (sr > 0) {
translate([-iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution, $fa=360/$shape_facets);
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution, $fa=360/$shape_facets);
translate([-iw/2, 0]) scale([sr, sh]) circle(d = resolution);
translate([iw/2, 0]) scale([sr, sh]) circle(d = resolution);
translate([0, -ih/2]) scale([sw, sr]) circle(d = resolution);
translate([0, ih/2]) scale([sw, sr]) circle(d = resolution);
}
square([iw, ih], center=true);
}

View File

@ -1,53 +1,3 @@
use <../functions.scad>
// we do this weird key_shape_type check here because rounded_square uses
// square_shape, and we want flat sides to work for that too.
// could be refactored, idk
module square_shape(size, delta, progress){
if ($key_shape_type == "flat_sided_square") {
flat_sided_square_shape(size, delta,progress);
} else {
square(size - delta * progress, center = true);
}
}
/*
[-size.x /2,-size.y / 2],
[size.x / 2,-size.y / 2],
[size.x / 2, size.y / 2],
[-size.x / 2, size.y / 2] */
// for side-printed keycaps. Any amount of top tilt (on a keycap with a smaller
// top than bottom) makes the left and right side of the keycap convex. This
// shape makes the sides flat by making the top a trapezoid.
// This obviously doesn't work with rounded sides at all
module flat_sided_square_shape(size, delta, progress) {
polygon(skin_flat_sided_square_shape(size, delta, progress));
}
function skin_flat_sided_square_shape(size,delta,progress) = [
[(-size.x + (delta.x + extra_keytop_length_for_flat_sides()) * progress)/2, (-size.y + delta.y * progress)/2],
[(size.x - (delta.x + extra_keytop_length_for_flat_sides()) * progress)/2,(-size.y + delta.y * progress)/2],
[(size.x - (delta.x - extra_keytop_length_for_flat_sides()) * progress)/2, (size.y - delta.y * progress)/2],
[(-size.x + (delta.x - extra_keytop_length_for_flat_sides()) * progress)/2, (size.y - delta.y * progress)/2]
];
function rectangle_profile(size) = [
[-size.x/2, -size.y/2],
[size.x/2, -size.y/2],
[size.x/2, size.y/2],
[-size.x/2, size.y/2],
];
function skin_square_shape(size, delta, progress, thickness_difference) =
let(
width = size[0],
height = size[1],
width_difference = delta[0] * progress,
height_difference = delta[1] * progress,
square_size = [
width - width_difference - thickness_difference,
height - height_difference - thickness_difference
]
) $key_shape_type == "flat_sided_square" ? skin_flat_sided_square_shape(size, delta, progress) : rectangle_profile(square_size);

View File

@ -16,12 +16,12 @@ module brim_support(stem_type, stem_support_height, slop) {
}
}
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "rounded_cherry") {
difference() {
cylinder(d=$rounded_cherry_stem_d * 2, h=stem_support_height);
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "box_cherry") {
difference() {
@ -31,7 +31,7 @@ module brim_support(stem_type, stem_support_height, slop) {
}
}
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "cherry_stabilizer") {
difference() {
@ -41,7 +41,7 @@ module brim_support(stem_type, stem_support_height, slop) {
}
}
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if(stem_type == "choc") {
translate([-5.7/2,0,0]) linear_extrude(height=stem_support_height) {

View File

@ -1,64 +1,28 @@
include <../functions.scad>
include <../stems/cherry.scad>
/* NOTE: every reference to total_key_width and total_key_height
* is multiplied by two in order to account for offset stems
*/
// $wall_thickness/4 to reduce coincident faces
module centered_tines(stem_support_height) {
if ($key_length < 2) {
translate([0,0,$stem_support_height / 2]) {
cube([total_key_width()*2, 0.5, $stem_support_height], center = true);
}
}
translate([0,0,$stem_support_height / 2]) {
cube([
1,
total_key_height()*2,
$stem_support_height
],
center = true);
}
if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness)+$wall_thickness/4, 1, $stem_support_height], center = true);
translate([0,0,$stem_support_height / 2]) cube([1, total_key_height($wall_thickness), $stem_support_height], center = true);
}
module tines_support(stem_type, stem_support_height, slop) {
if (stem_type == "cherry" || stem_type == "costar_stabilizer") {
difference () {
union() {
if ($key_length < 2) {
translate([0,0,$stem_support_height / 2]) {
cube([
total_key_width()*2,
0.5,
$stem_support_height
], center = true);
}
if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness)+$wall_thickness/4, 1, $stem_support_height], center = true);
translate([1.15,0,$stem_support_height / 2]) cube([.5, total_key_height($wall_thickness), $stem_support_height], center = true);
translate([-1.15,0,$stem_support_height / 2]) cube([.5, total_key_height($wall_thickness), $stem_support_height], center = true);
}
// 2 vertical tines holding either side of the cruciform
for (x = [2, -2]) {
translate([x,0,$stem_support_height / 2]) {
cube([
0.5,
total_key_height()*2, // this is to extend past
$stem_support_height
], center = true);
}
}
}
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "cherry_stabilizer") {
difference () {
for (x = [1.15, -1.15]) {
translate([x,0,$stem_support_height / 2]) {
cube([
1,
total_key_height()*2,
$stem_support_height
], center = true);
}
union() {
translate([1.15,0,$stem_support_height / 2]) cube([1, total_key_height($wall_thickness), $stem_support_height], center = true);
translate([-1.15,0,$stem_support_height / 2]) cube([1, total_key_height($wall_thickness), $stem_support_height], center = true);
}
inside_cherry_stabilizer_cross(slop);
@ -67,19 +31,19 @@ module tines_support(stem_type, stem_support_height, slop) {
difference () {
centered_tines(stem_support_height);
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "rounded_cherry") {
difference () {
centered_tines(stem_support_height);
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
} else if (stem_type == "alps"){
centered_tines(stem_support_height);
} else if (stem_type == "choc"){
if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width(), 0.42, $stem_support_height], center = true);
/* translate([-5.7/2,0,$stem_support_height / 2]) cube([0.5, total_key_height(), $stem_support_height], center = true); */
/* translate([5.7/2,0,$stem_support_height / 2]) cube([0.5, total_key_height(), $stem_support_height], center = true); */
if ($key_length < 2) translate([0,0,$stem_support_height / 2]) cube([total_key_width($wall_thickness)+$wall_thickness/4, 0.42, $stem_support_height], center = true);
/* translate([-5.7/2,0,$stem_support_height / 2]) cube([0.5, total_key_height($wall_thickness), $stem_support_height], center = true); */
/* translate([5.7/2,0,$stem_support_height / 2]) cube([0.5, total_key_height($wall_thickness), $stem_support_height], center = true); */
}
}

View File

@ -8,21 +8,21 @@ include <stems/choc.scad>
//whole stem, alps or cherry, trimmed to fit
module stem(stem_type, depth, slop, throw){
module stem(stem_type, depth, slop){
if (stem_type == "alps") {
alps_stem(depth, slop, throw);
alps_stem(depth, slop);
} else if (stem_type == "cherry" || stem_type == "costar_stabilizer") {
cherry_stem(depth, slop, throw);
cherry_stem(depth, slop);
} else if (stem_type == "rounded_cherry") {
rounded_cherry_stem(depth, slop, throw);
rounded_cherry_stem(depth, slop);
} else if (stem_type == "box_cherry") {
box_cherry_stem(depth, slop, throw);
box_cherry_stem(depth, slop);
} else if (stem_type == "filled") {
filled_stem();
} else if (stem_type == "cherry_stabilizer") {
cherry_stabilizer_stem(depth, slop, throw);
cherry_stabilizer_stem(depth, slop);
} else if (stem_type == "choc") {
choc_stem(depth, slop, throw);
choc_stem(depth, slop);
} else if (stem_type == "disable") {
children();
} else {

View File

@ -1,4 +1,4 @@
module alps_stem(depth, slop, throw){
module alps_stem(depth, has_brim, slop){
linear_extrude(height=depth) {
square($alps_stem, center = true);
}

View File

@ -1,7 +1,7 @@
include <../functions.scad>
include <cherry.scad>
module box_cherry_stem(depth, slop, throw) {
module box_cherry_stem(depth, slop) {
difference(){
// outside shape
linear_extrude(height = depth) {
@ -11,6 +11,6 @@ module box_cherry_stem(depth, slop, throw) {
}
// inside cross
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
}

View File

@ -2,7 +2,7 @@ include <../functions.scad>
// extra length to the vertical tine of the inside cherry cross
// splits the stem into halves - allows easier fitment
extra_vertical = 100;
extra_vertical = 0.6;
module inside_cherry_cross(slop) {
// inside cross
@ -23,7 +23,7 @@ module inside_cherry_cross(slop) {
}
}
module cherry_stem(depth, slop, throw) {
module cherry_stem(depth, slop) {
difference(){
// outside shape
linear_extrude(height = depth) {
@ -32,6 +32,6 @@ module cherry_stem(depth, slop, throw) {
}
}
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
}

View File

@ -4,18 +4,18 @@ include <../functions.scad>
// splits the stem into halves - allows easier fitment
extra_vertical = 0.6;
module inside_cherry_stabilizer_cross(slop, throw) {
module inside_cherry_stabilizer_cross(slop) {
// inside cross
// translation purely for aesthetic purposes, to get rid of that awful lattice
translate([0,0,-SMALLEST_POSSIBLE]) {
linear_extrude(height = throw) {
linear_extrude(height = $stem_throw) {
square(cherry_cross(slop, extra_vertical)[0], center=true);
square(cherry_cross(slop, extra_vertical)[1], center=true);
}
}
}
module cherry_stabilizer_stem(depth, slop, throw) {
module cherry_stabilizer_stem(depth, slop) {
difference(){
// outside shape
linear_extrude(height = depth) {
@ -24,6 +24,6 @@ module cherry_stabilizer_stem(depth, slop, throw) {
}
}
inside_cherry_stabilizer_cross(slop, throw);
inside_cherry_stabilizer_cross(slop);
}
}

View File

@ -1,17 +1,5 @@
separation = 5.7;
module choc_stem(depth, slop){
positions = [
[separation/2, 0],
[-separation/2, 0],
];
// TODO throw not used
module choc_stem(depth, slop, throw){
for (position=positions) {
translate([position.x,position.y, depth/2]) single_choc_stem(depth, slop);
}
}
module single_choc_stem(depth, slop) {
cube([$choc_stem.x - slop, $choc_stem.y - slop, depth], center=true);
translate([-5.7/2, 0, depth/2]) cube([1.2 - slop, 3 - slop / 2, depth], center=true);
translate([5.7/2, 0, depth/2]) cube([1.2 - slop, 3 - slop / 2, depth], center=true);
}

View File

@ -1,4 +1,4 @@
module filled_stem(_depth, _slop, _throw) {
module filled_stem() {
// I broke the crap out of this stem type due to the changes I made around how stems are differenced
// now that we just take the dish out of stems in order to support stuff like
// bare stem keycaps (and buckling spring eventually) we can't just make a

View File

@ -1,12 +1,12 @@
include <../functions.scad>
include <cherry.scad>
module rounded_cherry_stem(depth, slop, throw) {
module rounded_cherry_stem(depth, slop) {
difference(){
cylinder(d=$rounded_cherry_stem_d, h=depth);
// inside cross
// translation purely for aesthetic purposes, to get rid of that awful lattice
inside_cherry_cross($stem_inner_slop);
inside_cherry_cross(slop);
}
}

View File

@ -1,7 +1,4 @@
include <../functions.scad>
// TODO this define doesn't do anything besides tell me I used flat() in this file
// is it better than not having it at all?
include <./flat.scad>
// figures out the scale factor needed to make a 45 degree wall
function scale_for_45(height, starting_size) = (height * 2 + starting_size) / starting_size;
@ -9,11 +6,6 @@ function scale_for_45(height, starting_size) = (height * 2 + starting_size) / st
// complicated since we want the different stems to work well
// also kind of messy... oh well
module flared(stem_type, loft, height) {
// flat support. straight flat support has a tendency to shear off; flared support
// all the way to the top has a tendency to warp the outside of the keycap.
// hopefully the compromise is both
flat(stem_type, loft + height/4, height);
translate([0,0,loft]){
if (stem_type == "rounded_cherry") {
linear_extrude(height=height, scale = scale_for_45(height, $rounded_cherry_stem_d)){
@ -41,6 +33,26 @@ module flared(stem_type, loft, height) {
}
}
} else if (stem_type == "choc") {
choc_scale = [scale_for_45(height, $choc_stem[0]), scale_for_45(height, $choc_stem[1])];
// double support
/*
translate([-5.7/2,0,0]) linear_extrude(height=height, scale = choc_scale){
// TODO make a choc_stem() function so it can build in the slop
square($choc_stem - [$stem_slop, $stem_slop], center=true);
}
translate([5.7/2,0,0]) linear_extrude(height=height, scale = choc_scale){
square($choc_stem - [$stem_slop, $stem_slop], center=true);
} */
// single support, full width
/* translate([0,0,0]) linear_extrude(height=height, scale = choc_scale){
// TODO make a choc_stem() function so it can build in the slop
square([total_key_width($wall_thickness), $choc_stem[1] - $stem_slop], center=true);
} */
// single support, just the stem
new_choc_scale = [scale_for_45(height, $choc_stem[0] + 5.7 - $stem_slop), scale_for_45(height, $choc_stem[1])];
translate([0,0,0]) linear_extrude(height=height, scale = new_choc_scale){

2385
yarn.lock

File diff suppressed because it is too large Load Diff