feat: Base with test example was built.

This commit is contained in:
KyMAN 2025-01-25 11:41:39 +01:00
parent b7cd867778
commit a1dbed7503
44 changed files with 7371 additions and 880 deletions

17
.gitignore vendored
View File

@ -1,7 +1,12 @@
Kanvas.apache2.conf
PHP/Kanvas.Secrets.php
Public/es
Public/dev
Public/index.html
Public/data
Data
*[Ss]ecrets?*
/Public/es
/Public/dev
/Public/index.html
/Public/data
/Data
html.files.json
/Python/Abstracts/AnPMap.py
/Python/Abstracts/Applications.py
__pycache__
.sass-cache

120
HTML/Kanvas.base.html Normal file
View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html lang="{language}">
<head>
<title data-i18n="{title_i18n}">{title_text}</title>
<meta http-equiv="content-type" content="text/html;charset={charset}" />
<meta charset="{charset}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="xdoc:project" content="Kanvas" />
<meta name="xdoc:link" content="https://kanvas.k3y.pw/" />
<meta name="xdoc:git" content="https://git.k3y.pw/KyMAN/Kanvas" />
<meta name="xdoc:author" content="KyMAN" />
<meta name="xdoc:since" content="20240626" />
<meta name="xdoc:version" content="20240626" />
<meta name="xdoc:access" content="public" />
<meta name="xdoc:donate:btc" content="" />
<meta name="xdoc:donate:ltc" content="" />
<meta name="xdoc:donate:doge" content="" />
<meta name="xdoc:donate:dash" content="" />
<style data-type="text/css;charset=utf-8" data-language="CSS1.2" data-rel="stylesheet" charset="utf-8">
html,body{
height : 100%;
margin : 0em;
}
</style>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.local/ecma/AnPScriptsLoader.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" charset="utf-8">
const domain = /^https?\:\/{2}[^\/]+\.((anprm\.)?local|anprm)/i.test(window.location) ? "local" : "k3y.pw";
new AnPScriptsLoader({
styles : [
"https://cdn." + domain + "/css/Roboto.v30.local.css",
"https://cdn." + domain + "/css/RobotoMono.v23.local.css",
"https://cdn." + domain + "/css/FA6F.v6.5.2.local.css",
"/scss/Kanvas.scss",
"https://wmarkdown." + domain + "/css/WMarkDown.icons.FontAwesome.css",
"https://wmarkdown." + domain + "/css/WMarkDown.web.icons.css",
"https://wmarkdown." + domain + "/scss/WMarkDown.scss",
"https://cdn." + domain + "/data/styles/Highlight.v11.10.0.min.css"
],
scripts : [[
"https://errorsmanager." + domain + "/ecma/ErrorsManager.ecma.js",
"https://wmarkdown." + domain + "/ecma/WMarkDown.ecma.js",
"https://cdn." + domain + "/data/scripts/Highlight.v11.10.0.min.js"
], [
"https://anp." + domain + "/ecma/Application/AnP.ecma.js"
], [
"https://anp." + domain + "/ecma/Managers/Settings.ecma.js",
"https://anp." + domain + "/ecma/Application/URI.ecma.js",
"https://anp." + domain + "/ecma/Managers/Globals.ecma.js",
"https://anp." + domain + "/ecma/Managers/I18N.ecma.js",
"https://anp." + domain + "/ecma/Managers/PrintTypes.ecma.js",
"https://anp." + domain + "/ecma/Managers/Threads.ecma.js",
"https://anp." + domain + "/ecma/Application/Attributes.ecma.js",
"https://anp." + domain + "/ecma/Application/HTMLPreload.ecma.js"
], [
"https://anp." + domain + "/ecma/Components/Base.ecma.js"
]]
}, () => {
wmarkdown = new WMarkDown({dictionary : "https://wmarkdown." + domain + "/json/WMarkDown.dict.es.kyman.json"});
anp = new AnP({
globals : {
anp_root : "https://anp." + domain,
kanvas_root : ""
},
callback : () => anp.base.set(".kanvas")
});
});
</script>
</head>
<body class="anp kanvas">
<header>
<h1 data-i18n="kanvas" data-i18n-without="true" title="{{kanvas}}">
<a href="{link}" target="_blank">
<span class="image">
<img src="{logo}" />
<span style="background-image:url('{logo}');"></span>
</span>
<span data-i18n="kanvas">{{kanvas}}</span>
</a>
</h1>
<nav class="main-menu">
<ul>
<li data-i18n="web" data-i18n-without="true" title="{{web}}">
<a href="/" target="_self">
<span data-icon="web"></span>
<span data-i18n="web">{{web}}</span>
</a>
</li>
<li data-i18n="git" data-i18n-without="true" title="{{git}}">
<a href="https://git.k3y.pw/KyMAN/Kanvas" target="_self">
<span data-icon="git"></span>
<span data-i18n="git">{{git}}</span>
</a>
</li>
</ul>
</nav>
</header>
<main>{contents}</main>
<footer>
<span class="license">
<a class="license-image" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" data-i18n="license_cc_by_nc_sa_4" data-i18n-without="true" title="{{license_cc_by_nc_sa_4}}">
<span data-i18n="license_cc_by_nc_sa_4">{{license_cc_by_nc_sa_4}}</span>
<img src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" data-i18n="license_cc_by_nc_sa_4" data-i18n-without="true" alt="{{license_cc_by_nc_sa_4}}">
</a>
</span>
</footer>
</body>
</html>

View File

@ -0,0 +1,3 @@
[
"get:/ /Kanvas/Public"
]

View File

@ -0,0 +1,22 @@
{
"kanvas_host_name" : "/^(https?\\:\\/{2})?kanvas\\.(k3y\\.pw|(anprm\\.)?local|anprm)/",
"kanvas_default_settings_files" : [
"/JSON/Kanvas.py.settings.json"
],
"kanvas_default_secrets_files" : [
"/JSON/Kanvas.py.settings.secrets.json"
],
"kanvas_default_i18n_files" : [
"/JSON/I18N/Python/Kanvas.py.i18n.espanol.json"
],
"kanvas_default_routes_files" : [
"/JSON/Kanvas.py.routes.json",
"/JSON/Kanvas.py.routes.secrets.json"
],
"kanvas_default_views_files" : [],
"kanvas_charset" : "utf-8",
"kanvas_logo" : "/images/Kanvas.png",
"kanvas_link" : "https://kanvas.k3y.pw/",
"kanvas_git" : "https://git.k3y.pw/KyMAN/Kanvas",
"kanvas_base_html" : "/HTML/Kanvas.base.html"
}

234
LICENSE
View File

@ -1,232 +1,170 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Creative Commons Attribution-ShareAlike 4.0 International
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Using Creative Commons Public Licenses
Preamble
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
The GNU General Public License is a free, copyleft license for software and other kinds of works.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
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.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described.
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.
Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
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.
Creative Commons Attribution-ShareAlike 4.0 International Public License
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.
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
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.
Section 1 Definitions.
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.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
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.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
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.
c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
The precise terms and conditions for copying, distribution and modification follow.
d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
TERMS AND CONDITIONS
e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
0. Definitions.
f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
“This License” refers to version 3 of the GNU General Public License.
g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution and ShareAlike.
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
“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.
i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
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.
j. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
A “covered work” means either the unmodified Program or a work based on the Program.
k. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
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.
l. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
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.
m. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
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.
Section 2 Scope.
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. License grant.
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.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
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.
A. reproduce and Share the Licensed Material, in whole or in part; and
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.
B. produce, reproduce, and Share Adapted Material.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
The Corresponding Source for a work in source code form is that same work.
3. Term. The term of this Public License is specified in Section 6(a).
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.
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
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.
5. Downstream recipients.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
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.
B. Additional offer from the Licensor Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapters License You apply.
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.
C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
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.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
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.
b. Other rights.
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:
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
2. Patent and trademark rights are not licensed under this Public License.
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”.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
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.
Section 3 License Conditions.
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.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
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.
a. Attribution.
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:
1. If You Share the Licensed Material (including in modified form), You must:
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.
A. retain the following if it is supplied by the Licensor with the Licensed Material:
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.
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
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.
ii. a copyright notice;
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.
iii. a notice that refers to this Public License;
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.
iv. a notice that refers to the disclaimer of warranties;
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.
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
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.
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
“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.
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
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).
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
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.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
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.
b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
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.
1. The Adapters License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
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.
2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
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:
3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
Section 4 Sui Generis Database Rights.
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
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
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
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
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.
Section 5 Disclaimer of Warranties and Limitation of Liability.
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.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
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.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
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.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
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).
Section 6 Term and Termination.
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.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
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.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
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.
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
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.
2. upon express reinstatement by the Licensor.
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.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public 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.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
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.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
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”.
Section 7 Other Terms and Conditions.
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.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
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.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
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.
Section 8 Interpretation.
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.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
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.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
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.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
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.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
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.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
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 <http://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 <http://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 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
Creative Commons may be contacted at creativecommons.org.

13
Public/doc/es/bugs.w.md Normal file
View File

@ -0,0 +1,13 @@
```wmd-options
language = es
title_i18n = kanvas_title_bugs
title_text = Bugs y errores - Kanvas
```
<!-- [[wmd]] -->
## Bugs y errores
Esta sección va orientada a exponer los posibles errores que se puedan encontrar dentro del proyecto y el estado al cual se atañen.
<!-- [[wmd]] -->

View File

@ -0,0 +1,7 @@
El proyecto **Kanvas** es un pequeño proyecto desarrollado por **KyMAN**, el cual no es más que un sencillo motor gráfico 2D basado en el API de Canvas para JavaScript sobre navegador. La idea es intentar renderizar al máximo la salida de gráficos 2D a partir de este mismo API ampliando su funcionabilidad nativa u original y facilitar su modificación en caliente. Para llevar a cabo dicho plan, la idea es tener un mapeado de lo que se quiere representar y sea éste el que se encargue de dibujarlo. Para que puedan existir niveles y capas de profundidad se optó por un mapeado en un formato de Arrays anidados de diccionarios en JSON los cuales definan los elementos. Una vez leídos, éstos se convertiran en un objeto directo en JavaScript, lo que reducirá la carga y permitirá especificar más en profundidad cada uno de los elementos. La posición ya determina la profundidad y el solapamiento de los elementos.
La idea es poner en un Array JSON todos los elementos ordenados y anidados sobre sí mismos, ya sean en posiciones específicas por los cuales, vayan saliendo éstos. Los elementos pueden tener hijos, concepto que permite el anidamiento pero heredarían posicionamiento y otras propiedades de los padres, algunas corregibles, como el propio posicionamiento; y otras no, como puede ser la transparencia. Este concepto evitaría tener que estar pendiente de la creación o gestión en sí misma más que la de los efectos o dinamismos, que irían a parte acorde únicamente a propiedades asignadas. Además, al estar en un Array interpretado, el dibujado iría plenamente controlado por éste, automatizando gran parte del control con este concepto y reducir la carga de los efectos heredados y posicionamientos anidados.
Para evitar una extensión enorme de la librería, y pensando en el tipo de plataformas que se piensa aplicar dicho proyecto, éste se basará plenamente en el **AnP**, otro proyecto del que participa KyMAN como creador y desarrollador, pero en este caso, desde la estructura gráfica básica, con lo que tendríamos un sistema de tamaño dinámico que unifique tamaño en las distintas pantallas, gestor de configuraciones, I18N, hilos de proceso simulados \(intervalos de JavaScript), etc.
El nombre de *Kanvas* viene del elemento con API **Canvas**, pero sobre el nombre *KyMAN*, creador de este proyecto.

11
Public/doc/es/design.w.md Normal file
View File

@ -0,0 +1,11 @@
```wmd-options
language = es
title_i18n = kanvas_title_design
title_text = Estilo y diseño - Kanvas
```
<!-- [[wmd]] -->
## Estilo y diseño
<!-- [[wmd]] -->

View File

@ -0,0 +1,28 @@
El concepto de funcionamiento es relativamente sencillo: se basa en un cuadrado, el cual determinará las medidas porcentuales a modo de simulación de DPIs en los dispositivos móviles, cogiendo el tamaño relativo al la sección más estrecha de la pantalla donde se muestre, siempre entendiendo como ésta un espacio rectangular. Para poder simular los DPI se usará un sistema de división de celdas para dicho cuadrado, donde se dividirá la sección estrecha de la pantalla en ese número de celdas para hallar el tamaño de la misma, valor que se usará para relativizar las medidas, dándose éstas en porcentajes o en celdas, pudiendo ser, en ambos casos, valores decimales.
El cuadrado que determina la pantalla se centrará y puede dibujarse fuera del mismo a conveniencia del desarrollador si éste lo procisara, luego, la posición inicial de los elementos será la establecida en la configuración mediante los parámetros **base_x** y **base_y** de forma porcentual dentro de ese cuadrado, siendo sus valores por defecto para ambos el ".5", éste indica 50% y representa el centro de dicho cuadrado, pero podemos establecer la siguiente tabla de posiciones medias para entender como funciona este mecanismo:
[|
|= X | Y | Posición
| 0 | 0 | Arriba-Izquierda
| 0 | .5 | Arriba-Centro
| 0 | 1 | Arriba-Derecha
| .5 | 0 | Centro-Izquierda
| .5 | .5 | Centro-Centro
| .5 | 1 | Centro-Derecha
| 1 | 0 | Abajo-Izquierda
| 1 | .5 | Abajo-Centro
| 1 | 1 | Abajo-Derecha
|]
[| style="width:30em;height:30em;"
| \(0, 0)<br />Arriba-Izquierda | \(0, .5)<br />Arriba-Centro | \(0, 1)<br />Arriba-Derecha
| \(.5, 0)<br />Centro-Izquierda | \(.5, .5)<br />Centro-Centro | \(.5, 1)<br />Centro-Derecha
| \(1, 0)<br />Abajo-Izquierda | \(1, .5)<br />Abajo-Centro | \(1, 1)<br />Abajo-Derecha
|]
La idea es ir creando formas que estén definidas dentro de un mapeado en formato Array que se vayan dibujando dinámicamente en cada ciclo a partir de esa posición. En el caso de los elementos anidados, dicha posición parte directamente de la posición del padre. El solapamiento o eje Z se automatizaría con la misma idea, dejando atrás a los primeros elementos creados, incluyendo sus anidamientos, todo automatizado gracias al concepto del Array.
> [!#] El concepto del Array es similar al que se puede ver cuando se trabaja HTML, CSS, etc. Donde los elementos se dibujan en base a algo preestablecido y que cuando se cambia algo de éstos, dicho cambio aparece reflejado en el GUI que se esté trabajando. La idea es optimizar el modelo de creación de elementos al máximo mediante cacheados y formas preprogramadas en objetos.
> [!!] Es importante destacar que los cálculos de las posiciones dadas se hacen automáticamente de forma interna por el propio Kanvas, aunque sí es habrá que saber cómo funciona para la creación de formas o elementos personalizados, lo cual, se explicará en el apartado correspondiente más adelante.

View File

@ -0,0 +1,19 @@
```wmd-options
language = es
title_i18n = Kanvas_title_technical_developer
title_text = Manual del desarrollador - Kanvas
```
<!-- [[wmd]] -->
### Manual del desarrollador
Este manual irá orientado a los desarrolladores que consuman esta librería para sus proyectos, y sólo se hablará de las posibilidades así como de sus elementos públicos accesibles a los que fue diseñado.
[[include description.md]]
[[include settings.w.md]]
[[include mapper.w.md]]
<!-- [[wmd]] -->

View File

@ -0,0 +1,67 @@
```wmd-options
language = es
title_i18n = Kanvas_title_technical_mapper
title_text = Mapeador - Kanvas
```
<!-- [[wmd]] -->
### Mapeador
El mapeador es el elemento donde se mapearán los objetos que contenga nuestro elemento HTML Canvas, procesado y gestionado sobre Kanvas. El acceso a dicho elemento es público y la variación de los elementos que contiene es dinámica presentándose directamente en el GUI como resultado.
```js
/** @type {AnP} */
const anp = new AnP({
globals : {
anp_root : "https://anp.k3y.pw"
},
callback : () => {
/** @type {Kanvas} */
const kanvas = new Kanvas(anp);
/** @type {boolean} */
let done = false,
/** @type {number|null} */
time = null;
// Creamos elementos en el mapa.
kanvas.map = [
{type : "rectangle", x : -20, y : -20, width : 40, height : 40, background : "#F00", rotate : 45, alpha : .6, childs : [
{type : "rectangle", x : 14, y : 14, width : 4, height : 4, background : "#8F8"}
]},
{type : "rectangle", x : -5, y : -3, width : 10, height : 6, background : "#0BA", alpha : .4},
{type : "text", x : 20, y : -20, text : "FPS", baseline : "top", align : "right", style : "bold", color : "#600", size : 2},
{type : "image", x : -10, y : -10, width : 20, height : 20, source : "https://cdn.k3y.pw/data/space_art_publish/red_giant.png", rotate : 45},
{type : "text", x : 20, y : -18, text : "Delta", baseline : "top", align : "right", style : "bold", color : "#600", size : 2}
];
// Cambio de FPSs
anp.threads.restart(24);
// Hilo donde se gestionan los cambios dentro del mapa.
anp.threads.add(() => {
/** @type {number} */
const new_time = Date.now();
if(done){
kanvas.map[0].rotate(1 * kanvas.delta);
kanvas.map[0].childs[0].rotate(-3 * kanvas.delta);
kanvas.map[3].rotate(-1 * kanvas.delta);
time && (kanvas.map[2].text = kanvas.fps.toFixed(2) + " FPS");
kanvas.map[4].text = kanvas.delta.toFixed(3) + " Delta";
}else
done = kanvas.map.every(item => item.state & Kanvas.prototype.LOADED);
time = new_time;
});
}
})
```
<!-- [[wmd]] -->

View File

@ -0,0 +1,74 @@
```wmd-options
language = es
title_i18n = Kanvas_title_settings
title_text = Configuración - Kanvas
```
<!-- [[wmd]] -->
#### Configuración
La configuración e esta librería se establece a la hora de construir la misma, aunque sí es cierto que a posteriori, en caliente, los atributos pueden ir modificándose. Para establecer la configuración inicial tendríamos la siguiente forma:
```js
/** @type {AnP} */
const anp = new AnP({
globals : {
anp_root : "https://anp.k3y.pw"
},
callback : () => {
/** @type {Kanvas} */
const kanvas = new Kanvas(anp, {
position : "body",
autocreate : true,
quality : 1,
base_x : .5,
base_y : .5,
cells : 40,
autostart : true
});
}
});
```
> [!#] En el ejemplo se muestran las configuraciones por defecto del inicio del sistema, pero no son los únicos parámetros.
Los parámetros de configuración que hay serían los siguientes:
[|
|= Campo | Tipado | Obligatorio | Valor por defecto | Descripción
| position | "String|HTMLElement" | Sí | '"body"' | "
Sería el selector del elemento donde se quiera instalar por defecto el elemento HTML Canvas o bien, el propio elemento de forma directa.
"
| autocreate | Boolean | Sí | true | "
Determina si se autocrea el elemento HTML Canvas en la posición dada por defecto o no.
"
| quality | "Integer|Float" | Sí | 1 | "
Valor entero o decimal comprendido entre 0 y 1 sin cubrir nunca el valor 0 y determina porcentualmente la calidad de la imagen resultante. *Si se pone un valor superior a 1 o inferior a 0 éstos serán equivalentes a la máxima y a la mínima consecutivamente.*
"
| base_x | "Integer|Float" | Sí | .5 | "
Valor entero o decimal comprendido entre 0 y 1, ambos inclusive, el cual determina la posición porcentual de donde establecer el origen en el eje X de los elementos a visualizar en pantalla. Dicho valor puede exceder el valor dado quedando fuera del marco principal de pantalla, el origen en el eje X de los elementos a visualizar en pantalla.
"
| base_y | "Integer|Float" | Sí | .5 | "
Valor entero o decimal comprendido entre 0 y 1, ambos inclusive, el cual determina la posición porcentual de donde establecer el origen en el eje Y de los elementos a visualizar en pantalla. Dicho valor puede exceder el valor dado quedando fuera del marco principal de pantalla, el origen en el eje Y de los elementos a visualizar en pantalla.
"
| cells | Integer | Sí | 40 | "
Valor numérico entero positivo en el cual se indica el número de celdas en el que se divide la pantalla de muestreo principal de los elementos a visualizar.
"
| autostart | Boolean | Sí | true | Determina si el objeto Kanvas o no.
| class | String | No | | Establece valores de clase al elemento HTML Canvas.
| git | String | No | | "
Establece la dirección del proyecto Git como atributo del elemento HTML Canvas.
"
| link | String | No | | "
Establece la dirección URL del proyecto como atributo del elemento HTML Canvas.
"
|]
Es importante tener en cuenta que estos parámetros sólo afectan única y exclusivamente a Kanvas, pero al estar basado en AnP, ciertos comportamientos se condicionan a AnP, como puede ser la frecuencia de refresco del hilo de procesos del que cuelga el funcionamiento del mismo, que es el parámetro de configuración ***fps*** o ***frames_per_second*** del mismo.
<!-- [[wmd]] -->

View File

@ -0,0 +1,55 @@
```wmd-options
language = es
title_i18n = kanvas_title_donates
title_text = Donaciones - Kanvas
```
<!-- [[wmd]] -->
## Donaciones
Este proyecto es plenamente gratuito pues es un proyecto orientado a complementar otros proyectos de los mismos desarrolladores. No tiene ningún plan de ingresos ni pasivos ni activos más allá de lo que se expone en este título. Si alguien quisiere colaborar en que este proyecto no sólo esté abierto por requisitos de los autores, sino también cara un mantenimiento hacia terceros, a continuación presentamos unas direcciones de Cryptoactivos donde se podrá donar sin ninguna cuantía mínima establecida.
- **Bitcoin** o *BTC*: [bitcoin: DIRECCIÓN]
- **Litecoin** o *LTC*: [litecoin: DIRECCIÓN]
- **Dogecoin** o *DOGE*: [dogecoin: DIRECCIÓN]
- **Dash**: [dash: DIRECCIÓN]
- **Faircoin** o *FAIR*: [faircoin: DIRECCIÓN]
> [!!] Mientras no halla ninguna condición de recursos que impida el mantenimiento gratuito de este servicio, éste permanecerá mantenido y público independientemente de los ingresos obtenidos a partir de los donativos.
> [!#] Los usuarios que colaboren y quieran ser referenciados, éstos serán referenciados en este apartado mediante un Quote de comentario de usuario con el Nick y avatar correspondiente, pero sólo en caso de que ellos quieran aparecer aquí.
> [!#] Se mantendrá informados a los usuarios de todo aquel donativo dado y la cantidad económica adquirida, y será publicado su uso y tenencia para que halla constancia pública del uso que se le dé a dichos recursos.
> [!@Srx00] Quería agredecer de forma persona aquellas aportaciones que serán bien recibidas y valoradas para este proyecto, ya sea como valor simbólico como de mantenimiento. Así, que desde el desarrollo y como desarrollador de este proyecto, muchas gracias a todos aquellos que ponen su granito de arena para este proyecto y por lo tanto, en pro de todos. Muchas gracias, de verdad.
### Balance
A continuación se mostrará una tabla de balance con respecto a las cantidades y usos dados.
[|
|= Activo | Cantidad | Motivo | Usuario | Cantidad total actual
| **BTC** | 0 BTC | Inicio del contador de unidades de BTC. | | 0 BTC
| **LTC** | 0 LTC | Inicio del contador de unidades de LTC. | | 0 LTC
| **DOGE** | 0 DOGE | Inicio del contador de unidades de DOGE. | | 0 DOGE
| **DASH** | 0 DASH | Inicio del contador de unidades de DASH. | | 0 DASH
| **FAIR** | 0 FAIR | Inicio del contador de unidades de FAIR. | | 0 FAIR
|]
Cómputo total actual en tenencia.
[|
|= Activo | Cantidad | Número de Operaciones
| **BTC** | 0 BTC | 0
| **LTC** | 0 LTC | 0
| **DOGE** | 0 DOGE | 0
| **DASH** | 0 DASH | 0
| **FAIR** | 0 FAIR | 0
|]
### Donantes
A continuación, los comentarios de los donantes.
<!-- [[wmd]] -->

13
Public/doc/es/faq.w.md Normal file
View File

@ -0,0 +1,13 @@
```wmd-options
language = es
title_i18n = kanvas_title_faq
title_text = F.A.Q. - Kanvas
```
<!-- [[wmd]] -->
## F.A.Q.
En este apartado se irán haciendo preguntas y respuestas acorde a motivos sobre las decisiones que se tomaron para llevar a cabo dicho proyecto.
<!-- [[wmd]] -->

View File

@ -0,0 +1,169 @@
```wmd-options
language = es
title_i18n = Kanvas_title_integration
title_text = Integración - Kanvas
```
<!-- [[wmd]] -->
## Integración
Para poder integrar este proyecto a otro simplemente hemos de implementarlo junto a AnP. Para ello tendríamso dos formas de implementarlo.
### Integración directa
La integración directa es la que nosotros creamos manualmente las etiquetas Scripts que nos permiten cargar las librerías necesarias para nuestro fin.
```html
<!DOCTYPE html>
<html>
<head>
<title>PROYECTO</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://errorsmanager.k3y.pw/ecma/ErrorsManager.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Application/AnP.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/Settings.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Application/Ajax.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/Globals.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/I18N.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/PrintTypes.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/Threads.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Managers/Events.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Application/Attributes.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Application/HTMLPreload.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/Application/Binary.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="/ecma/Kanvas.AnP.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" charset="utf-8">
/** @type {AnP} */
const anp = new AnP({
globals : {
anp_root : "https://anp.k3y.pw"
},
callback : () => {
/** @type {Kanvas} */
const kanvas = new Kanvas(anp);
}
});
</script>
</head>
<body></body>
</html>
```
### Integración mediante AnPScriptsLoader
La integración mediante AnPScriptsLoader viene siendo la carga de todas las librerías mediante esta librería de carga de Scripts y estilos de manera asíncrona y precargada del propio proyecto AnP.
```html
<!DOCTYPE html>
<html>
<head>
<title>PROYECTO</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" src="https://anp.k3y.pw/ecma/AnPScriptsLoader.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script data-type="text/javascript;charset=utf-8" data-language="ECMAScript 2015" charset="utf-8">
new AnPScriptsLoader({
scripts : [[
"https://errorsmanager.k3y.pw/ecma/ErrorsManager.ecma.js"
], [
"https://anp.k3y.pw/ecma/Application/AnP.ecma.js"
], [
"https://anp.k3y.pw/ecma/Managers/Settings.ecma.js",
"https://anp.k3y.pw/ecma/Application/Ajax.ecma.js",
"https://anp.k3y.pw/ecma/Managers/Globals.ecma.js",
"https://anp.k3y.pw/ecma/Managers/I18N.ecma.js",
"https://anp.k3y.pw/ecma/Managers/PrintTypes.ecma.js",
"https://anp.k3y.pw/ecma/Managers/Threads.ecma.js",
"https://anp.k3y.pw/ecma/Managers/Events.ecma.js",
"https://anp.k3y.pw/ecma/Application/Attributes.ecma.js",
"https://anp.k3y.pw/ecma/Application/HTMLPreload.ecma.js",
"https://anp.k3y.pw/ecma/Application/Binary.ecma.js"
], [
"https://kanvas.k3y.pw/ecma/Kanvas.AnP.ecma.js"
]]
}, () => {
/** @type {AnP} */
const anp = new AnP({
globals : {
anp_root : "https://anp.k3y.pw"
},
callback : () => {
/** @type {Kanvas} */
const kanvas = new Kanvas(anp);
}
});
});
</script>
</head>
<body></body>
</html>
```
### Sincronía
La sincronía de la librería Kanvas contra AnP puede ser síncrona si la configuración que se le dé es la que tiene por defecto o bien, es una configuración dada mediante en *input* de entrada, o por el contrario, puede ser asíncrona como se mostró en los ejemplos anteriores. Presuponiendo que se tienen las librerías pertinentes precargadas, los métodos de creación de un objeto Kanvas pueden ser los siguientes:
```js
"use strict";
// Método de creación síncrono.
/** @type {Kanvas} */
const kanvas_sincrono = new Kanvas(new AnP({
globals : {
anp_root : "httsp://anp.k3y.pw"
}
}));
// Método de creación síncrono con parámetros.
/** @type {Kanvas} */
const kanvas_sincrono_con_parametros = new Kanvas(new AnP({
globals : {
anp_root : "httsp://anp.k3y.pw"
}
}), {
parametro_1 : 1,
parametro_2 : 2,
parametro_3 : 3,
parametro_n : "N"
});
// Método de creación asíncrona.
/** @type {AnP} */
const anp = new AnP({
globals : {
anp_root : "https://anp.k3y.pw"
},
callback : () => {
// En este método también puede tener entrada de parámetros como en el ejemplo síncrono.
/** @type {Kanvas} */
const kanvas_asincrono = new Kanvas(anp);
}
});
```
> [!!] La carga asíncrona se usaría para tener acceso a toda la funcionalidad completa de AnP desde el principio, cosa que se aconseja encarecidamente para evitar problemas de funcionamientos inesperados.
<!-- [[wmd]] -->

17
Public/doc/es/manual.w.md Normal file
View File

@ -0,0 +1,17 @@
```wmd-options
language = es
title_i18n = Kanvas_title_manual
title_text = Manual - Kanvas
```
<!-- [[wmd]] -->
## Manual
El manual de este proyecto se dividirá en dos partes, siendo la primera la parte común cara los desarrolladores que consuman esta librería; y los desarrolladores que quieran usar esta librería de forma profunda o simplemente comprender cómo funciona.
[[include developer/index.w.md]]
[[include technical/index.w.md]]
<!-- [[wmd]] -->

View File

@ -0,0 +1,15 @@
```wmd-options
language = es
title_i18n = kanvas_title_opinions
title_text = Opiniones y comentarios - Kanvas
```
<!-- [[wmd]] -->
## Opiniones y comentarios
Esta sección va dedicada a publicar las opiniones y comentarios de usuarios cercanos a los desarrolladores del proyecto para que halla una visión externa a éste, aprobechando la confianza en éstos tanto para lo bueno como para lo malo.
> [!@Srx00] Quería agradecer personalmente a todos aquellos que me han dado una opinión y/o comentario acerca de este proyecto. Lo valor mucho pues sea como crítica para aprender como apoyo a continuar con este tipo de trabajos, me son realmente importantes. ¡Muchas gracias!
<!-- [[wmd]] -->

View File

@ -0,0 +1,44 @@
```wmd-options
language = es
title_i18n = kanvas_title_projects
title_text = Proyectos - Kanvas
```
<!-- [[wmd]] -->
## Proyectos
Este proyecto se lleva a cabo a partir de los siguientes proyectos directamente:
[["""
AnP
*https://anp.k3y.pw/images/AnP.png
*https://anp.k3y.pw/images/AnP-512.png
*https://anp.k3y.pw/favicon.ico
https://anp.k3y.pw/
https://git.k3y.pw/AnP/AnP
"""]]
Por otro lado, la documentación se basa plenamente en los siguientes proyectos:
[["""
WMarkDown
*https://wmarkdown.k3y.pw/images/WMarkDown.png
*https://wmarkdown.k3y.pw/images/WMarkDown-512.png
*https://wmarkdown.k3y.pw/favicon.ico
https://wmarkdown.k3y.pw/
https://git.k3y.pw/Whalers/WMarkDown
"""]]
Este proyecto es usado abiertamente en otros proyectos los cuales exponemos a continuación:
[["""
MuWeb
*https://muweb.k3y.pw/images/MuWeb.png
*https://muweb.k3y.pw/images/MuWeb-512.png
*https://muweb.k3y.pw/favicon.ico
https://muweb.k3y.pw/
https://git.k3y.pw/KyMAN/MuWeb
"""]]
<!-- [[wmd]] -->

View File

@ -0,0 +1,42 @@
```wmd-options
language = es
title_i18n = kanvas_title_targets
title_text = Objetivos - Kanvas
```
<!-- [[wmd]] -->
## Objetivos
Los objetivos para poder llevar a cabo este proyecto son los siguientes:
+ [X] Montar estructura base del proyecto.
+ [-] Montar motor.
+ [X] Base del fichero ECMA/JS.
+ [X] Generador de objetos CANVAS y/o referencia a éstos.
+ [X] Montar sistema de mapeado dinámico \(Dibujador) vía Arrays anidados con Diccionarios/Objetos.
+ [X] Atributos de proporción y posicionamiento.
+ [X] Generación de atributos comunes.
+ [X] Rotación.
+ [X] Transparencia \(Efecto alfa).
+ [X] Color.
+ [X] Posición.
+ [X] Hijos \(Gestor de elementos anidados).
+ [X] Printer para imprimir objeto por consola del navegador para testeos y debugging.
+ [-] Disposición y tamaño.
+ [X] Nativo, es decir, por celdas.
+ [ ] Porcentaje.
+ [ ] Determinar si se mira todo el objeto Canvas o no *\(full)*.
+ [X] Dibujador de rectándulos.
+ [X] Dibujador de imágenes.
+ [X] Dibujador de texto.
+ [ ] Dibujador de capa vacía.
+ [ ] Gestor de elementos caché.
+ [ ] Dibujador de formas personalizadas.
* [ ] Integrar automáticamente la creación de AnP cuando éste no esté dado o definido.
+ [-] Documentar.
+ [-] Montaje de la documentación base en WMarkDown.
+ [ ] Documentación técnica.
+ [ ] Publicar y actualizar.
<!-- [[wmd]] -->

View File

@ -0,0 +1,15 @@
```wmd-options
language = es
title_i18n = Kanvas_title_technical_manual
title_text = Manual técnico - Kanvas
```
<!-- [[wmd]] -->
### Manual técnico
Manual que analiza el trabajo de forma profunda para su comprensión y posibles modificaciones para terceros.
> [!!] Para poder comprender plenamente este manual, es importantísimo entender la parte del manual para el desarrollador.
<!-- [[wmd]] -->

File diff suppressed because it is too large Load Diff

104
Public/ecma/t.js Normal file
View File

@ -0,0 +1,104 @@
"use strict";
/**
* @class
* @constructor
* @returns {void}
* @access public
*/
const X = (function(){
/**
* @constructs X
* @returns {void}
* @access private
*/
const X = function(){
/** @type {X} */
const self = this;
/** @type {number} */
this.frames_per_second = 60;
/** @type {number} */
this.threads_mode = X.THREADS_MODE_ANIMATION;
/**
* @returns {number}
* @access private
*/
const thread_timer = () => self.frames_per_second && 1000 / self.frames_per_second;
/**
* @returns {void}
* @access private
*/
const execute_threads_by_mode = () => {
switch(self.threads_mode){
case X.THREADS_MODE_INTERVAL:
/** @type {Object.<string, number>} */
const cache = {
frames_per_second : self.frames_per_second,
mode : self.threads_mode
},
/** @type {number} */
interval = setInterval(() => {
execute_threads();
if(
cache.frames_per_seconds != self.frames_per_second ||
cache.mode != self.threads_mode
){
clearInterval(interval);
execute_threads_by_mode();
};
}, thread_timer());
break;
case X.THREADS_MODE_TIMEOUT:
setTimeout(() => {
execute_threads();
execute_threads_by_mode();
}, thread_timer());
break;
case X.THREADS_MODE_ANIMATION:
default:
/** @type {number} */
const time = Date.now(),
/** @type {number} */
timer = thread_timer();
requestAnimationFrame(() => {
execute_threads();
setTimeout(() => {
execute_threads_by_mode();
}, timer - (Date.now() - time));
});
break;
};
};
/** @type {number} */
X.THREADS_MODE_INTERVAL = 1 << 0;
/** @type {number} */
X.THREADS_MODE_TIMEOUT = 1 << 1;
/** @type {number} */
X.THREADS_MODE_ANIMATION = 1 << 2;
/**
* @returns {void}
* @access private
*/
const execute_threads = () => {};
execute_threads_by_mode();
};
return X;
})();
/** @type {X} */
const x = X();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,456 @@
"use strict";
/**
* @typedef {import("../../../AnP/Public/ecma/AnP.ecma.js").AnP} AnP
*/
/**
* @constructor
* @param {!AnP} anp
* @param {!(Object.<string, any|null>|Array.<Object.<string, any|null>>)} [inputs]
* @param {!anp_default_callback} [callback]
* @returns {void}
* @access public
*/
const Kanvas = function(anp, inputs, callback){
/** @type {Kanvas} */
const self = this,
/** @type {Object.<string, any|null>} */
settings = AnP.prototype.get_dictionary([{
/** @type {HTMLElement|string} */
position : "body",
/** @type {boolean} */
autocreate : true,
/** @type {number} */
quality : 1,
/** @type {number} */
base_x : .5,
/** @type {number} */
base_y : .5,
/** @type {number} */
cells : 40,
/** @type {boolean} */
autostart : true
}, inputs]),
/** @type {Object.<string, number>} */
screen = {x : 0, y : 0, quality : 0},
/** @type {Object.<string, number>} */
base = {x : .5, y : .5};
/** @type {boolean} */
let started = false,
/** @type {HTMLCanvasElement|null} */
canvas = null,
/** @type {CanvasRenderingContext2D|null} */
context = null,
/** @type {number|null} */
thread = null,
/** @type {number} */
quality = 1,
/** @type {number} */
cell_size = 1,
fps_time = 0;
/** @type {Array.<Kanvas.prototype.ObjectBase|Object.<string, any|null>|Array.<any|null>|null>} */
this.map = [];
/** @type {Object.<string, number>} */
this.screen = {x : 0, y : 0};
/** @type {number} */
this.cells = 40;
this.delta = 0;
this.fps = 0;
/**
* @returns {void}
* @access private
*/
const constructor = () => {
anp.settings.get("autostart", settings) && self.start(callback);
};
/**
* @param {!anp_start_callback} [callback]
* @returns {boolean}
* @access public
*/
this.start = callback => {
/**
* @param {!boolean} status
* @returns {void}
*/
const end = status => AnP.prototype.execute(callback, status);
if(started){
end(false);
return false;
};
started = true;
quality = anp.settings.get("quality", settings);
base.x = anp.settings.get("base_x", settings);
base.y = anp.settings.get("base_y", settings);
self.cells = anp.settings.get("cells", settings);
if(anp.settings.get("autocreate", settings))
self.create(anp.settings.get("position", settings), () => end(true));
else
end(true);
return true;
};
/**
* @param {!number} value
* @returns {number}
* @access public
*/
this.aexis = value => value * cell_size;
/**
* @param {!number} value
* @returns {number}
* @access private
*/
const _ = this.aexis;
/**
* @returns {Array.<number>}
* @access public
* @deprecated
*/
this.get_transform_matrix = () => {
/** @type {DOMMatrix} */
const transform = context.getTransform();
return [
transform.a,
transform.b,
transform.c,
transform.d,
transform.e,
transform.f
];
};
/**
* @returns {void}
* @access private
*/
const thread_method = () => {
const new_time = Date.now();
if(screen.x != canvas.offsetWidth || screen.y != canvas.offsetHeight || screen.quality != quality){
screen.quality = quality;
canvas.width = quality * (screen.x = canvas.offsetWidth);
canvas.height = quality * (screen.y = canvas.offsetHeight);
cell_size = quality * screen[screen.y < screen.x ? "y" : "x"] / self.cells;
self.screen.x = quality * screen.x / cell_size;
self.screen.y = quality * screen.y / cell_size;
};
/** @type {Array.<number>} */
const x = _(base.x * self.screen.x),
y = _(base.y * self.screen.y);
context.clearRect(0, 0, _(self.screen.x), _(self.screen.y));
context.translate(x, y);
draw(self.map);
context.translate(-x, -y);
if(fps_time){
self.fps = 1000 / (new_time - fps_time);
self.delta = 24 / self.fps;
};
fps_time = new_time;
};
/**
* @param {!(string|HTMLElement)} position
* @param {!anp_default_callback} [callback]
* @returns {void}
* @access public
*/
this.create = (position, callback) => {
if(canvas)
AnP.prototype.execute(callback);
else
new HTMLPreload(anp, position, item => {
if(item){
anp.attributes.set(canvas = item.appendChild(document.createElement("canvas")), {
class : ["kanvas"].concat(AnP.prototype.get_class_keys(AnP.prototype.get_value("class", settings))).join(" ").trim(),
git : AnP.prototype.get_value("git", settings),
link : AnP.prototype.get_value("link", settings)
});
context = canvas.getContext("2d");
thread = anp.threads.add(thread_method);
};
AnP.prototype.execute(callback);
});
};
/**
* @param {!Array.<Array.<any|null>|Object.<string, any|null>|Kanvas.prototype.ObjectBase|null>} map
* @returns {void}
* @access private
*/
const draw = map => map.forEach((item, i) => {
if((AnP.prototype.is_dictionary(item) && !item.draw) || AnP.prototype.is_array(item)){
/** @type {string} */
const type = AnP.prototype.is_dictionary(item) ? item.type : item.shift(),
/** @type {Kanvas.prototype.ObjectBase} */
_class = self.objects[type] || self.objects[object_synonyms[type]];
map[i] = _class ? _class(item) : null;
map[i].print && console.log(map[i]);
};
if(item && item.state & Kanvas.prototype.LOADED){
const base_x = _(item.x),
base_y = _(item.y);
context.save();
context.translate(base_x, base_y);
if(item.rotation){
/** @type {number} */
const x = item.width ? _(item.width / 2) : 0,
/** @type {number} */
y = item.height ? _(item.height / 2) : 0;
context.translate(x, y);
context.rotate(2 * Math.PI * item.rotation / 360);
context.translate(-x, -y);
};
item.background && (context.fillStyle = item.background);
item.alpha !== null && (context.globalAlpha = item.alpha);
item.draw();
item.background && context.fill();
item.childs && draw(item.childs);
context.translate(-base_x, -base_y);
context.restore();
};
});
/**
* @constructor
* @callback kanvas_builder_callback
* @param {!Object.<string, any|null>} inputs
* @returns {void}
*/
/**
* @constructor
* @callback kanvas_object_callback
* @param {!(Object.<string, any|null>|Object.<any|null>)} inputs
* @returns {void}
*/
/**
*
* @param {!Array.<string>} keys
* @param {!(Object.<string, any|null>|Array.<any|null>>)} inputs
* @param {!kanvas_builder_callback} Builder
* @returns {Kanvas.prototype.ObjectBase}
*/
const build_shape = (keys, inputs, Builder) => {
const base = new Kanvas.prototype.ObjectBase(
inputs = Kanvas.prototype.to_dictionary_values(keys, inputs)
);
return AnP.prototype.extends(base, true, new Builder(base, inputs));
};
/** @type {Object.<string, string>} */
const object_synonyms = {
rectangle : "Rectangle",
image : "Image",
text : "Text",
image : "Image"
};
/** @type {Object.<string, kanvas_object_callback>} */
this.objects = {
Rectangle : inputs => build_shape(["x", "y", "width", "height"], inputs, function(item, inputs){
/** @type {string} */
this.type = self.objects.Rectangle;
this.type_name = "Rectangle";
this.width = AnP.prototype.get_value("width", inputs, 0);
this.height = AnP.prototype.get_value("height", inputs, 0);
this.state = Kanvas.prototype.LOADED;
this.draw = () => context.fillRect(0, 0, _(item.width), _(item.height));
}),
Image : inputs => build_shape(["source", "x", "y", "width", "height", "cut_x", "cut_y", "cut_width", "cut_height"], inputs, function(item, inputs){
const image_item = AnP.prototype.get_value(["image", "source", "src"], inputs, null),
has = {any : false, all : true},
set_sizes = () => {
["x", "y", "width", "height"].forEach(key => this[key] === null && (this[key] = "xy".includes(key) ? 0 : this.image[key]));
if(!has.all && has.any){
["x", "y", "width", "height"].forEach(key => this["cut_" + key] === null && (this["cut_" + key] = "xy".includes(key) ? 0 : this.image[key]));
};
};
["x", "y", "width", "height"].forEach(key => {
has.any = (
has["cut_" + key] = (
this["cut_" + key] = AnP.prototype.get_value("cut_" + key, inputs, null)
) !== null
) || has.any;
has.all = has.all && has["cut_" + key];
});
this.type = self.objects.Image;
this.type_name = "Image";
this.url = AnP.prototype.is_string(image_item) ? image_item : image_item ? image_item.src : null;
this.image = AnP.prototype.is_object(image_item) ? image_item : null;
this.width = AnP.prototype.get_value("width", inputs, null);
this.height = AnP.prototype.get_value("height", inputs, null);
this.state = this.image ? Kanvas.prototype.LOADED : Kanvas.prototype.UNLOADED;
this.object = null;
if(this.state & Kanvas.prototype.UNLOADED && !this.image && this.url){
const image_object = new Image();
item.state = Kanvas.prototype.LOADING;
image_object.src = this.url;
image_object.onload = () => {
item.image = image_object;
item.state = Kanvas.prototype.LOADED;
set_sizes();
};
image_object.onerror = () => {
item.state |= Kanvas.prototype.ERROR;
};
}else
set_sizes();
this.draw = () => context.drawImage(item.image, 0, 0, _(item.width), _(item.height));
}),
Text : inputs => build_shape(["text", "x", "y"], inputs, function(item, inputs){
this.type = self.objects.Text;
this.type_name = "Text";
this.text = AnP.prototype.get_value("text", inputs, "");
this.align = AnP.prototype.get_value("align", inputs, null);
this.baseline = AnP.prototype.get_value("baseline", inputs, null);
this.size = AnP.prototype.get_value("size", inputs, null);
this.style = AnP.prototype.get_value("style", inputs, null);
this.font = AnP.prototype.get_value(["font_family", "font"], inputs, null);
this.direction = AnP.prototype.get_value("direction", inputs, null);
this.state = Kanvas.prototype.LOADED;
this.draw = () => {
item.direction && (context.direction = item.direction);
item.baseline && (context.textBaseline = item.baseline);
(item.size || item.font || item.style) && (context.font = (item.style ? item.style + " " : "") + (quality * (item.size || 1) * cell_size) + "px " + (item.font || "sans"));
item.align && (context.textAlign = item.align);
context[item.background ? "fillText" : "strokeText"](item.text, 0, 0);
};
})
};
constructor();
};
/**
* @param {!(Array.<string>|string)} keys
* @param {!(Object.<string, any|null>|Array.<any|null>)} inputs
* @returns {Object.<string, any|null>}
* @access public
* @static
*/
Kanvas.prototype.to_dictionary_values = (keys, inputs) => (
AnP.prototype.is_array(inputs) ? AnP.prototype.get_dictionary_from_array(keys, inputs) :
AnP.prototype.is_object(inputs) ? inputs || {} :
{});
/** @type {number} */
Kanvas.prototype.UNLOADED = 1 << 0;
/** @type {number} */
Kanvas.prototype.LOADING = 1 << 1;
/** @type {number} */
Kanvas.prototype.LOADED = 1 << 2;
/** @type {number} */
Kanvas.prototype.ERROR = 1 << 3;
/** @type {number} */
Kanvas.prototype.UNBUILT = 1 < 4;
/**
* @constructor
* @param {Object.<string, any|null>} inputs
* @returns {void}
* @access public
* @static
*/
Kanvas.prototype.ObjectBase = function(inputs){
/** @type {Object} */
this.type = Kanvas.prototype.ObjectBase;
/** @type {string} */
this.type_name = "ObjectBase";
/** @type {boolean} */
this.full = AnP.prototype.get_value("full", inputs, false);
/** @type {boolean} */
this.percentaje = AnP.prototype.get_value("percentaje", inputs, false);
/** @type {number|null} */
this.rotation = AnP.prototype.get_value("rotate", inputs, null);
/** @type {string|null} */
this.background = AnP.prototype.get_value(["background", "color"], inputs, null);
/** @type {number|null} */
this.alpha = AnP.prototype.get_value("alpha", inputs, null);
/** @type {number} */
this.state = Kanvas.prototype.UNBUILT;
/** @type {Array.<Array.<any>|Object.<string, any|null>|Object>|null} */
this.childs = AnP.prototype.get_value("childs", inputs, null);
/** @type {number} */
this.x = AnP.prototype.get_value("x", inputs, 0);
/** @type {number} */
this.y = AnP.prototype.get_value("y", inputs, 0);
/** @type {boolean} */
this.print = AnP.prototype.get_value("print", inputs, false);
/**
* @param {number} degrees
* @returns {void}
* @access public
*/
this.rotate = degrees => this.rotation = (this.rotation + degrees) % 360;
/**
* @returns {void}
* @access public
*/
this.draw = () => {};
};

View File

@ -0,0 +1,747 @@
Kanvas = function(settings){
const self = this,
default_settings = {
nulls : false,
default_value : null,
position : ".kanvas",
preload_timeout : 2000,
frames_per_second : 60,
quality : 1,
quality_x : 1,
quality_y : 1,
cells : 40,
swap_and_drop_timer : 5000,
font_size : 1,
font_family : "Arial",
settings_overwrite : false,
autostart : true,
autobuild : true,
font_minimum_size : 12,
events_cache_timer : 100
},
custom = {},
cache = {},
frames_times = [],
id_length = 11,
id_alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
ids = [],
threads = [],
number_of_cells = {x : 0, y : 0},
events_cache = [];
let thread = null,
frames_per_second = null,
canvas, context,
last_frame_time = 0, frames_times_summatory = 0,
swap_and_drop_timer,
cache_box,
default_font_size, default_font_family,
settings_overwrite,
built = false,
started = false,
font_minimum_size,
events_cache_timer;
this.map = [];
let cells = this.cells;
let cell_size = this.cell_size;
let quality = this.quality;
let quality_x = this.quality_x;
let quality_y = this.quality_y;
this.cells_x = 0;
this.cells_y = 0;
this.delta_time = 0;
let item_self = this.item_self;
let hash_self = this.hash_self;
let object_name = this.object_name;
this.Event = function(){
const self = this,
events = [],
properties = [];
const construct = () => {
events_cache.push(autoclean);
};
this.execute = (callback, ...arguments) => events.forEach((event, i) => (
event &&
(typeof callback == "function" ? callback(properties[i]) : true) &&
event(...arguments)
));
this.add = (callback, own_properties) => {
let i = 0;
const l = events.length;
for(; i < l; i ++)
if(!events[i])
break;
events[i] = callback;
properties[i] = own_properties;
return i;
};
this.remove = i => events[i] = null;
const autoclean = () => {
const date = Date.now();
properties.forEach((own_properties, i) => {
if(own_properties && own_properties.last_used && date - own_properties.last_used > events_cache_timer){
events[i] = null;
properties[i] = null;
};
});
};
this.update = (i, date) => events[i] && (properties[i].last_used = date);
construct();
};
this.on_screen_change = new this.Event();
this.on_ready = new this.Event();
this.on_click = new this.Event();
this.on_click_down = new this.Event();
this.on_click_up = new this.Event();
this.on_key_down = new this.Event();
this.on_key_up = new this.Event();
const construct = () => {
settings = (
settings instanceof Array ? settings :
typeof settings == "object" ? [settings] :
[]).filter(inputs => typeof inputs == "object" && !(inputs instanceof Array));
self.settings("autostart") && self.start();
};
this.start = callback => {
const end = status => typeof callback == "function" && callback(status);
if(started){
end(false);
return false;
};
started = true;
settings_overwrite = self.settings(["settings_overwrite", "overwrite"]);
frames_per_second = self.settings(["frames_per_second", "fps"]);
events_cache_timer = self.settings("events_cache_timer");
object_name = self.object_name = self.settings("object_name");
thread = setInterval(execute, 1000 / frames_per_second);
if(self.settings("autobuild"))
self.build(callback);
else
end(true);
return true;
};
this.build = callback => {
const position = self.settings("position"),
end = status => typeof callback == "function" && callback(status);
if(built){
end(false);
return false;
};
built = true;
if(position){
if(position.tagName || position.nodeName){
end_build(position);
end(true);
return;
};
if(typeof position != "string"){
console.error("position_not_string");
end(false);
return;
};
if(!position.trim()){
console.error("position_selector_empty");
end(false);
return;
};
let html_object;
try{
if(html_object = document.querySelector(position)){
end_build(html_object);
end(true);
return;
};
}catch(exception){
console.error(exception);
console.error("position_bad_selector");
end(false);
return;
};
const date = Date.now(),
timeout = self.settings("preload_timeout");
let interval = setInterval(() => {
if(html_object = document.querySelector(position)){
clearInterval(interval);
end_build(html_object);
end(true);
}else if(Date.now() - date > timeout){
clearInterval(interval);
console.error("position_timeout");
end(false);
};
}, frames_per_second);
}else{
console.error("no_position");
end(false);
};
return true;
};
const end_build = position => {
quality = self.quality = self.settings("quality");
quality_x = self.quality_x = self.settings("quality_x");
quality_y = self.quality_y = self.settings("quality_y");
cells = self.cells = self.settings("cells");
default_font_size = self.settings("font_size");
default_font_family = self.settings("font_family");
cache.quality = 0;
cache.quality_x = 0;
cache.quality_y = 0;
cache.screen = {x : 0, y : 0};
cache.origin = {x : 0, y : 0};
item_self = self.item_self = (position || document.querySelector("body")).appendChild(document.createElement("div"));
cache_box = item_self.appendChild(document.createElement("div"));
canvas = item_self.appendChild(document.createElement("canvas"));
hash_self = self.hash_self = self.settings(["id", "hash"]) || self.create_id();
item_self.setAttribute("id", hash_self);
item_self.setAttribute("class", ["kanvas", hash_self].concat((self.settings("class") || "").split(/\s+/)).filter((key, i, array) => array.indexOf(key) == i).join(" "));
item_self.setAttribute("data-hash", hash_self);
item_self.setAttribute("data-cells", cells);
item_self.setAttribute("data-minimum-font-size", font_minimum_size = self.settings("font_minimum_size"));
cache_box.setAttribute("class", "kanvas-cache-box");
cache_box.setAttribute("style", `
position : absolute;
top : 0%;
left : 0%;
width : 100%;
height : 100%;
visibility : hidden;
z-index : 10;
opacity : 0;
`.replace(/[\r\n\s]+/g, ""));
canvas.setAttribute("class", "kanvas-ui");
canvas.setAttribute("style", `
position : absolute;
top : 0%;
left : 0%;
width : 100%;
height : 100%;
z-index : 20;
`.replace(/[\r\n\s]+/g, ""));
canvas.onclick = event => on_click(canvas, event, "click");
canvas.onmousedown = event => on_click(canvas, event, "down");
canvas.onmouseup = event => on_click(canvas, event, "up");
canvas.onkeydown = event => on_key(canvas, event, "down");
canvas.onkeyup = event => on_key(canvas, event, "up");
context = canvas.getContext("2d");
context.id = self.create_id();
swap_and_drop_timer = self.settings("swap_and_drop_timer");
self.on_ready.execute();
};
this.nulls = nulls => typeof nulls == "boolean" ? nulls : self.settings("nulls", null, false, false);
this.default_value = (_default, nulls) => _default !== undefined && (self.nulls(nulls) || _default !== null) ? _default : self.settings("default_value", null, null, true);
this.settings = (names, inputs, _default, nulls) => {
const l = (names = (
names instanceof Array ? names :
typeof names == "string" ? [names] :
[]
).filter((name, i, array) => name && typeof name == "string" && array.indexOf(name) == i)).length;
if(l){
const m = (inputs = (
inputs instanceof Array ? inputs :
typeof inputs == "object" ? [inputs] :
[]).concat(settings, custom, [default_settings])).length;
nulls = self.nulls(nulls);
for(let j = 0; j < m; j ++)
if(inputs[j] && typeof inputs[j] == "object" && !(inputs[j] instanceof Array))
for(let i = 0; i < l; i ++)
if(inputs[j][names[i]] !== undefined && (nulls || inputs[j][names[i]] !== null))
return inputs[j][names[i]];
};
return self.default_value(_default, nulls);
};
this.settings_add = (inputs, overwrite) => {
if(!inputs)
return;
if(typeof inputs == "string"){
try{
inputs = JSON.parse(inputs);
}catch(exception){};
};
if(typeof inputs == "object"){
if(inputs instanceof Array)
inputs.forEach(inputs, overwrite);
else{
typeof overwrite != "boolean" && (overwrite = settings_overwrite);
for(const key in inputs)
if(overwrite || custom[key] === undefined)
custom[key] = inputs[key];
};
};
};
this.create_id = () => {
let id;
const l = id_alphabet.length;
do{
id = "";
while((id += id_alphabet[l * Math.random() >> 0]).length < id_length);
}while(
ids.includes(id) ||
!/^[a-z]/i.test(id) ||
document.querySelector("." + id + ",#" + id + ",[name=" + id + "]")
);
ids.push(id);
return id;
};
const execute = () => {
const date = Date.now();
let screen_changed = false;
if(item_self && (cache.screen.x != item_self.offsetWidth || cache.screen.y != item_self.offsetHeight)){
screen_changed = true;
cache.screen.x = item_self.offsetWidth;
cache.screen.y = item_self.offsetHeight;
const font_size = cache.screen[cache.screen.x < cache.screen.y ? "x" : "y"] / cells;
item_self.style.fontSize = (font_size < font_minimum_size ? font_minimum_size : font_size) + "px";
};
if(canvas){
if(last_frame_time){
const frame_time = date - last_frame_time;
frames_times.push(frame_time);
frames_times_summatory += frame_time;
self.delta_time = frame_time / 1000;
while(frames_times.length > frames_per_second)
frames_times_summatory -= frames_times.shift();
};
last_frame_time = date;
if(screen_changed || cache.quality != quality){
const width = cache.screen.x * quality,
height = cache.screen.y * quality;
cache.quality = quality;
canvas.setAttribute("width", width);
canvas.setAttribute("height", height);
cache.origin.x = width / 2;
cache.origin.y = height / 2;
cell_size = self.cell_size = (width > height ? height : width) / cells;
number_of_cells.x = width / cell_size;
number_of_cells.y = height / cell_size;
this.cells_x = number_of_cells.x / 2;
this.cells_y = number_of_cells.y / 2;
for(const key in cache)
if(cache[key] && cache[key].data)
cache[key].data = null;
self.on_screen_change.execute();
};
};
threads.forEach(thread => thread && thread());
if(canvas){
context.beginPath();
context.clearRect(0, 0, cache.screen.x * quality, cache.screen.y * quality);
context.translate(cache.origin.x, cache.origin.y);
draw(context, self.map, 0, 0);
context.translate(-cache.origin.x, -cache.origin.y);
for(const key in cache)
if(cache[key] && cache[key].last_used && date - cache[key].last_used > swap_and_drop_timer)
delete cache[key];
};
events_cache.forEach(autoclean => autoclean());
};
this.set_quality = new_quality => quality = self.quality = new_quality;
this.set_quality_x = new_quality => quality_x = self.quality_x = new_quality;
this.set_quality_y = new_quality => quality_y = self.quality_y = new_quality;
const _x = x => x * cell_size;
const _y = y => y * cell_size;
const size = size => size * cell_size;
const set_cache = (context, status) => {
!status && cache[context.id] && cache[context.id].ok && (cache[context.id].ok = false);
return status;
};
const set_border = (context, inputs) => {
const has_border = !!(inputs.border_color || !isNaN(inputs.border_width));
inputs.border_color && (context.strokeStyle = inputs.border_color);
!isNaN(inputs.border_width) && (context.lineWidth = size(inputs.border_width));
return has_border;
};
const set_background = (context, inputs) => {
const has_background = !!(inputs.background || (!inputs.border_color && isNaN(inputs.border_width)));
if(inputs.background){
if(inputs.background instanceof Array){
const v = inputs.background,
is_linear = v.length == 5,
gradient = (
is_linear ? context.createLinearGradient(_x(v[0]), _y(v[1]), _x(v[2]), _y(v[3])) :
context.createRadialGradient(_x(v[0]), _y(v[1]), _x(v[2]), _y(v[3]), size(v[4]), size(v[5]))
);
inputs.background[is_linear ? 4 : 6].forEach(color => gradient.addColorStop(color[0], color[1]));
context.fillStyle = gradient;
}else
context.fillStyle = inputs.background;
};
return has_background;
};
const set_shadow = (context, inputs, shape_callback) => {
const shadows = inputs.shadow || inputs.shadows;
(shadows && shadows.length ? shadows[0] instanceof Array ? shadows : [shadows] : []).forEach(shadow => {
[context.shadowOffsetX, context.shadowOffsetY, context.shadowBlur, context.shadowColor] = shadow;
context.shadowOffsetX = size(shadow[0]);
context.shadowOffsetY = size(shadow[1]);
context.shadowBlur = size(shadow[2]);
context.shadowColor = size(shadow[3]);
shape_callback();
});
};
const shapes = {
rectangle : (context, inputs) => {
const x = _x(inputs.x),
y = _y(inputs.y),
width = size(inputs.width),
height = size(inputs.height),
has_border = set_border(context, inputs),
has_background = set_background(context, inputs);
set_shadow(context, inputs, () => context.rect(x, y, width, height));
has_background && context.fillRect(x, y, width, height);
has_border && context.strokeRect(x, y, width, height);
return set_cache(context, true);
},
image : (context, inputs) => {
const url = inputs.url;
if(url){
const cached = cache[url];
if(!cached){
(cache[url] = {
image : new Image(),
loaded : false,
last_used : Date.now()
}).image.src = url;
cache[url].image.crossOrigin = "anonymous";
cache[url].image.onload = () => cache[url].loaded = true;
return set_cache(context, false);
};
if(cached.loaded){
let width = inputs.width,
height = inputs.height;
const cut_x = inputs.cut_x || 0,
cut_y = inputs.cut_y || 0,
cut_width = inputs.cut_width || 0,
cut_height = inputs.cut_height || 0,
position_x = inputs.x || 0,
position_y = inputs.y || 0,
x = _x(position_x),
y = _y(position_y),
end_width = size(width),
end_height = size(height);
!width && (width = cache.quality * (cut_width || cache[url].image.width - cut_x) / cell_size);
!height && (height = cache.quality * (cut_height || cache[url].image.height - cut_y) / cell_size);
set_shadow(context, inputs, () => context.rect(x, y, end_width, end_height));
set_border(context, inputs);
context.drawImage(
cache[url].image,
cut_x, cut_y, cut_width || cache[url].image.width - cut_x, cut_height || cache[url].image.height - cut_y,
x, y, end_width, end_height
);
cache[url].last_used = Date.now();
return set_cache(context, true);
};
};
return set_cache(context, false);
},
cache : (context, inputs) => {
const width = inputs.width ? inputs.width * cell_size : canvas.getAttribute("width"),
height = inputs.height ? inputs.height * cell_size : canvas.getAttribute("height");
let status = false;
if(!cache[inputs.name]){
const subcanvas = cache_box.appendChild(document.createElement("canvas"));
cache[inputs.name] = {
canvas : subcanvas,
data : null
};
cache[inputs.name].context = subcanvas.getContext("2d");
cache[inputs.name].context.id = inputs.name;
subcanvas.setAttribute("data-id", cache[inputs.name].context.id);
cache[inputs.name].context.translate(inputs.x || 0, inputs.y || 0);
};
if(cache[inputs.name].data){
if(cache[inputs.name].image_loaded){
context.drawImage(cache[inputs.name].image, _x(inputs.x || 0), _y(inputs.y || 0), cache[inputs.name].image.width, cache[inputs.name].image.height);
status = true;
}else if(!cache[inputs.name].image){
cache[inputs.name].image = new Image();
cache[inputs.name].image.src = cache[inputs.name].data;
cache[inputs.name].image.onload = () => {
// cache[inputs.name].canvas.remove();
cache[inputs.name].image_loaded = true;
};
// cache[inputs.name].image.onerror = () => cache[inputs.name].canvas.remove();
};
}else{
cache[inputs.name].canvas.setAttribute("width", width);
cache[inputs.name].canvas.setAttribute("height", height);
cache[inputs.name].context.beginPath();
cache[inputs.name].context.clearRect(0, 0, width, height);
cache[inputs.name].context.translate(width / 2, height / 2);
cache[inputs.name].image = null;
cache[inputs.name].image_loaded = false;
cache[inputs.name].ok = true;
draw(cache[inputs.name].context, inputs.childs, 0, 0);
cache[inputs.name].context.closePath();
cache[inputs.name].ok &&
(cache[inputs.name].data = cache[inputs.name].canvas.toDataURL("image/png", 1.0));
};
cache[inputs.name].last_used = Date.now();
return set_cache(context, status);
},
text : (context, inputs) => {
const x = _x(inputs.x),
y = _y(inputs.y),
has_border = set_border(context, inputs),
has_background = set_background(context, inputs);
inputs.align && (context.textAlign = inputs.align);
inputs.baseline && (context.textBaseline = inputs.baseline);
!isNaN(inputs.border_width) && (context.lineWidth = size(inputs.border_width));
context.font = (inputs.style ? inputs.style + " " : "") + size(inputs.size || default_font_size) + "px " + (inputs.family || default_font_family);
set_shadow(context, inputs, () => context.fillText(inputs.text, x, y));
has_background && context.fillText(inputs.text, x, y);
has_border && context.strokeText(inputs.text, x, y);
return true;
}
};
this.string_variables = (string, variables) => string.replace(/\{([^\{\}]+)\}/g, (...arguments) => variables[arguments[1]] !== undefined ? variables[arguments[1]] : arguments[0]);
const draw = (context, level, x, y) => level.forEach(values => {
if(values && (shapes[values.type] || ["block"].includes(values.type))){
const sub_x = _x(x + (values.margin_x || 0)),
sub_y = _y(y + (values.margin_y || 0)),
date = Date.now();
context.save();
context.translate(sub_x, sub_y);
const transform = context.getTransform();
values.rotate && context.rotate(2 * Math.PI * values.rotate / 360);
!isNaN(values.alpha) && (context.globalAlpha = values.alpha);
if(values.on_click){
values.context_x = transform.e / quality;
values.context_y = transform.f / quality;
if(!values.last_used || date - values.last_used > events_cache_timer)
values.i = self.on_click.add(eval(self.string_variables(values.on_click, {object_name : object_name})), values);
else
self.on_click.update(values.i, date);
values.last_used = date;
};
values.type != "block" && shapes[values.type](context, values);
values.type != "cache" && values.childs && draw(context, values.childs, values.x, values.y);
context.translate(-sub_x, -sub_y);
context.restore();
};
});
this.get_real_fps = this.get_real_frames_per_second = () => frames_times_summatory ? 1000 / (frames_times_summatory / frames_times.length) : 0;
this.threads_add = callback => {
let i = 0;
const l = threads.length;
for(; i < l; i ++)
if(!threads[i])
break;
threads[i] = callback;
return i;
};
this.threads_remove = i => threads[i] = null;
this.get_cells_x = () => number_of_cells.x;
this.get_cells_y = () => number_of_cells.y;
this.extends = object => {
for(const key in self)
if(object[key] === undefined)
object[key] = self[key];
};
const on_click = (canvas, event, action) => {
switch(action){
case "click":
self.on_click.execute(properties => (
event.clientX >= properties.context_x + (properties.x * cell_size) &&
event.clientY >= properties.context_y + (properties.y * cell_size) &&
event.clientX <= properties.context_x + ((properties.x + properties.width) * cell_size) &&
event.clientY <= properties.context_y + ((properties.y + properties.height) * cell_size)
), canvas, event);
break;
};
};
construct();
};

BIN
Public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

29
Public/index.w.md Normal file
View File

@ -0,0 +1,29 @@
```wmd-options
language = es
title_i18n = kanvas_title_documentation
title_text = Documentación - Kanvas
```
<!-- [[wmd]] -->
[[include doc/es/description.md]]
[[include doc/es/projects.w.md]]
[[include doc/es/design.w.md]]
[[include doc/es/integration.w.md]]
[[include doc/es/manual.w.md]]
[[include doc/es/faq.w.md]]
[[include doc/es/bugs.w.md]]
[[include doc/es/targets.w.md]]
[[include doc/es/opinions.w.md]]
[[include doc/es/donates.w.md]]
<!-- [[wmd]] -->

145
Public/scss/Kanvas.css Normal file
View File

@ -0,0 +1,145 @@
.kanvas {
position: relative;
top: 0em;
left: 0em;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #EFEFEF;
color: #222; }
.kanvas, .kanvas input, .kanvas button, .kanvas select {
font-family: "Roboto"; }
.kanvas pre, .kanvas textarea,
.kanvas .wmd-code-block,
.kanvas .wmd-code-block ol > li::marker,
.kanvas .wmd-code-doc > .description {
font-family: "Roboto Mono"; }
.kanvas [data-icon]::before {
font-family: "FA6FR"; }
.kanvas input, .kanvas button, .kanvas select, .kanvas textarea {
font-size: 1em; }
.kanvas [data-visible=false], .kanvas [data-hidden=true] {
display: none; }
.kanvas a[href] {
text-decoration: none;
word-break: break-word; }
.kanvas a[href], .kanvas [onclick], .kanvas [onmouseover], .kanvas [onmousedown], .kanvas button, .kanvas [type=button], .kanvas [type=reset], .kanvas [type=submit] {
cursor: pointer;
transition-duration: 1s; }
.kanvas a[href]:hover, .kanvas [onclick]:hover, .kanvas [onmouseover]:hover, .kanvas [onmousedown]:hover, .kanvas button:hover, .kanvas [type=button]:hover, .kanvas [type=reset]:hover, .kanvas [type=submit]:hover {
transition-duration: 0.2s; }
.kanvas a[href], .kanvas [onclick], .kanvas [onmouseover], .kanvas [onmousedown], .kanvas button, .kanvas [type=button], .kanvas [type=reset], .kanvas [type=submit] {
color: #2272D4;
transition-property: color; }
.kanvas a[href]:hover, .kanvas [onclick]:hover, .kanvas [onmouseover]:hover, .kanvas [onmousedown]:hover, .kanvas button:hover, .kanvas [type=button]:hover, .kanvas [type=reset]:hover, .kanvas [type=submit]:hover {
color: #D47222; }
.kanvas [onmouseover], .kanvas [onmousedown] {
color: #224a7b;
transition-property: color; }
.kanvas [onmouseover]:hover, .kanvas [onmousedown]:hover {
color: #7b4a22; }
.kanvas a[href], .kanvas [onclick] {
transition-property: color; }
.kanvas button, .kanvas [type=button], .kanvas [type=reset], .kanvas [type=submit] {
border-color: 0.1em solid #2272D4;
box-shadow: 0em 0em 0.4em #2272D4;
transition-property: color,border-color,box-shadow; }
.kanvas button:hover, .kanvas [type=button]:hover, .kanvas [type=reset]:hover, .kanvas [type=submit]:hover {
border-color: 0.1em solid #D47222;
box-shadow: 0em 0em 0.4em #D47222; }
.kanvas .wmd-dictionary-item {
color: #224a7b; }
.kanvas .wmd-dictionary-item:hover {
color: #7b4a22; }
.kanvas h2 {
font-size: 2.6em; }
.kanvas h3 {
font-size: 2.2em; }
.kanvas h4 {
font-size: 1.8em; }
.kanvas h5 {
font-size: 1.4em; }
.kanvas h6 {
font-size: 1em; }
.kanvas ul, .kanvas ol {
padding: 0em 2em; }
.kanvas header, .kanvas main, .kanvas footer {
position: absolute;
left: 0em;
width: 100%; }
.kanvas header, .kanvas footer {
overflow: hidden;
display: flex;
flex-direction: row;
box-shadow: 0em 0em 0.125em #EFEFEF, 0em 0em 0.25em #EFEFEF, 0em 0em 0.5em #EFEFEF, 0em 0em 1em #EFEFEF, 0em 0em 2em #EFEFEF; }
.kanvas header > *, .kanvas footer > * {
flex: auto;
align-self: center; }
.kanvas header {
top: 0em;
height: 4em;
z-index: 20; }
.kanvas header h1 {
margin: .2em 1em;
padding: 0em;
font-size: 1em;
text-wrap: nowrap; }
.kanvas header h1 .image {
height: 3.6em; }
.kanvas header h1 img {
width: auto;
height: 3.6em; }
.kanvas header h1 img + span {
display: none; }
.kanvas header h1 span + span {
font-size: 3.4em;
height: 0.9444444444em; }
.kanvas header h1 a > span {
display: inline-block;
vertical-align: top; }
.kanvas main {
top: 4em;
bottom: 2.5em;
padding: 1% 2%;
z-index: 10;
overflow: auto;
box-sizing: border-box; }
.kanvas footer {
bottom: 0em;
height: 2.5em;
z-index: 30; }
.kanvas .main-menu {
width: 25em;
text-align: center; }
.kanvas .main-menu ul {
list-style-type: none;
margin: 0em;
padding: 0em; }
.kanvas .main-menu li {
display: inline-block;
margin: 0em .6em; }
.kanvas .license {
display: block;
position: absolute;
bottom: 0em;
width: 100%;
padding: 0em .2em;
text-align: center;
font-weight: 900;
font-size: .85em;
box-sizing: border-box; }
.kanvas .license a {
display: flex;
flex-direction: row; }
.kanvas .license a span {
width: 100%; }
.kanvas .license a > * {
vertical-align: middle;
flex: auto;
align-self: center; }
.kanvas .license img {
width: auto;
height: 2.5em;
margin: .2em 0em; }
/*# sourceMappingURL=Kanvas.css.map */

View File

@ -0,0 +1,7 @@
{
"version": 3,
"mappings": "AAIA,OAAO;ECwBH,QAAQ,EAAG,QAAQ;EACnB,GAAG,EAAG,GAAG;EACT,IAAI,EAAG,GAAG;EACV,KAAK,EAAG,IAAI;EACZ,MAAM,EAAG,IAAI;EACb,QAAQ,EAAG,MAAM;EA4Hb,gBAAgB,ECzJV,OAAO;ED0Jb,KAAK,EC3JC,IAAI;EDgCd,sDAAqB;IAAC,WAAW,ECtBtB,QAAQ;EDuBnB;;;sCAG0B;IAAC,WAAW,ECxB7B,aAAa;EDyBtB,2BAAmB;IAAC,WAAW,ECvBtB,OAAO;EDwBhB,+DAA4B;IAAC,SAAS,EAAG,GAAG;EAE5C,wDAAuC;IAAC,OAAO,EAAG,IAAI;EAEtD,eAAO;IACH,eAAe,EAAG,IAAI;IACtB,UAAU,EAAG,UAAU;EAE3B,oKAA6F;IACzF,MAAM,EAAG,OAAO;IAChB,mBAAmB,ECpBT,EAAE;IDqBZ,oNAAO;MAAC,mBAAmB,ECtBlB,IAAG;EDwBhB,oKAA6F;IACzF,KAAK,ECtDI,OAAO;IDuDhB,mBAAmB,EAAG,KAAK;IAC3B,oNAAO;MAAC,KAAK,ECvDF,OAAO;EDyDtB,4CAA2B;IACvB,KAAK,EAAG,OAAqC;IAC7C,mBAAmB,EAAG,KAAK;IAC3B,wDAAO;MAAC,KAAK,EAAG,OAAuC;EAO3D,kCAAiB;IAAC,mBAAmB,EAAG,KAAK;EAC7C,kFAA+C;IAC3C,YAAY,EAAG,mBAAyB;IACxC,UAAU,EAAG,qBAA2B;IACxC,mBAAmB,EAAG,6BAA6B;IACnD,0GAAO;MACH,YAAY,EAAG,mBAA2B;MAC1C,UAAU,EAAG,qBAA6B;EAIlD,4BAAoB;IAChB,KAAK,EAAG,OAAqC;IAC7C,kCAAO;MAAC,KAAK,EAAG,OAAuC;EAIvD,UAAM;IAAC,SAAS,EAAG,KAAmB;EAAtC,UAAM;IAAC,SAAS,EAAG,KAAmB;EAAtC,UAAM;IAAC,SAAS,EAAG,KAAmB;EAAtC,UAAM;IAAC,SAAS,EAAG,KAAmB;EAAtC,UAAM;IAAC,SAAS,EAAG,GAAmB;EAG1C,sBAAK;IACD,OAAO,EAAG,OAAO;EAGrB,4CAAkB;IACd,QAAQ,EAAG,QAAQ;IACnB,IAAI,EAAG,GAAG;IACV,KAAK,EAAG,IAAI;EAEhB,8BAAa;IACT,QAAQ,EAAG,MAAM;IACjB,OAAO,EAAG,IAAI;IACd,cAAc,EAAG,GAAG;IAxFxB,UAAU,EACN,gHAIuB;IAqFvB,sCAAG;MACC,IAAI,EAAG,IAAI;MACX,UAAU,EAAG,MAAM;EAG3B,cAAM;IACF,GAAG,EAAG,GAAG;IACT,MAAM,EC1FG,GAAG;ID2FZ,OAAO,EAAG,EAAE;IACZ,iBAAE;MACE,MAAM,EAAG,QAAQ;MACjB,OAAO,EAAG,GAAG;MACb,SAAS,EAAG,GAAG;MACf,SAAS,EAAG,MAAM;MAClB,wBAAM;QAAC,MAAM,EAAG,KAAyB;MACzC,qBAAG;QACC,KAAK,EAAG,IAAI;QACZ,MAAM,EAAG,KAAyB;QAClC,4BAAM;UAAC,OAAO,EAAG,IAAI;MAEzB,6BAAS;QACL,SAAS,EAAG,KAAyB;QACrC,MAAM,EAAG,cAAiE;MAE9E,0BAAM;QACF,OAAO,EAAG,YAAY;QACtB,cAAc,EAAG,GAAG;EAIhC,YAAI;IACA,GAAG,EClHM,GAAG;IDmHZ,MAAM,EClHG,KAAK;IDmHd,OAAO,EAAG,KAAK;IACf,OAAO,EAAG,EAAE;IACZ,QAAQ,EAAG,IAAI;IACf,UAAU,EAAG,UAAU;EAE3B,cAAM;IACF,MAAM,EAAG,GAAG;IACZ,MAAM,EC1HG,KAAK;ID2Hd,OAAO,EAAG,EAAE;EAiBhB,kBAAU;IACN,KAAK,EAAG,IAAI;IACZ,UAAU,EAAG,MAAM;IACnB,qBAAE;MACE,eAAe,EAAG,IAAI;MACtB,MAAM,EAAG,GAAG;MACZ,OAAO,EAAG,GAAG;IAEjB,qBAAE;MACE,OAAO,EAAG,YAAY;MACtB,MAAM,EAAG,QAAQ;EAIzB,gBAAQ;IACJ,OAAO,EAAG,KAAK;IACf,QAAQ,EAAG,QAAQ;IACnB,MAAM,EAAG,GAAG;IACZ,KAAK,EAAG,IAAI;IACZ,OAAO,EAAG,QAAQ;IAClB,UAAU,EAAG,MAAM;IACnB,WAAW,EAAG,GAAG;IACjB,SAAS,EAAG,KAAK;IACjB,UAAU,EAAG,UAAU;IACvB,kBAAC;MACG,OAAO,EAAG,IAAI;MACd,cAAc,EAAG,GAAG;MACpB,uBAAI;QAAC,KAAK,EAAG,IAAI;MACjB,sBAAG;QACC,cAAc,EAAG,MAAM;QACvB,IAAI,EAAG,IAAI;QACX,UAAU,EAAG,MAAM;IAG3B,oBAAG;MACC,KAAK,EAAG,IAAI;MACZ,MAAM,EAAG,KAAK;MACd,MAAM,EAAG,QAAQ",
"sources": ["Kanvas.scss","../../../AnP/Public/scss/AnP.common.scss","../../../AnP/Public/scss/AnP.settings.scss"],
"names": [],
"file": "Kanvas.css"
}

7
Public/scss/Kanvas.scss Normal file
View File

@ -0,0 +1,7 @@
@import
"../../../AnP/Public/scss/AnP.settings.scss",
"../../../AnP/Public/scss/AnP.common.scss";
.kanvas{
@include main_web;
}

87
Public/test/index.anp.html Executable file
View File

@ -0,0 +1,87 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Kanvas - Test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta charset="utf-8" />
<style data-type="text/css" data-language="CSS3" data-rel="stylesheet" charset="utf-8">
html,body{
height : 100%;
margin : 0px;
}
body{overflow : hidden;}
.kanvas{
position : absolute;
top : 0px;
left : 0px;
width : 100%;
height : 100%;
}
.fps{
position : absolute;
top : 0px;
right : 0px;
margin : 10px;
font-weight : 900;
}
</style>
<script data-type="text/javascript" data-language="ECMAScript 2015" src="/ecma/version/20230707/Kanvas.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script type="module" data-type="text/javascript" data-language="ECMAScript 2015" charset="utf-8">
kanvas = new Kanvas({
position : "body",
quality : 1,
frames_per_second : 60
});
kanvas.map.push(
{type : "cache", name : "main_test", x : -20, y : -20, width : 40, height : 40, childs : [
{type : "image", url : "/data/test/hqdefault.jpg", x : -10, y : -10, width : 20, height : 20, cut_x : 100, cut_width : 100, rotate : -15},
{type : "rectangle", x : -2, y : -1, width : 4, height : 2, background : [0, 0, 4, 0, [
[0, "#F00"],
[1, "#00F"]
]], rotate : 45, border_color : "#00F", childs : [
{type : "rectangle", x : -.5, y : -.5, width : 1, height : 1, background : "#F88", rotate : -35, margin_x : 2, margin_y : 1}
]},
{type : "cache", name : "test_cache", childs : []}
]},
{type : "text", background : "#080", border_color : "#F00", text : "Hola, esto es una prueba xD", x : 20, y : 20, size : 5, baseline : "bottom", align : "right", shadow : [
[0, 0, 5, "#000"],
[1, 1, 2, "#800"]
]}
);
with(kanvas.map[1]){
align = "left";
baseline = "top";
};
kanvas.on_ready.add(() => {
kanvas.threads_add(() => {
kanvas.map[1].text = kanvas.get_real_fps().toFixed(2);
});
kanvas.on_screen_change.add(() => {
console.log("PASA");
with(kanvas.map[1]){
x = -kanvas.cells_x;
y = -kanvas.cells_y;
};
});
});
</script>
</head>
<body></body>
</html>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<html lang="es" dir="ltr">
<head>
<title>Kanvas - Test</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
@ -15,67 +15,210 @@
body{overflow : hidden;}
.kanvas{
position : absolute;
display : inline-block;
position : relative;
top : 0px;
left : 0px;
width : 100%;
height : 100%;
}
.fps{
.kanvas>.cache,
.kanvas>.cache>canvas,
.kanvas>canvas{
position : absolute;
top : 0px;
right : 0px;
margin : 10px;
font-weight : 900;
left : 0px;
}
.kanvas>.cache,
.kanvas>canvas{
width : 100%;
height : 100%;
}
.kanvas>.cache{
display : block;
/* visibility : hidden; */
z-index : 10;
}
.kanvas>.cache>canvas{
background-color: #FEE;
}
.kanvas>canvas{
z-index : 20;
/* visibility : hidden; */
}
</style>
<script data-type="text/javascript" data-language="ECMAScript 2015" src="/ecma/version/20230707/Kanvas.ecma.js" data-crossorigin="anonymous" charset="utf-8"></script>
<script type="module" data-type="text/javascript" data-language="ECMAScript 2015" charset="utf-8">
<script data-type="text/javascript" data-language="ECMAScript 2015" charset="utf-8">
import {Kanvas} from "/ecma/Kanvas.ecma.js";
kanvas = new Kanvas({
/** @type {number} */
const v = 5;
/** @type {Kanvas} */
const kanvas = new Kanvas({
position : "body",
quality : 1,
fps : 60
});
frames_per_second : 0,
// threads_mode : Kanvas.THREADS_MODE_TIMEOUT,
// context : "webgl",
on_ready : () => {
kanvas.map.push(
{type : "cache", name : "main_test", x : -20, y : -20, width : 40, height : 40, childs : [
{type : "image", url : "/data/test/hqdefault.jpg", x : -10, y : -10, width : 20, height : 20, cut_x : 100, cut_width : 100, rotate : -15},
{type : "rectangle", x : -2, y : -1, width : 4, height : 2, background : [0, 0, 4, 0, [
[0, "#F00"],
[1, "#00F"]
]], rotate : 45, border_color : "#00F", childs : [
{type : "rectangle", x : -.5, y : -.5, width : 1, height : 1, background : "#F88", rotate : -35, margin_x : 2, margin_y : 1}
]},
{type : "cache", name : "test_cache", childs : []}
]},
{type : "text", background : "#080", border_color : "#F00", text : "Hola, esto es una prueba xD", x : 20, y : 20, size : 5, baseline : "bottom", align : "right", shadow : [
[0, 0, 5, "#000"],
[1, 1, 2, "#800"]
]}
);
[
{
type : "Rectangle",
x : -19,
y : -19,
width : 4,
height : 4,
background : "#F00",
on_full_done : (...parameters) => console.log(parameters),
// shadows : [
// [.5, .5, 1, "#F00"],
// [-.5, -.5, 1, "#00F"],
// [0, 0, 1, "#0F0"]
// ],
childs : [
{
type : "Rectangle",
x : 3,
y : 3,
width : 2,
height : 2,
color : "#007",
on_click : (...parameters) => console.log(parameters)
}
],
on_click : (...parameters) => console.log(["PASA", parameters])
},
{
type : "Text",
y : -15,
text : "Hola",
size : 4,
weight : 900,
color : "#060",
rotate : 45,
alpha : .5,
on_mouse_move : () => console.log("PASA")
},
["Position", 0, 0, [
{
type : "Rectangle",
x : -19,
y : -10,
width : 4,
height : 4,
radius : [1, 2],
// use_modern_mode : false,
color : "#700"
},
{
type : "Rectangle",
x : -14,
y : -10,
width : 4,
height : 4,
radius : [1, 2],
use_modern_mode : false,
color : "#700"
}
]],
// ["Image", "https://cdn.k3y.pw/data/space_art_publish/red_giant.png", -10, -10, 20, 20],
{
type : "Image",
source : "https://cdn.k3y.pw/data/space_art_publish/red_giant.png",
x : -10,
y : -10,
width : 20,
height : 20,
// on_mouse_move : () => console.log("IMAGE")
},
{
type : "Text",
y : -20,
x : 20,
size : 2,
weight : 900,
color : "#000",
border_color : "#FFF",
border_size : .1,
text : "",
align : "right",
baseline : "top"
},
["Image", "https://cdn.k3y.pw/data/space_art_publish/cold_nebula.png", -20, -20, 40, 40],
{
type : "Position",
x : -25,
y : -20,
childs : [{
type : "Cache",
x : 10,
y : 0,
width : 10,
height : 10,
childs : [
["Rectangle", 3, 3, 2, 2, "#008"],
["Rectangle", 2, 5, 4, 4, "#700"]
],
on_load : (i, cache) => {
kanvas.thread_add(() => cache.rotation += kanvas.delta * v);
cache.childs[0].background = "#F00";
}
}]
},
// // ["Sprite", "https://upload.wikimedia.org/wikipedia/commons/e/e0/Baraja_espa%C3%B1ola_completa.png", -20, 20, {
// // cards : ["https://upload.wikimedia.org/wikipedia/commons/e/e0/Baraja_espa%C3%B1ola_completa.png", "pattern", 100, 200, 12, 4]
// // }],
{
type : "Sprite",
x : -20,
i : 47,
map : {
cards : [
// ["https://upload.wikimedia.org/wikipedia/commons/e/e0/Baraja_espa%C3%B1ola_completa.png", "pattern", 208, 319, 4, 12, 8, 12.5, 0, -12.5]
["https://upload.wikimedia.org/wikipedia/commons/e/e0/Baraja_espa%C3%B1ola_completa.png", "pattern", 208, 319, 4, 12, 8, 12.5, 0, 0]
]
},
group : "cards",
fps : 1,
on_click : (i, sprite) => {
sprite.rotation += 10;
console.log(sprite.i);
}
}
].forEach(item => {
kanvas.map.push(item);
});
with(kanvas.map[1]){
align = "left";
baseline = "top";
};
// setTimeout(() => {
// console.log(kanvas.map[0].childs[0]);
// }, 2000);
kanvas.on_ready.add(() => {
kanvas.thread_add(() => {
if(kanvas.map[0].status & Kanvas.LOADED){
kanvas.map[0].rotation += kanvas.delta * v;
kanvas.map[0].childs[0].status == Kanvas.LOADED && (kanvas.map[0].childs[0].rotation += kanvas.delta * v);
};
kanvas.map[3].status & Kanvas.LOADED && (kanvas.map[3].rotation += kanvas.delta * v);
kanvas.map[4].status & Kanvas.LOADED && (kanvas.map[4].text = kanvas.real_frames_per_second.toFixed(2) + " FPS");
kanvas.map[6].childs[0].status & Kanvas.LOADED && (kanvas.map[6].childs[0].rotation += kanvas.delta * v);
// kanvas.map[4].status & Kanvas.LOADED && (kanvas.map[4].text = kanvas.difference);
}, {
bucle : true
});
kanvas.threads_add(() => kanvas.map[1].text = kanvas.get_real_fps().toFixed(2));
// setInterval(() => {
// console.log([kanvas.difference, kanvas.delta]);
// kanvas.frames_per_second = kanvas.frames_per_second ? 0 : 60;
// }, 5000);
kanvas.on_screen_change.add(() => {
console.log("PASA");
with(kanvas.map[1]){
x = -kanvas.cells_x;
y = -kanvas.cells_y;
};
});
// kanvas.on_key_down.add((...parameters) => console.log(parameters));
// kanvas.on_mouse_move.add((...parameters) => console.log(parameters), 0, 0, 3);
}
});
</script>

51
Public/test/shadow.html Normal file
View File

@ -0,0 +1,51 @@
<canvas id="mainCanvas" width="800" height="600"></canvas>
<script>
const mainCanvas = document.getElementById("mainCanvas");
const mainCtx = mainCanvas.getContext("2d");
// Crear un canvas temporal para la forma base
function createBaseShapeCanvas(width, height, drawShapeCallback) {
const tempCanvas = document.createElement("canvas");
tempCanvas.width = width;
tempCanvas.height = height;
const tempCtx = tempCanvas.getContext("2d");
drawShapeCallback(tempCtx); // Dibujar la forma en el canvas temporal
return tempCanvas;
}
// Dibujar la forma base con diferentes configuraciones de sombra
function drawShapesWithShadows(baseCanvas) {
const shadows = [
{ shadowColor: "rgba(0, 0, 0, 0.5)", shadowBlur: 10, x: 50, y: 50 },
{ shadowColor: "rgba(255, 0, 0, 0.5)", shadowBlur: 20, x: 50, y: 50 },
{ shadowColor: "rgba(0, 0, 255, 0.7)", shadowBlur: 15, x: 50, y: 50 },
];
shadows.forEach(({ shadowColor, shadowBlur, x, y }, i) => {
mainCtx.save(); // Guardar estado actual del contexto principal
mainCtx.shadowColor = shadowColor;
mainCtx.shadowBlur = shadowBlur;
mainCtx.shadowOffsetX = i * 10 - 10; // Opcional: ajustar según el efecto deseado
mainCtx.shadowOffsetY = i * 10 - 10;
// Dibujar la forma base con la sombra configurada
mainCtx.drawImage(baseCanvas, x, y);
mainCtx.restore(); // Restaurar estado para evitar que las sombras se mezclen
});
}
// Crear la forma base
const baseShapeCanvas = createBaseShapeCanvas(100, 100, (ctx) => {
ctx.fillStyle = "green";
ctx.beginPath();
ctx.arc(50, 50, 50, 0, Math.PI * 2); // Un círculo
ctx.fill();
});
// Dibujar la forma base con diferentes sombras
drawShapesWithShadows(baseShapeCanvas);
</script>

20
Public/test/x.html Normal file
View File

@ -0,0 +1,20 @@
<canvas id="mainCanvas"></canvas>
<script>
function x(){
const body = document.querySelector("body"),
canvas = document.querySelector("canvas"),
context = canvas.getContext("2d");
canvas.setAttribute("width", body.offsetWidth);
canvas.setAttribute("height", body.offsetHeight);
context.clearRect(0, 0, body.offsetWidth, body.offsetHeight);
requestAnimationFrame(x);
};
requestAnimationFrame(x);
</script>

18
Public/test/y.html Normal file
View File

@ -0,0 +1,18 @@
<script>
// function cosa(){
// console.log("PASA");
// requestAnimationFrame(cosa);
// };
// requestAnimationFrame(cosa);
console.log("Primero");
setTimeout(() => {
console.log("Segundo (callback de setTimeout)");
}, 0);
console.log("Tercero");
</script>

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Abstracts.AnPMap import AnP
from Abstracts.Applications import ApplicationsAbstract
from typing import Any, Optional
from os.path import abspath as path_absolute
from os.path import dirname as directory_name
class Kanvas(ApplicationsAbstract):
def __init__(self, anp:AnP, inputs:Optional[dict[str, Any|None]|tuple|list] = None) -> None:
super().__init__(anp, "kanvas", anp.path.get_parent(path_absolute(directory_name(__file__))), {
**anp.get_dictionary(inputs),
"kanvas_default_settings_files" : "/JSON/Kanvas.py.settings.json",
"kanvas_controllers" : {},
"kanvas_resources" : ("logo", "charset", "link", "git")
})

3
Tools/sass.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
directory=`dirname $(readlink -f "$0")`
sass $directory/../Public/scss/Kanvas.scss ../Public/scss/Kanvas.css;

1
version Normal file
View File

@ -0,0 +1 @@
0.0.4.1