Стартовый пул
This commit is contained in:
481
bgrabitmap/test/testbgrafunc/COPYING.LGPL.txt
Normal file
481
bgrabitmap/test/testbgrafunc/COPYING.LGPL.txt
Normal file
@@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library 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 Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
24
bgrabitmap/test/testbgrafunc/COPYING.modifiedLGPL.txt
Normal file
24
bgrabitmap/test/testbgrafunc/COPYING.modifiedLGPL.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
This is the file COPYING.modifiedLGPL, it applies to all units of the
|
||||
BGRABitmap library.
|
||||
|
||||
These files are distributed under the Library GNU General Public License
|
||||
(see the file COPYING.LGPL) with the following modification:
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent modules,
|
||||
and to copy and distribute the resulting executable under terms of your choice,
|
||||
provided that you also meet, for each linked independent module, the terms
|
||||
and conditions of the license of that module. An independent module is a
|
||||
module which is not derived from or based on this library. If you modify this
|
||||
library, you may extend this exception to your version of the library, but
|
||||
you are not obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version.
|
||||
|
||||
|
||||
If you didn't receive a copy of the file COPYING.LGPL, contact:
|
||||
Free Software Foundation, Inc.,
|
||||
675 Mass Ave
|
||||
Cambridge, MA 02139
|
||||
USA
|
||||
|
BIN
bgrabitmap/test/testbgrafunc/img/diamondback.png
Normal file
BIN
bgrabitmap/test/testbgrafunc/img/diamondback.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 212 B |
BIN
bgrabitmap/test/testbgrafunc/img/pac_d1.bmp
Normal file
BIN
bgrabitmap/test/testbgrafunc/img/pac_d1.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
bgrabitmap/test/testbgrafunc/img/pac_d2.bmp
Normal file
BIN
bgrabitmap/test/testbgrafunc/img/pac_d2.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
bgrabitmap/test/testbgrafunc/img/pac_d3.bmp
Normal file
BIN
bgrabitmap/test/testbgrafunc/img/pac_d3.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
bgrabitmap/test/testbgrafunc/img/resampletest.png
Normal file
BIN
bgrabitmap/test/testbgrafunc/img/resampletest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
8
bgrabitmap/test/testbgrafunc/readme.txt
Normal file
8
bgrabitmap/test/testbgrafunc/readme.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
Test for BGRABitmap functions - v2.0
|
||||
|
||||
This code is under modified LGPL (see COPYING.modifiedLGPL.txt). This means that you can link this library inside your programs for any purpose. Only the included part of the code must remain LGPL.
|
||||
|
||||
If you make some improvements to this library, please notify here:
|
||||
http://www.lazarus.freepascal.org/index.php/topic,12037.0.html
|
||||
|
||||
Contact : circular at operamail.com
|
BIN
bgrabitmap/test/testbgrafunc/testbgrafunc.ico
Normal file
BIN
bgrabitmap/test/testbgrafunc/testbgrafunc.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
859
bgrabitmap/test/testbgrafunc/testbgrafunc.lpi
Normal file
859
bgrabitmap/test/testbgrafunc/testbgrafunc.lpi
Normal file
@@ -0,0 +1,859 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="testbgrafunc"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="bgrabitmappack"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="etpackage"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="123">
|
||||
<Unit0>
|
||||
<Filename Value="testbgrafunc.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos X="10" Y="14"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="umain.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="FMain"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="umain"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="97"/>
|
||||
<CursorPos X="39" Y="98"/>
|
||||
<UsageCount Value="200"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="utestpacrect.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="utest.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="utest1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CursorPos X="45" Y="2"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="utest2.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="utest3.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="utest4.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="utest5.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="16"/>
|
||||
<CursorPos Y="50"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="utest6.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="13"/>
|
||||
<CursorPos X="47" Y="37"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="utest7.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="53"/>
|
||||
<CursorPos X="44" Y="63"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="utest8.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="utest8"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="65"/>
|
||||
<CursorPos X="49" Y="81"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="utest9.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="50"/>
|
||||
<CursorPos Y="70"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="utestback.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CursorPos X="3" Y="13"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
<Filename Value="..\testbgrafuncold\umain.pas"/>
|
||||
<ComponentName Value="FMain"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<TopLine Value="7"/>
|
||||
<CursorPos Y="98"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit14>
|
||||
<Unit15>
|
||||
<Filename Value="utest10.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="19"/>
|
||||
<CursorPos X="55" Y="36"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit15>
|
||||
<Unit16>
|
||||
<Filename Value="..\bgrabitmap\bgrafilters.pas"/>
|
||||
<CursorPos X="61" Y="4"/>
|
||||
<UsageCount Value="29"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="utest11.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="59"/>
|
||||
<CursorPos X="32" Y="63"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit17>
|
||||
<Unit18>
|
||||
<Filename Value="utest14.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="18"/>
|
||||
<CursorPos X="6" Y="30"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit18>
|
||||
<Unit19>
|
||||
<Filename Value="utest15.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="72"/>
|
||||
<CursorPos X="90" Y="83"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit19>
|
||||
<Unit20>
|
||||
<Filename Value="utest16.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="60"/>
|
||||
<CursorPos X="94" Y="136"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit20>
|
||||
<Unit21>
|
||||
<Filename Value="D:\lazarus\fpc\2.2.4\source\rtl\objpas\sysutils\datih.inc"/>
|
||||
<TopLine Value="101"/>
|
||||
<CursorPos X="10" Y="119"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit21>
|
||||
<Unit22>
|
||||
<Filename Value="..\bgrabitmap\bgragradients.pas"/>
|
||||
<CursorPos X="78" Y="10"/>
|
||||
<UsageCount Value="45"/>
|
||||
</Unit22>
|
||||
<Unit23>
|
||||
<Filename Value="..\bgrabitmap\bgraanimatedgif.pas"/>
|
||||
<TopLine Value="110"/>
|
||||
<CursorPos X="32" Y="122"/>
|
||||
<UsageCount Value="28"/>
|
||||
</Unit23>
|
||||
<Unit24>
|
||||
<Filename Value="..\bgrabitmap\bgradefaultbitmap.pas"/>
|
||||
<UnitName Value="BGRADefaultBitmap"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="3997"/>
|
||||
<CursorPos X="42" Y="4002"/>
|
||||
<UsageCount Value="84"/>
|
||||
</Unit24>
|
||||
<Unit25>
|
||||
<Filename Value="..\bgrabitmap\bgrapolygon.pas"/>
|
||||
<TopLine Value="166"/>
|
||||
<CursorPos X="27" Y="177"/>
|
||||
<ExtraEditorCount Value="1"/>
|
||||
<ExtraEditor1>
|
||||
<TopLine Value="790"/>
|
||||
<CursorPos X="69" Y="800"/>
|
||||
</ExtraEditor1>
|
||||
<UsageCount Value="65"/>
|
||||
</Unit25>
|
||||
<Unit26>
|
||||
<Filename Value="..\bgrabitmap\bgrabitmaptypes.pas"/>
|
||||
<UnitName Value="BGRABitmapTypes"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="962"/>
|
||||
<CursorPos Y="990"/>
|
||||
<UsageCount Value="77"/>
|
||||
</Unit26>
|
||||
<Unit27>
|
||||
<Filename Value="..\bgrabitmap\bgrablend.pas"/>
|
||||
<UnitName Value="BGRABlend"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="385"/>
|
||||
<CursorPos Y="404"/>
|
||||
<UsageCount Value="71"/>
|
||||
</Unit27>
|
||||
<Unit28>
|
||||
<Filename Value="..\bgrabitmap\bgraresample.pas"/>
|
||||
<TopLine Value="1295"/>
|
||||
<CursorPos X="3" Y="1325"/>
|
||||
<UsageCount Value="56"/>
|
||||
</Unit28>
|
||||
<Unit29>
|
||||
<Filename Value="..\bgrabitmap\bgrapaintnet.pas"/>
|
||||
<TopLine Value="160"/>
|
||||
<CursorPos X="29" Y="167"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit29>
|
||||
<Unit30>
|
||||
<Filename Value="..\bgrabitmap\bgradnetdeserial.pas"/>
|
||||
<CursorPos X="25" Y="5"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit30>
|
||||
<Unit31>
|
||||
<Filename Value="utest17.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="76"/>
|
||||
<CursorPos X="36" Y="53"/>
|
||||
<UsageCount Value="200"/>
|
||||
</Unit31>
|
||||
<Unit32>
|
||||
<Filename Value="D:\lazarus\lcl\graphics.pp"/>
|
||||
<TopLine Value="43"/>
|
||||
<CursorPos X="42" Y="61"/>
|
||||
<UsageCount Value="26"/>
|
||||
</Unit32>
|
||||
<Unit33>
|
||||
<Filename Value="D:\lazarus\fpc\2.2.4\source\packages\fcl-image\src\fpcanvas.pp"/>
|
||||
<TopLine Value="105"/>
|
||||
<CursorPos X="65" Y="105"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit33>
|
||||
<Unit34>
|
||||
<Filename Value="..\bgrabitmap\bgrapen.pas"/>
|
||||
<CursorPos X="85" Y="3"/>
|
||||
<UsageCount Value="33"/>
|
||||
</Unit34>
|
||||
<Unit35>
|
||||
<Filename Value="D:\lazarus\fpc\2.2.4\source\packages\fcl-image\src\fpimage.pp"/>
|
||||
<TopLine Value="19"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit35>
|
||||
<Unit36>
|
||||
<Filename Value="D:\lazarus\lcl\graphtype.pp"/>
|
||||
<TopLine Value="77"/>
|
||||
<CursorPos X="3" Y="95"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit36>
|
||||
<Unit37>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\inc\objpash.inc"/>
|
||||
<TopLine Value="176"/>
|
||||
<CursorPos X="31" Y="192"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit37>
|
||||
<Unit38>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\inc\objpas.inc"/>
|
||||
<TopLine Value="782"/>
|
||||
<CursorPos Y="788"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit38>
|
||||
<Unit39>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpimage.pp"/>
|
||||
<TopLine Value="227"/>
|
||||
<CursorPos X="17" Y="245"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit39>
|
||||
<Unit40>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\objpas\classes\classesh.inc"/>
|
||||
<TopLine Value="15"/>
|
||||
<CursorPos X="18" Y="33"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit40>
|
||||
<Unit41>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\i386\i386.inc"/>
|
||||
<TopLine Value="1254"/>
|
||||
<CursorPos X="10" Y="1272"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit41>
|
||||
<Unit42>
|
||||
<Filename Value="..\bgrabitmap\bgrawinbitmap.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="102"/>
|
||||
<CursorPos Y="122"/>
|
||||
<UsageCount Value="17"/>
|
||||
</Unit42>
|
||||
<Unit43>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\win\wininc\struct.inc"/>
|
||||
<TopLine Value="215"/>
|
||||
<CursorPos X="6" Y="233"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit43>
|
||||
<Unit44>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\objpas\types.pp"/>
|
||||
<TopLine Value="80"/>
|
||||
<CursorPos X="3" Y="98"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit44>
|
||||
<Unit45>
|
||||
<Filename Value="..\bgrabitmap\bgrabitmap.pas"/>
|
||||
<TopLine Value="39"/>
|
||||
<CursorPos X="9" Y="44"/>
|
||||
<UsageCount Value="32"/>
|
||||
</Unit45>
|
||||
<Unit46>
|
||||
<Filename Value="..\bgrabitmap\bgracompressablebitmap.pas"/>
|
||||
<TopLine Value="13"/>
|
||||
<CursorPos X="107" Y="16"/>
|
||||
<UsageCount Value="24"/>
|
||||
</Unit46>
|
||||
<Unit47>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpreadpcx.pas"/>
|
||||
<TopLine Value="29"/>
|
||||
<CursorPos Y="46"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit47>
|
||||
<Unit48>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpwritepcx.pas"/>
|
||||
<TopLine Value="12"/>
|
||||
<CursorPos X="3" Y="30"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit48>
|
||||
<Unit49>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpreadxpm.pp"/>
|
||||
<TopLine Value="5"/>
|
||||
<CursorPos X="23" Y="33"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit49>
|
||||
<Unit50>
|
||||
<Filename Value="utest18.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="16"/>
|
||||
<CursorPos X="71" Y="114"/>
|
||||
<UsageCount Value="197"/>
|
||||
</Unit50>
|
||||
<Unit51>
|
||||
<Filename Value="..\bgrabitmap\bgratransform.pas"/>
|
||||
<UnitName Value="BGRATransform"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1273"/>
|
||||
<CursorPos Y="1298"/>
|
||||
<UsageCount Value="36"/>
|
||||
</Unit51>
|
||||
<Unit52>
|
||||
<Filename Value="utest19.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="98"/>
|
||||
<CursorPos X="27" Y="123"/>
|
||||
<UsageCount Value="189"/>
|
||||
</Unit52>
|
||||
<Unit53>
|
||||
<Filename Value="ucalc3d.pas"/>
|
||||
<CursorPos X="25" Y="295"/>
|
||||
<UsageCount Value="127"/>
|
||||
</Unit53>
|
||||
<Unit54>
|
||||
<Filename Value="..\bgrabitmap\bgragradientscanner.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="44"/>
|
||||
</Unit54>
|
||||
<Unit55>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpimgcanv.pp"/>
|
||||
<TopLine Value="13"/>
|
||||
<CursorPos X="35" Y="23"/>
|
||||
<UsageCount Value="27"/>
|
||||
</Unit55>
|
||||
<Unit56>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fppixlcanv.pp"/>
|
||||
<TopLine Value="25"/>
|
||||
<CursorPos X="32" Y="31"/>
|
||||
<UsageCount Value="27"/>
|
||||
</Unit56>
|
||||
<Unit57>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpcanvas.pp"/>
|
||||
<TopLine Value="162"/>
|
||||
<CursorPos X="19" Y="186"/>
|
||||
<UsageCount Value="27"/>
|
||||
</Unit57>
|
||||
<Unit58>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\packages\fcl-image\src\fpinterpolation.inc"/>
|
||||
<CursorPos X="59" Y="8"/>
|
||||
<UsageCount Value="27"/>
|
||||
</Unit58>
|
||||
<Unit59>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\objpas\math.pp"/>
|
||||
<TopLine Value="308"/>
|
||||
<CursorPos X="10" Y="326"/>
|
||||
<UsageCount Value="21"/>
|
||||
</Unit59>
|
||||
<Unit60>
|
||||
<Filename Value="utest22.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="16"/>
|
||||
<CursorPos X="30" Y="42"/>
|
||||
<UsageCount Value="165"/>
|
||||
</Unit60>
|
||||
<Unit61>
|
||||
<Filename Value="utest23.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="58"/>
|
||||
<CursorPos X="27" Y="82"/>
|
||||
<UsageCount Value="158"/>
|
||||
</Unit61>
|
||||
<Unit62>
|
||||
<Filename Value="utest24.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="62"/>
|
||||
<CursorPos X="27" Y="86"/>
|
||||
<UsageCount Value="158"/>
|
||||
</Unit62>
|
||||
<Unit63>
|
||||
<Filename Value="utexture.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="158"/>
|
||||
</Unit63>
|
||||
<Unit64>
|
||||
<Filename Value="..\bgrabitmap\bgrapolygonaliased.pas"/>
|
||||
<TopLine Value="327"/>
|
||||
<CursorPos X="33" Y="335"/>
|
||||
<ExtraEditorCount Value="1"/>
|
||||
<ExtraEditor1>
|
||||
<CursorPos X="77" Y="16"/>
|
||||
</ExtraEditor1>
|
||||
<UsageCount Value="29"/>
|
||||
</Unit64>
|
||||
<Unit65>
|
||||
<Filename Value="utest25.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<CursorPos X="48" Y="106"/>
|
||||
<UsageCount Value="129"/>
|
||||
</Unit65>
|
||||
<Unit66>
|
||||
<Filename Value="..\bgrabitmap\bgracanvas.pas"/>
|
||||
<TopLine Value="261"/>
|
||||
<CursorPos X="29" Y="279"/>
|
||||
<UsageCount Value="16"/>
|
||||
</Unit66>
|
||||
<Unit67>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\objpas\sysutils\sysstrh.inc"/>
|
||||
<TopLine Value="66"/>
|
||||
<CursorPos X="10" Y="84"/>
|
||||
<UsageCount Value="3"/>
|
||||
</Unit67>
|
||||
<Unit68>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\objpas\sysutils\sysstr.inc"/>
|
||||
<TopLine Value="167"/>
|
||||
<CursorPos X="3" Y="183"/>
|
||||
<UsageCount Value="3"/>
|
||||
</Unit68>
|
||||
<Unit69>
|
||||
<Filename Value="..\bgrabitmap\phongdraw.inc"/>
|
||||
<TopLine Value="90"/>
|
||||
<CursorPos Y="195"/>
|
||||
<UsageCount Value="20"/>
|
||||
</Unit69>
|
||||
<Unit70>
|
||||
<Filename Value="utest26.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="7"/>
|
||||
<CursorPos Y="18"/>
|
||||
<UsageCount Value="112"/>
|
||||
</Unit70>
|
||||
<Unit71>
|
||||
<Filename Value="..\bgrabitmap\filldensity256.inc"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit71>
|
||||
<Unit72>
|
||||
<Filename Value="..\bgrabitmap\perspectivescan.inc"/>
|
||||
<TopLine Value="106"/>
|
||||
<CursorPos X="3" Y="127"/>
|
||||
<UsageCount Value="8"/>
|
||||
</Unit72>
|
||||
<Unit73>
|
||||
<Filename Value="..\bgrabitmap\lineartexscan.inc"/>
|
||||
<CursorPos X="65" Y="3"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit73>
|
||||
<Unit74>
|
||||
<Filename Value="D:\lazarus\fpc\2.4.2\source\rtl\i386\mmx.pp"/>
|
||||
<TopLine Value="33"/>
|
||||
<CursorPos X="18" Y="43"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit74>
|
||||
<Unit75>
|
||||
<Filename Value="..\bgrabitmap\bgrafillinfo.pas"/>
|
||||
<TopLine Value="214"/>
|
||||
<CursorPos X="59" Y="227"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit75>
|
||||
<Unit76>
|
||||
<Filename Value="..\bgrabitmap\filldensitysegment256.inc"/>
|
||||
<CursorPos X="50" Y="15"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit76>
|
||||
<Unit77>
|
||||
<Filename Value="..\bgrabitmap\renderdensity256.inc"/>
|
||||
<TopLine Value="26"/>
|
||||
<CursorPos Y="62"/>
|
||||
<UsageCount Value="8"/>
|
||||
</Unit77>
|
||||
<Unit78>
|
||||
<Filename Value="..\bgrabitmap\multishapeline.inc"/>
|
||||
<TopLine Value="24"/>
|
||||
<CursorPos X="18" Y="43"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit78>
|
||||
<Unit79>
|
||||
<Filename Value="C:\Users\ELSASS\Downloads\uEControls_v5.10\uEControls_v5.10\uerotimage.pas"/>
|
||||
<UsageCount Value="7"/>
|
||||
</Unit79>
|
||||
<Unit80>
|
||||
<Filename Value="ucube3d.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="23"/>
|
||||
<CursorPos X="16" Y="41"/>
|
||||
<UsageCount Value="79"/>
|
||||
</Unit80>
|
||||
<Unit81>
|
||||
<Filename Value="..\bgrabitmap\bgrascene3d.pas"/>
|
||||
<TopLine Value="2510"/>
|
||||
<CursorPos X="42" Y="2571"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit81>
|
||||
<Unit82>
|
||||
<Filename Value="utest27.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="24"/>
|
||||
<CursorPos X="26" Y="42"/>
|
||||
<UsageCount Value="78"/>
|
||||
</Unit82>
|
||||
<Unit83>
|
||||
<Filename Value="utore3d.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<TopLine Value="84"/>
|
||||
<CursorPos X="12" Y="91"/>
|
||||
<UsageCount Value="78"/>
|
||||
</Unit83>
|
||||
<Unit84>
|
||||
<Filename Value="utest31.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="58"/>
|
||||
<CursorPos X="31" Y="73"/>
|
||||
<UsageCount Value="74"/>
|
||||
</Unit84>
|
||||
<Unit85>
|
||||
<Filename Value="..\bgrabitmap\bgratextfx.pas"/>
|
||||
<TopLine Value="579"/>
|
||||
<CursorPos X="25" Y="589"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit85>
|
||||
<Unit86>
|
||||
<Filename Value="..\bgrabitmap\bgraphongtypes.pas"/>
|
||||
<CursorPos X="14" Y="26"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit86>
|
||||
<Unit87>
|
||||
<Filename Value="..\bgrabitmap\bgratext.pas"/>
|
||||
<TopLine Value="75"/>
|
||||
<CursorPos X="32" Y="98"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit87>
|
||||
<Unit88>
|
||||
<Filename Value="..\bgrabitmap\bgracanvas2d.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="1365"/>
|
||||
<CursorPos X="17" Y="1369"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit88>
|
||||
<Unit89>
|
||||
<Filename Value="..\bgrabitmap\bgrasse.pas"/>
|
||||
<TopLine Value="440"/>
|
||||
<CursorPos X="38" Y="520"/>
|
||||
<UsageCount Value="8"/>
|
||||
</Unit89>
|
||||
<Unit90>
|
||||
<Filename Value="..\bgrabitmap\lightingclasses3d.inc"/>
|
||||
<TopLine Value="534"/>
|
||||
<CursorPos X="12" Y="555"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit90>
|
||||
<Unit91>
|
||||
<Filename Value="..\bgrabitmap\phonglight.inc"/>
|
||||
<TopLine Value="19"/>
|
||||
<CursorPos X="63" Y="26"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit91>
|
||||
<Unit92>
|
||||
<Filename Value="..\bgrabitmap\phongdrawsse.inc"/>
|
||||
<CursorPos X="58" Y="8"/>
|
||||
<UsageCount Value="8"/>
|
||||
</Unit92>
|
||||
<Unit93>
|
||||
<Filename Value="..\bgrabitmap\bgrabitmappack.pas"/>
|
||||
<TopLine Value="6"/>
|
||||
<CursorPos X="18" Y="14"/>
|
||||
<UsageCount Value="8"/>
|
||||
</Unit93>
|
||||
<Unit94>
|
||||
<Filename Value="..\bgrabitmap\bgragrayscalemask.pas"/>
|
||||
<CursorPos X="3" Y="13"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit94>
|
||||
<Unit95>
|
||||
<Filename Value="..\bgrabitmap\bgrautf8.pas"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit95>
|
||||
<Unit96>
|
||||
<Filename Value="C:\lazarus\lcl\graphics.pp"/>
|
||||
<TopLine Value="154"/>
|
||||
<CursorPos Y="174"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit96>
|
||||
<Unit97>
|
||||
<Filename Value="C:\lazarus\lcl\graphtype.pp"/>
|
||||
<TopLine Value="21"/>
|
||||
<CursorPos Y="44"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit97>
|
||||
<Unit98>
|
||||
<Filename Value="..\bgrabitmap\bgralclbitmap.pas"/>
|
||||
<TopLine Value="575"/>
|
||||
<CursorPos X="60" Y="578"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit98>
|
||||
<Unit99>
|
||||
<Filename Value="..\bgrabitmap\bgraqtbitmap.pas"/>
|
||||
<TopLine Value="27"/>
|
||||
<CursorPos X="46" Y="37"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit99>
|
||||
<Unit100>
|
||||
<Filename Value="..\bgrabitmap\bgragtkbitmap.pas"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit100>
|
||||
<Unit101>
|
||||
<Filename Value="..\bgrabitmap\bgratypewriter.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="19"/>
|
||||
</Unit101>
|
||||
<Unit102>
|
||||
<Filename Value="C:\lazarus\fpc\2.6.2\source\rtl\win\wininc\base.inc"/>
|
||||
<TopLine Value="92"/>
|
||||
<CursorPos X="6" Y="104"/>
|
||||
<UsageCount Value="12"/>
|
||||
</Unit102>
|
||||
<Unit103>
|
||||
<Filename Value="C:\lazarus\components\lazutils\lazutf8.pas"/>
|
||||
<TopLine Value="367"/>
|
||||
<CursorPos Y="401"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit103>
|
||||
<Unit104>
|
||||
<Filename Value="C:\lazarus\lcl\lclproc.pas"/>
|
||||
<TopLine Value="2630"/>
|
||||
<CursorPos X="10" Y="2639"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit104>
|
||||
<Unit105>
|
||||
<Filename Value="C:\lazarus\fpc\2.6.2\source\rtl\inc\wstringh.inc"/>
|
||||
<TopLine Value="10"/>
|
||||
<CursorPos X="10" Y="41"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit105>
|
||||
<Unit106>
|
||||
<Filename Value="C:\lazarus\fpc\2.6.2\source\rtl\inc\wstrings.inc"/>
|
||||
<TopLine Value="1233"/>
|
||||
<CursorPos X="5" Y="1239"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit106>
|
||||
<Unit107>
|
||||
<Filename Value="..\bgrabitmap\bgrafreetype.pas"/>
|
||||
<TopLine Value="13"/>
|
||||
<CursorPos X="33" Y="37"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit107>
|
||||
<Unit108>
|
||||
<Filename Value="C:\lazarus\fpc\2.6.2\source\rtl\objpas\types.pp"/>
|
||||
<TopLine Value="79"/>
|
||||
<CursorPos X="3" Y="98"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit108>
|
||||
<Unit109>
|
||||
<Filename Value="..\bgrabitmap\bgracustomtextfx.pas"/>
|
||||
<CursorPos X="86" Y="6"/>
|
||||
<UsageCount Value="11"/>
|
||||
</Unit109>
|
||||
<Unit110>
|
||||
<Filename Value="..\bgrabitmap\bgragraphics.pas"/>
|
||||
<CursorPos X="34" Y="8"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit110>
|
||||
<Unit111>
|
||||
<Filename Value="..\bgrabitmap\bgrareadico.pas"/>
|
||||
<TopLine Value="53"/>
|
||||
<CursorPos X="53" Y="66"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit111>
|
||||
<Unit112>
|
||||
<Filename Value="utest32.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="99"/>
|
||||
<CursorPos Y="124"/>
|
||||
<UsageCount Value="32"/>
|
||||
</Unit112>
|
||||
<Unit113>
|
||||
<Filename Value="..\bgrabitmap\bgracustombitmap.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="9"/>
|
||||
<CursorPos X="14" Y="23"/>
|
||||
<UsageCount Value="15"/>
|
||||
</Unit113>
|
||||
<Unit114>
|
||||
<Filename Value="..\bgrabitmap\bgrapath.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="138"/>
|
||||
<CursorPos Y="155"/>
|
||||
<UsageCount Value="15"/>
|
||||
</Unit114>
|
||||
<Unit115>
|
||||
<Filename Value="..\bgrabitmap\geometrytypes.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="239"/>
|
||||
<CursorPos X="50" Y="261"/>
|
||||
<UsageCount Value="15"/>
|
||||
</Unit115>
|
||||
<Unit116>
|
||||
<Filename Value="C:\lazarus\lcl\interfaces\win32\win32callback.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="2710"/>
|
||||
<CursorPos X="33" Y="2722"/>
|
||||
<UsageCount Value="14"/>
|
||||
</Unit116>
|
||||
<Unit117>
|
||||
<Filename Value="C:\lazarus\lcl\customtimer.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="161"/>
|
||||
<CursorPos Y="181"/>
|
||||
<UsageCount Value="14"/>
|
||||
</Unit117>
|
||||
<Unit118>
|
||||
<Filename Value="C:\lazarus\components\lazutils\easylazfreetype.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos Y="3"/>
|
||||
<UsageCount Value="13"/>
|
||||
</Unit118>
|
||||
<Unit119>
|
||||
<Filename Value="utest33.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="41"/>
|
||||
<CursorPos X="73" Y="50"/>
|
||||
<UsageCount Value="25"/>
|
||||
</Unit119>
|
||||
<Unit120>
|
||||
<Filename Value="..\bgrabitmap\bgrapixel.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="29"/>
|
||||
<CursorPos X="12" Y="34"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit120>
|
||||
<Unit121>
|
||||
<Filename Value="C:\lazarus\fpc\2.6.4\source\packages\fcl-image\src\fpimage.pp"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="121"/>
|
||||
<CursorPos X="17" Y="137"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit121>
|
||||
<Unit122>
|
||||
<Filename Value="..\bgrabitmap\perspectivescan2.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="111"/>
|
||||
<CursorPos X="102" Y="126"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit122>
|
||||
</Units>
|
||||
<JumpHistory Count="1">
|
||||
<Position1>
|
||||
<Filename Value="umain.pas"/>
|
||||
<Caret Line="25" Column="46" TopLine="20"/>
|
||||
</Position1>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
23
bgrabitmap/test/testbgrafunc/testbgrafunc.lpr
Normal file
23
bgrabitmap/test/testbgrafunc/testbgrafunc.lpr
Normal file
@@ -0,0 +1,23 @@
|
||||
program testbgrafunc;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, umain, utest1, utest2, utest3, utest4, utest5, utest6, utest7, utest8,
|
||||
utest9, utest10, utest11, utest14, utest15, utest16, utest17, utest18,
|
||||
utest19, utestback, utestpacrect, etpackage, utest22, utest23, utest24,
|
||||
utexture, utest25, utest26, ucube3d, utest27, utore3d, utest31, utest32,
|
||||
utest33;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TFMain, FMain);
|
||||
Application.Run;
|
||||
end.
|
||||
|
68
bgrabitmap/test/testbgrafunc/ucube3d.pas
Normal file
68
bgrabitmap/test/testbgrafunc/ucube3d.pas
Normal file
@@ -0,0 +1,68 @@
|
||||
unit ucube3d;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRAScene3D, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TCubeScene3D }
|
||||
|
||||
TCubeScene3D = class(TBGRAScene3D)
|
||||
cube: IBGRAObject3D;
|
||||
constructor Create;
|
||||
procedure SetCubeTexture(ATexture: TBGRACustomBitmap);
|
||||
procedure SetCubeTexture(ATexture: IBGRAScanner; tx,ty: single);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TCubeScene3D }
|
||||
|
||||
constructor TCubeScene3D.Create;
|
||||
var v: arrayOfIBGRAVertex3D;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
cube := CreateObject;
|
||||
v := cube.MainPart.Add([-1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1,
|
||||
-1,-1,+1, 1,-1,+1, 1,1,+1, -1,1,+1]);
|
||||
|
||||
cube.AddFace([v[0],v[1],v[2],v[3]],BGRA(255,0,0));
|
||||
cube.AddFace([v[4],v[5],v[1],v[0]],BGRA(128,160,255));
|
||||
cube.AddFace([v[7],v[6],v[5],v[4]],BGRA(96,224,0));
|
||||
cube.AddFace([v[3],v[2],v[6],v[7]],BGRA(192,0,255));
|
||||
cube.AddFace([v[1],v[5],v[6],v[2]],BGRA(255,192,0));
|
||||
cube.AddFace([v[4],v[0],v[3],v[7]],BGRAWhite);
|
||||
|
||||
cube.MainPart.Scale(20);
|
||||
|
||||
AmbiantLightness := 0.5;
|
||||
AddDirectionalLight(Point3D(1,1,1),1,-0.5);
|
||||
end;
|
||||
|
||||
procedure TCubeScene3D.SetCubeTexture(ATexture: TBGRACustomBitmap);
|
||||
begin
|
||||
SetCubeTexture(ATexture,ATexture.Width-1,ATexture.Height-1);
|
||||
end;
|
||||
|
||||
procedure TCubeScene3D.SetCubeTexture(ATexture: IBGRAScanner; tx, ty: single);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to cube.FaceCount-1 do
|
||||
with cube.Face[i] do
|
||||
begin
|
||||
Texture := ATexture;
|
||||
TexCoord[0] := PointF(0,0);
|
||||
TexCoord[1] := PointF(tx,0);
|
||||
TexCoord[2] := PointF(tx,ty);
|
||||
TexCoord[3] := PointF(0,ty);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
79
bgrabitmap/test/testbgrafunc/umain.lfm
Normal file
79
bgrabitmap/test/testbgrafunc/umain.lfm
Normal file
@@ -0,0 +1,79 @@
|
||||
object FMain: TFMain
|
||||
Left = 456
|
||||
Height = 301
|
||||
Top = 194
|
||||
Width = 650
|
||||
Caption = 'BGRABitmap functions test'
|
||||
ClientHeight = 301
|
||||
ClientWidth = 650
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnPaint = FormPaint
|
||||
LCLVersion = '1.6.0.4'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 62
|
||||
Top = 0
|
||||
Width = 650
|
||||
Align = alTop
|
||||
ClientHeight = 62
|
||||
ClientWidth = 650
|
||||
TabOrder = 0
|
||||
object Label_TestName: TLabel
|
||||
Left = 1
|
||||
Height = 39
|
||||
Top = 1
|
||||
Width = 648
|
||||
Align = alTop
|
||||
AutoSize = False
|
||||
Caption = 'Label_TestName'
|
||||
Font.Height = -12
|
||||
Layout = tlCenter
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
WordWrap = True
|
||||
end
|
||||
object Button_First: TButton
|
||||
Left = 7
|
||||
Height = 22
|
||||
Top = 37
|
||||
Width = 75
|
||||
Caption = 'First'
|
||||
OnClick = Button_FirstClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button_Prev: TButton
|
||||
Left = 88
|
||||
Height = 22
|
||||
Top = 37
|
||||
Width = 75
|
||||
Caption = '<< Prev'
|
||||
OnClick = Button_PrevClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object Button_Next: TButton
|
||||
Left = 168
|
||||
Height = 22
|
||||
Top = 37
|
||||
Width = 75
|
||||
Caption = 'Next >>'
|
||||
OnClick = Button_NextClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object Button_Last: TButton
|
||||
Left = 248
|
||||
Height = 22
|
||||
Top = 37
|
||||
Width = 75
|
||||
Caption = 'Last'
|
||||
OnClick = Button_LastClick
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object Timer1: TTimer
|
||||
Interval = 30
|
||||
OnTimer = Timer1Timer
|
||||
left = 568
|
||||
top = 96
|
||||
end
|
||||
end
|
211
bgrabitmap/test/testbgrafunc/umain.pas
Normal file
211
bgrabitmap/test/testbgrafunc/umain.pas
Normal file
@@ -0,0 +1,211 @@
|
||||
unit umain;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, utest, EpikTimer;
|
||||
|
||||
type
|
||||
|
||||
{ TFMain }
|
||||
|
||||
TFMain = class(TForm)
|
||||
Button_First: TButton;
|
||||
Button_Last: TButton;
|
||||
Button_Next: TButton;
|
||||
Button_Prev: TButton;
|
||||
Label_TestName: TLabel;
|
||||
Panel1: TPanel;
|
||||
Timer1: TTimer;
|
||||
procedure Button_LastClick(Sender: TObject);
|
||||
procedure Button_NextClick(Sender: TObject);
|
||||
procedure Button_FirstClick(Sender: TObject);
|
||||
procedure Button_PrevClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormPaint(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
public
|
||||
NumTest: integer;
|
||||
CurrentTest: TTest;
|
||||
stopwatch, timeMeasure: TEpikTimer;
|
||||
procedure SetNumTest(value: integer);
|
||||
end;
|
||||
|
||||
var
|
||||
FMain: TFMain;
|
||||
|
||||
implementation
|
||||
|
||||
uses utest1, utest2, utest3, utest4, utest5, utest6, utest7,
|
||||
utest8, utest9, utest10, utest11, utest14, utest15, utest16, utest17,
|
||||
utest18, utest19, utest22, utest23, utest24, utest25, utest26,
|
||||
utest27, utest31, utest32, utest33, BGRAScene3D,
|
||||
BGRABitmapTypes, LCLIntf, BGRAText;
|
||||
|
||||
const
|
||||
TestCount = 33;
|
||||
|
||||
{ TFMain }
|
||||
|
||||
procedure TFMain.SetNumTest(value: integer);
|
||||
begin
|
||||
FreeAndNil(CurrentTest);
|
||||
numTest := value;
|
||||
Button_Prev.Enabled := TestCount >=2;
|
||||
Button_Next.Enabled := TestCount >=2;
|
||||
case numTest of
|
||||
1: currentTest := TTest1.Create;
|
||||
2: currentTest := TTest2.Create;
|
||||
3: currentTest := TTest3.Create;
|
||||
4: currentTest := TTest4.Create;
|
||||
5: currentTest := TTest5.Create;
|
||||
6: currentTest := TTest6.Create;
|
||||
7: currentTest := TTest7.create;
|
||||
8: currentTest := TTest8.create;
|
||||
9: currentTest := TTest9.create;
|
||||
10: currentTest := TTest10.create;
|
||||
11: currentTest := TTest11.create('');
|
||||
12: currentTest := TTest11.create('Emboss');
|
||||
13: currentTest := TTest11.create('Contour');
|
||||
14: currentTest := TTest14.create;
|
||||
15: currentTest := TTest15.create;
|
||||
16: currentTest := TTest16.create;
|
||||
17: currentTest := TTest17.create;
|
||||
18: currentTest := TTest18.create;
|
||||
19: currentTest := TTest19.create(False,False);
|
||||
20: currentTest := TTest19.create(True,False);
|
||||
21: currentTest := TTest19.create(True,True);
|
||||
22: currentTest := TTest22.create;
|
||||
23: currentTest := TTest23.create;
|
||||
24: currentTest := TTest24.create;
|
||||
25: currentTest := TTest25.create;
|
||||
26: currentTest := TTest26.create;
|
||||
27: currentTest := TTest27.create(lnFace, liLowQuality);
|
||||
28: currentTest := TTest27.create(lnFaceVertexMix, liLowQuality);
|
||||
29: currentTest := TTest27.create(lnVertex, liLowQuality);
|
||||
30: currentTest := TTest27.create(lnVertex, liAlwaysHighQuality);
|
||||
31: currentTest := TTest31.create;
|
||||
32: currentTest := TTest32.create;
|
||||
33: currentTest := TTest33.create;
|
||||
else
|
||||
raise exception.Create('Test number unknown ('+IntToStr(numTest)+')');
|
||||
end;
|
||||
Label_TestName.Caption := 'Test n°'+inttostr(Value)+': '+currentTest.Name;
|
||||
end;
|
||||
|
||||
procedure TFMain.FormCreate(Sender: TObject);
|
||||
begin
|
||||
CurrentTest := nil;
|
||||
{$IFDEF DARWIN}
|
||||
ResourceDir := ExtractFilePath(Application.ExeName)+'../../../../'+'img'+pathdelim;
|
||||
If not FileExists(ResourceDir+'pac_d1.bmp') then
|
||||
{$ENDIF}
|
||||
ResourceDir:= ExtractFilePath(Application.ExeName)+'..'+pathdelim+'img'+pathdelim;
|
||||
|
||||
SetNumTest(1);
|
||||
stopwatch := TEpikTimer.Create(Application);
|
||||
timeMeasure := TEpikTimer.Create(Application);
|
||||
timeMeasure.Start;
|
||||
|
||||
if TBGRAPixel_RGBAOrder then
|
||||
Caption := Caption + ' (RGBA 32-bit)'
|
||||
else
|
||||
Caption := Caption + ' (BGRA 32-bit)';
|
||||
end;
|
||||
|
||||
procedure TFMain.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(CurrentTest);
|
||||
end;
|
||||
|
||||
procedure TFMain.FormPaint(Sender: TObject);
|
||||
var
|
||||
strTime: string;
|
||||
ptText: TPoint;
|
||||
drawElapsed: extended;
|
||||
begin
|
||||
if CurrentTest <> nil then
|
||||
begin
|
||||
stopwatch.clear;
|
||||
stopwatch.Start;
|
||||
|
||||
CurrentTest.OnPaint(self.Canvas,0,Panel1.Height,ClientWidth,ClientHeight-Panel1.Height);
|
||||
|
||||
drawElapsed := stopwatch.Elapsed;
|
||||
|
||||
if drawElapsed > 0.0001 then
|
||||
begin
|
||||
strTime := IntToStr(round(drawElapsed*1000))+ ' ms';
|
||||
strTime += ', ' + IntToStr(round(1/drawElapsed)) + ' FPS';
|
||||
ptText := Point(3,ClientHeight-25);
|
||||
with self.Canvas do
|
||||
begin
|
||||
Font.Height := FixLCLFontFullHeight(Font.Name,25);
|
||||
Font.Style := [fsBold];
|
||||
Brush.Style := bsClear;
|
||||
Font.Color := clBlack;
|
||||
TextOut(ptText.X-1,ptText.Y-1,strTime);
|
||||
TextOut(ptText.X+1,ptText.Y-1,strTime);
|
||||
TextOut(ptText.X+1,ptText.Y+1,strTime);
|
||||
TextOut(ptText.X-1,ptText.Y+1,strTime);
|
||||
Font.Color := clWhite;
|
||||
TextOut(ptText.X,ptText.Y,strTime);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFMain.Timer1Timer(Sender: TObject);
|
||||
var
|
||||
elapsed: Extended;
|
||||
r: TRect;
|
||||
begin
|
||||
if CurrentTest <> nil then
|
||||
begin
|
||||
Timer1.Enabled := false;
|
||||
elapsed := timeMeasure.Elapsed;
|
||||
timeMeasure.clear;
|
||||
timeMeasure.Start;
|
||||
|
||||
CurrentTest.OnTimer(ClientWidth,ClientHeight-Panel1.Height,elapsed);
|
||||
r := rect(0,Panel1.Height,ClientWidth,ClientHeight);
|
||||
InvalidateRect(self.Handle,@r,False);
|
||||
self.Update;
|
||||
Timer1.Enabled := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFMain.Button_NextClick(Sender: TObject);
|
||||
begin
|
||||
if NumTest < TestCount then
|
||||
SetNumTest(NumTest+1) else
|
||||
SetNumTest(1);
|
||||
end;
|
||||
|
||||
procedure TFMain.Button_LastClick(Sender: TObject);
|
||||
begin
|
||||
SetNumTest(TestCount);
|
||||
end;
|
||||
|
||||
procedure TFMain.Button_FirstClick(Sender: TObject);
|
||||
begin
|
||||
SetNumTest(1);
|
||||
end;
|
||||
|
||||
procedure TFMain.Button_PrevClick(Sender: TObject);
|
||||
begin
|
||||
if NumTest > 1 then
|
||||
SetNumTest(NumTest-1) else
|
||||
SetNumTest(TestCount);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I umain.lrs}
|
||||
|
||||
end.
|
||||
|
24
bgrabitmap/test/testbgrafunc/utest.pas
Normal file
24
bgrabitmap/test/testbgrafunc/utest.pas
Normal file
@@ -0,0 +1,24 @@
|
||||
unit utest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics;
|
||||
|
||||
type
|
||||
TTest = class
|
||||
public
|
||||
Name: string;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); virtual; abstract;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); virtual; abstract;
|
||||
end;
|
||||
|
||||
var
|
||||
ResourceDir: string;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
43
bgrabitmap/test/testbgrafunc/utest1.pas
Normal file
43
bgrabitmap/test/testbgrafunc/utest1.pas
Normal file
@@ -0,0 +1,43 @@
|
||||
unit utest1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utestpacrect;
|
||||
|
||||
type
|
||||
{ TTest1 }
|
||||
|
||||
TTest1 = class(TTestPacRect)
|
||||
public
|
||||
constructor Create;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest1 }
|
||||
|
||||
constructor TTest1.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Canvas.Draw(TBitmap) on Form. NOT RECOMMENDED! Flickering pacmans walking with a rectangle. Rectangle opacity depends on the standard Canvas rendering capacities on windows.';
|
||||
end;
|
||||
|
||||
procedure TTest1.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var i: integer;
|
||||
begin
|
||||
if backgroundImg = nil then exit;
|
||||
|
||||
//draw background as TBitmap
|
||||
Canvas.Draw(Left,Top,backgroundImg.Bitmap);
|
||||
|
||||
//draw sprites as TBitmaps
|
||||
for i := 0 to high(pacLoc) do
|
||||
Canvas.Draw(Left+pacLoc[i].x,Top+pacLoc[i].y,pacImg[numPacImg].Bitmap);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
108
bgrabitmap/test/testbgrafunc/utest10.pas
Normal file
108
bgrabitmap/test/testbgrafunc/utest10.pas
Normal file
@@ -0,0 +1,108 @@
|
||||
unit utest10;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
const
|
||||
sinTabPrecision = 12;
|
||||
|
||||
type
|
||||
{ TTest10 }
|
||||
|
||||
TTest10 = class(TTest)
|
||||
protected
|
||||
virtualScreen: TBGRABitmap;
|
||||
time: single;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest10 }
|
||||
|
||||
constructor TTest10.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Plasma rendered by Scanline access';
|
||||
virtualScreen := nil;
|
||||
time := 0;
|
||||
end;
|
||||
|
||||
destructor TTest10.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest10.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var xb,yb: integer;
|
||||
p: PBGRAPixel;
|
||||
value: integer;
|
||||
center: TPointF;
|
||||
intTime1, intTime2, intTime3: integer;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
center := pointF((sin(time)+1)/4+0.2,(cos(time*0.3)+1)/4+0.3);
|
||||
intTime1 := round(time*65536*7/10);
|
||||
intTime2 := round(time*65536*11/10);
|
||||
intTime3 := round(time*65536*13/10);
|
||||
for yb := 0 to virtualscreen.Height-1 do
|
||||
begin
|
||||
p := virtualScreen.ScanLine[yb];
|
||||
for xb := 0 to virtualScreen.Width-1 do
|
||||
begin
|
||||
{$push}{$r-}
|
||||
value := Sin65536(
|
||||
(xb shl 8 + (height-yb)*(Sin65536(intTime2 shr 2) shr 8 - 128) + intTime1 shr 5 + Sin65536(yb shl 16 div height + intTime3) shr 4)*
|
||||
( Sin65536(intTime1 shr 3) shr 9 - 64 + 256 )*2 div Width);
|
||||
inc(value, Sin65536(yb * ( Sin65536(intTime1 shr 2) shr 9 - 64 + 256 )*256 div Height + intTime1 shr 1 +
|
||||
xb*(Sin65536(intTime2 shr 4) shr 8 - 128) ) );
|
||||
|
||||
inc(value, Sin65536( round( sqrt(sqr(xb/width-center.x)+sqr(yb/height-center.y))
|
||||
* ( (Sin65536(intTime3 shr 3)+ 2*65536) ) ) + intTime2 shr 2) );
|
||||
{$pop}
|
||||
|
||||
value := value div (3*128);
|
||||
|
||||
if value > 255 then
|
||||
begin
|
||||
if value < 511 then value := value-256 else
|
||||
value := 255;
|
||||
p^.red := 255;
|
||||
p^.green := 64+value shr 1;
|
||||
p^.blue := 0;
|
||||
end else
|
||||
begin
|
||||
p^.red := value;
|
||||
p^.green := value shr 2;
|
||||
p^.blue := 0;
|
||||
end;
|
||||
p^.alpha := 255;
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
virtualScreen.InvalidateBitmap;
|
||||
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest10.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
136
bgrabitmap/test/testbgrafunc/utest11.pas
Normal file
136
bgrabitmap/test/testbgrafunc/utest11.pas
Normal file
@@ -0,0 +1,136 @@
|
||||
unit utest11;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, BGRAGrayscaleMask;
|
||||
|
||||
const
|
||||
nbPoints = 6;
|
||||
|
||||
type
|
||||
{ TTest11 }
|
||||
|
||||
TTest11 = class(TTest)
|
||||
protected
|
||||
virtualScreen: TBGRABitmap;
|
||||
mask: TGrayscaleMask;
|
||||
pts: array of TPointF;
|
||||
dirs: array of TPointF;
|
||||
FFilter: string;
|
||||
|
||||
public
|
||||
constructor Create(filter: string);
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest11 }
|
||||
|
||||
constructor TTest11.Create(filter: string);
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Antialiased lines and splines';
|
||||
if filter <> '' then Name += ' with filter '+filter;
|
||||
randomize;
|
||||
virtualScreen := nil;
|
||||
FFilter := filter;
|
||||
end;
|
||||
|
||||
destructor TTest11.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest11.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var filtered: TBGRABitmap;
|
||||
filteredMask: TGrayscaleMask;
|
||||
begin
|
||||
if pts = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
if (mask <> nil) and ((mask.width <> width) or (mask.Height <> height)) then
|
||||
FreeAndNil(mask);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
if ffilter = 'Emboss' then
|
||||
begin
|
||||
virtualScreen.Fill(BGRABlack);
|
||||
virtualScreen.DrawPolyLineAntialias(virtualScreen.ComputeOpenedSpline(pts,ssCrossing),BGRAWhite,(width+height)/80,True);
|
||||
filtered := virtualScreen.FilterEmbossHighlight(True);
|
||||
virtualScreen.Fill(clForm);
|
||||
virtualScreen.PutImage(0,0,filtered,dmDrawWithTransparency);
|
||||
filtered.Free;
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end else
|
||||
if ffilter = 'Contour' then
|
||||
begin
|
||||
if mask = nil then
|
||||
mask := TGrayscaleMask.Create(virtualScreen.Width, virtualScreen.Height);
|
||||
mask.Fill(ByteMaskBlack);
|
||||
mask.DrawPolyLineAntialias(virtualScreen.ComputeOpenedSpline(pts,ssCrossing),
|
||||
ByteMaskWhite, (width+height)/80, True);
|
||||
filteredMask := mask.FilterContour;
|
||||
filteredMask.Draw(virtualScreen, 0, 0, true);
|
||||
filteredMask.Free;
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end else
|
||||
begin
|
||||
virtualScreen.Fill(BGRAWhite);
|
||||
virtualScreen.DrawPolyLineAntialias(virtualScreen.ComputeOpenedSpline(pts,ssCrossing),BGRA(0,0,0,128),(width+height)/80,True);
|
||||
virtualScreen.DrawPolyLineAntialias(pts,BGRA(0,0,0,128),(width+height)/800,True);
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest11.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var i: integer;
|
||||
begin
|
||||
if pts = nil then
|
||||
begin
|
||||
setlength(pts,nbPoints);
|
||||
setlength(dirs,nbPoints);
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i] := pointf(random(Width),random(Height));
|
||||
dirs[i] := pointf((random(Width)-width/2)/20,(random(Height)-height/2)/20);
|
||||
end;
|
||||
end;
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i].x := pts[i].x+dirs[i].x;
|
||||
if pts[i].x < 0 then
|
||||
begin
|
||||
pts[i].x := 0;
|
||||
dirs[i].x := abs(dirs[i].x);
|
||||
end;
|
||||
if pts[i].x > width-1 then
|
||||
begin
|
||||
pts[i].x := width-1;
|
||||
dirs[i].x := -abs(dirs[i].x);
|
||||
end;
|
||||
pts[i].y := pts[i].y+dirs[i].y;
|
||||
if pts[i].y < 0 then
|
||||
begin
|
||||
pts[i].y := 0;
|
||||
dirs[i].y := abs(dirs[i].y);
|
||||
end;
|
||||
if pts[i].y > height-1 then
|
||||
begin
|
||||
pts[i].y := height-1;
|
||||
dirs[i].y := -abs(dirs[i].y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
77
bgrabitmap/test/testbgrafunc/utest14.pas
Normal file
77
bgrabitmap/test/testbgrafunc/utest14.pas
Normal file
@@ -0,0 +1,77 @@
|
||||
unit utest14;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics, BGRABitmap, BGRABitmapTypes, utest;
|
||||
|
||||
type
|
||||
{ TTest14 }
|
||||
|
||||
TTest14 = class(TTest)
|
||||
protected
|
||||
virtualScreen: TBGRABitmap;
|
||||
time: single;
|
||||
lightPos1,lightPos2: TPointF;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest14 }
|
||||
|
||||
constructor TTest14.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Layer blending: adding red and green gives yellow';
|
||||
virtualScreen := nil;
|
||||
time := 0;
|
||||
end;
|
||||
|
||||
destructor TTest14.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest14.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var layer: TBGRABitmap; x,y: single; radius: integer;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
if time = 0 then exit;
|
||||
|
||||
radius := (width+height) div 8;
|
||||
virtualScreen.Fill(BGRABlack);
|
||||
x := lightPos1.X*Width;
|
||||
y := lightPos1.Y*Height;
|
||||
virtualScreen.FillEllipseAntialias(x,y,radius,radius,BGRA(255,0,0,255));
|
||||
layer := TBGRABitmap.Create(Width,Height,BGRABlack);
|
||||
x := lightPos2.X*Width;
|
||||
y := lightPos2.Y*Height;
|
||||
layer.FillEllipseAntialias(x,y,radius,radius,BGRA(0,255,0,255));
|
||||
virtualScreen.BlendImage(0,0,layer,boAdditive);
|
||||
layer.Free;
|
||||
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest14.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec*0.5;
|
||||
lightPos1 := pointF((sin(time)+1)/4+0.2,(cos(time*0.3)+1)/4+0.3);
|
||||
lightPos2 := pointF((sin(time*0.7+1)+1)/4+0.4,(cos(time*0.5+2)+1)/4+0.3);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
136
bgrabitmap/test/testbgrafunc/utest15.pas
Normal file
136
bgrabitmap/test/testbgrafunc/utest15.pas
Normal file
@@ -0,0 +1,136 @@
|
||||
unit utest15;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Classes, SysUtils, utest, BGRAGradients, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTest15 }
|
||||
|
||||
TTest15 = class(TTest)
|
||||
private
|
||||
phong: TPhongShading;
|
||||
virtualScreen, map, colorMap: TBGRABitmap;
|
||||
time: double;
|
||||
lightPos1: TPointF;
|
||||
ShouldGenerateMap: Boolean;
|
||||
procedure GenerateMap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest15 }
|
||||
|
||||
constructor TTest15.Create;
|
||||
begin
|
||||
Name := 'Phong shading and Perlin noise';
|
||||
virtualScreen := nil;
|
||||
time := 0;
|
||||
|
||||
randomize;
|
||||
phong := TPhongShading.Create;
|
||||
phong.LightPositionZ := 128;
|
||||
phong.SpecularIndex := 20;
|
||||
phong.SpecularFactor := 0.5;
|
||||
phong.LightSourceIntensity := 100;
|
||||
phong.AmbientFactor := 0.3;
|
||||
phong.NegativeDiffusionFactor := 0.3;
|
||||
ShouldGenerateMap:= false;
|
||||
end;
|
||||
|
||||
destructor TTest15.Destroy;
|
||||
begin
|
||||
phong.Free;
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest15.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
const lightSize= 20;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(map);
|
||||
FreeAndNil(colorMap);
|
||||
end;
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
end;
|
||||
|
||||
if ShouldGenerateMap then
|
||||
begin
|
||||
GenerateMap;
|
||||
ShouldGenerateMap := false;
|
||||
end;
|
||||
|
||||
if map <> nil then
|
||||
begin
|
||||
phong.LightPositionF := PointF(lightPos1.x * Width, lightPos1.y * Height);
|
||||
phong.Draw(virtualScreen,map,64,0,0,colorMap);
|
||||
virtualScreen.GradientFill(phong.LightPosition.X-lightSize,phong.LightPosition.Y-lightSize,
|
||||
phong.LightPosition.X+lightSize,phong.LightPosition.Y+lightSize, BGRA(255,255,240,255),BGRAPixelTransparent,
|
||||
gtRadial,PointF(phong.LightPosition.X,phong.LightPosition.Y),PointF(phong.LightPosition.X+lightSize,phong.LightPosition.Y),
|
||||
dmDrawWithTransparency);
|
||||
virtualScreen.Draw(Canvas,Left,Top,True);
|
||||
end else
|
||||
begin
|
||||
virtualScreen.Fill(BGRABlack);
|
||||
virtualScreen.TextOut(Width div 2, height div 2-virtualScreen.FontHeight div 2,'Generating map...',BGRAWhite,taCenter);
|
||||
virtualScreen.Draw(Canvas,Left,Top,True);
|
||||
ShouldGenerateMap := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TTest15.GenerateMap;
|
||||
var
|
||||
i: Integer;
|
||||
p: PBGRAPixel;
|
||||
pcol: PBGRAPixel;
|
||||
temp: TBGRABitmap;
|
||||
begin
|
||||
FreeAndNil(map);
|
||||
FreeAndNil(colorMap);
|
||||
map := CreatePerlinNoiseMap(virtualscreen.Width,virtualscreen.Height,2,2);
|
||||
colorMap := TBGRABitmap.Create(map.width,map.Height,BGRAWhite);
|
||||
p := map.Data;
|
||||
pcol := colorMap.Data;
|
||||
for i := 0 to map.NbPixels-1 do
|
||||
begin
|
||||
if p^.red < 64 then pcol^ := BGRA(0,128,255) else //water
|
||||
if p^.red < 96 then pcol^ := BGRA(240,200,100) else //beach
|
||||
if p^.red < 128 then pcol^ := BGRA(100,190,0) else //grass
|
||||
if p^.red < 220 then pcol^ := BGRA(180,120,90) else //mountain
|
||||
pcol^ := BGRAWhite; //snow
|
||||
|
||||
if p^.red < 128 then //water and beach less
|
||||
p^ := MapHeightToBGRA((128-(128-p^.red)/4)/255,255);
|
||||
|
||||
inc(pcol);
|
||||
inc(p);
|
||||
end;
|
||||
|
||||
temp := colorMap.FilterBlurRadial(2,rbCorona);
|
||||
colorMap.Free;
|
||||
colorMap := temp;
|
||||
end;
|
||||
|
||||
procedure TTest15.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec;
|
||||
lightPos1 := pointF((sin(time*0.7+1)+1)/4+0.4,(cos(time*0.5+2)+1)/4+0.3);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
194
bgrabitmap/test/testbgrafunc/utest16.pas
Normal file
194
bgrabitmap/test/testbgrafunc/utest16.pas
Normal file
@@ -0,0 +1,194 @@
|
||||
unit utest16;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Classes, SysUtils, utest, BGRAGradients, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTest16 }
|
||||
|
||||
TTest16 = class(TTest)
|
||||
private
|
||||
phong: TPhongShading;
|
||||
chartTime,lightTime: double;
|
||||
lightPos1: TPointF;
|
||||
RoundCorners : boolean;
|
||||
series: array of record
|
||||
val1,val2: integer;
|
||||
end;
|
||||
color1,color2: TBGRAPixel;
|
||||
procedure NewChart;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses types;
|
||||
|
||||
{ TTest16 }
|
||||
|
||||
constructor TTest16.Create;
|
||||
begin
|
||||
Name := 'Phong shading primitives';
|
||||
lightTime := 0;
|
||||
chartTime := 0;
|
||||
|
||||
randomize;
|
||||
phong := TPhongShading.Create;
|
||||
NewChart;
|
||||
end;
|
||||
|
||||
procedure TTest16.NewChart;
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
procedure RandomSwap(var color: TBGRAPixel);
|
||||
var temp: byte;
|
||||
begin
|
||||
if random(2)= 0 then
|
||||
begin
|
||||
temp := color.Red;
|
||||
color.red := color.Green;
|
||||
color.green := temp;
|
||||
end;
|
||||
if random(2)= 0 then
|
||||
begin
|
||||
temp := color.green;
|
||||
color.green := color.blue;
|
||||
color.blue := temp;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
setlength(series, 4+random(6));
|
||||
for i := 0 to high(series) do
|
||||
begin
|
||||
series[i].val1 := random(50);
|
||||
series[i].val2 := random(50);
|
||||
end;
|
||||
color1 := BGRA(255,160,0);
|
||||
RandomSwap(color1);
|
||||
color2 := BGRA(140,180,255);
|
||||
RandomSwap(Color2);
|
||||
RoundCorners := not RoundCorners;
|
||||
end;
|
||||
|
||||
destructor TTest16.Destroy;
|
||||
begin
|
||||
phong.Free;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest16.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var
|
||||
borderSize: integer;
|
||||
barPrecalc: TBGRABitmap;
|
||||
|
||||
procedure DrawBar(image: TBGRABitmap; bounds: TRect; color : TBGRAPixel);
|
||||
begin
|
||||
if barPrecalc <> nil then
|
||||
phong.Draw(image,barPrecalc,borderSize,bounds.Left,bounds.Top,color)
|
||||
else
|
||||
phong.DrawRectangle(image,bounds,borderSize,borderSize,color,RoundCorners,[rmoNoBottomBorder]);
|
||||
end;
|
||||
|
||||
const
|
||||
chartTitle = 'Chart example';
|
||||
|
||||
var
|
||||
image: TBGRABitmap;
|
||||
i: integer;
|
||||
maxVal: integer;
|
||||
r: TRect;
|
||||
gbounds: TRect;
|
||||
s: TSize;
|
||||
|
||||
begin
|
||||
if lightTime = 0 then exit;
|
||||
barPrecalc := nil;
|
||||
|
||||
//create background
|
||||
image := TBGRABitmap.Create(Width,Height);
|
||||
image.GradientFill(0,0,image.Width,image.Height,BGRA(255,255,255),BGRA(128,128,128),gtLinear,PointF(0,0),PointF(image.Width,Image.Height),dmSet);
|
||||
|
||||
gbounds := rect(round(image.Width*0.1),round(image.Height*0.2),round(image.Width*0.9),round(image.Height*0.98));
|
||||
image.Rectangle(gbounds,BGRA(0,0,0,96),dmDrawWithTransparency);
|
||||
borderSize := round((gbounds.right-gbounds.left)/length(series)*0.06);
|
||||
if borderSize = 0 then borderSize := 1;
|
||||
|
||||
//init phong
|
||||
phong.LightPosition := Point(round(lightPos1.X*Width),round(lightPos1.Y*Height));
|
||||
phong.LightPositionZ := 2*borderSize;
|
||||
|
||||
//draw title
|
||||
image.FontHeight := gbounds.Top div 4;
|
||||
s := image.TextSize(chartTitle);
|
||||
phong.DrawSphere(image, rect((gbounds.Left+gbounds.Right-s.cx*2) div 2,(gbounds.Top-s.cy*2) div 2,
|
||||
(gbounds.Left+gbounds.Right+s.cx*2) div 2,(gbounds.Top+s.cy*2) div 2),10,BGRA(0,255,0,192));
|
||||
image.TextOut((gbounds.Left+gbounds.Right) div 2+1, (gbounds.Top-s.cy) div 2+1,ChartTitle,BGRABlack,taCenter);
|
||||
image.TextOut((gbounds.Left+gbounds.Right) div 2-1, (gbounds.Top-s.cy) div 2-1,ChartTitle,BGRAWhite,taCenter);
|
||||
|
||||
//compute max value
|
||||
maxVal := 1;
|
||||
for i := 0 to high(series) do
|
||||
begin
|
||||
if series[i].val1 > maxVal then maxVal := series[i].Val1;
|
||||
if series[i].val2 > maxVal then maxVal := series[i].Val2;
|
||||
end;
|
||||
|
||||
if RoundCorners then
|
||||
barPrecalc := CreateRoundRectangleMap(round((0.4-0.1)/length(series)*(gbounds.Right-gBounds.Left)),gBounds.Bottom-gBounds.Top,borderSize,[rmoNoBottomBorder])
|
||||
else
|
||||
barPrecalc := CreateRectangleMap(round((0.4-0.1)/length(series)*(gbounds.Right-gBounds.Left)),gBounds.Bottom-gBounds.Top,borderSize,[rmoNoBottomBorder]);
|
||||
image.ClipRect := gBounds;
|
||||
|
||||
//draw bars
|
||||
for i := 0 to high(series) do
|
||||
begin
|
||||
r.Left := gbounds.Left+round((i+0.1)/length(series)*(gbounds.Right-gBounds.Left));
|
||||
r.Right := gbounds.Left+round((i+0.4)/length(series)*(gbounds.Right-gBounds.Left));
|
||||
r.top := gbounds.Top+round((gbounds.Bottom-gBounds.Top)*(1-series[i].val1/maxVal));
|
||||
r.bottom := gbounds.Bottom;
|
||||
DrawBar(image,r,color1);
|
||||
|
||||
r.Left := gbounds.Left+round((i+0.43)/length(series)*(gbounds.Right-gBounds.Left));
|
||||
r.Right := gbounds.Left+round((i+0.73)/length(series)*(gbounds.Right-gBounds.Left));
|
||||
r.top := gbounds.Top+round((gbounds.Bottom-gBounds.Top)*(1-series[i].val2/maxVal));
|
||||
r.bottom := gbounds.Bottom;
|
||||
DrawBar(image,r,color2);
|
||||
end;
|
||||
|
||||
image.NoClip;
|
||||
barPrecalc.Free;
|
||||
|
||||
//draw chart
|
||||
image.Draw(Canvas,Left,Top,True);
|
||||
|
||||
image.free;
|
||||
end;
|
||||
|
||||
procedure TTest16.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
begin
|
||||
lightTime := lightTime+ElapsedSec*0.2;
|
||||
lightPos1 := pointF((sin(lightTime*0.7+1)+1)/2,(cos(lightTime*0.5+2)+1)/4-0.3);
|
||||
|
||||
chartTime := chartTime+ElapsedSec;
|
||||
if chartTime > 10 then
|
||||
begin
|
||||
chartTime := chartTime-10;
|
||||
NewChart;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
102
bgrabitmap/test/testbgrafunc/utest17.pas
Normal file
102
bgrabitmap/test/testbgrafunc/utest17.pas
Normal file
@@ -0,0 +1,102 @@
|
||||
unit utest17;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Graphics, Classes, SysUtils, utest, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTest17 }
|
||||
|
||||
TTest17 = class(TTest)
|
||||
time: double;
|
||||
dashstyle: TPenStyle;
|
||||
constructor Create;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest17 }
|
||||
|
||||
constructor TTest17.Create;
|
||||
begin
|
||||
Name := 'Line primitives';
|
||||
dashstyle := psSolid;
|
||||
end;
|
||||
|
||||
procedure TTest17.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var
|
||||
image: TBGRABitmap;
|
||||
c : TBGRAPixel;
|
||||
angleofs: single;
|
||||
|
||||
procedure DrawLines(x,y: single; title: string);
|
||||
var
|
||||
penwidth: single;
|
||||
i: Integer;
|
||||
ca,sa: single;
|
||||
begin
|
||||
image.textout(round(x),round(y),title,c);
|
||||
y += image.TextSize(title).cy+10;
|
||||
for i := 1 to 2 do
|
||||
begin
|
||||
ca := cos(sin(angleofs)/2);
|
||||
sa := sin(sin(angleofs)/2);
|
||||
penwidth := i*8+1;
|
||||
image.PenStyle := dashstyle;
|
||||
image.DrawPolyLineAntialias([PointF(x+40,y),PointF(x,y),PointF(x+sa*6*penwidth,y+ca*6*penwidth)],ColorToBGRA(clHighlight),penwidth);
|
||||
if penwidth > 5 then
|
||||
begin
|
||||
image.penStyle := psSolid;
|
||||
image.DrawPolyLineAntialias([PointF(x+40,y),PointF(x,y),PointF(x+sa*6*penwidth,y+ca*6*penwidth)],ColorToBGRA(clHighlightText),1);
|
||||
end;
|
||||
y += penwidth*2+6*penwidth+5;
|
||||
angleofs += Pi*0.6;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
angleofs := time;
|
||||
image := TBGRABitmap.Create(Width,Height,ColorToBGRA(clBtnFace));
|
||||
c := ColorToBGRA(clWindowText);
|
||||
|
||||
image.LineCap := pecFlat;
|
||||
DrawLines(30,20,'Flat cap');
|
||||
image.LineCap := pecSquare;
|
||||
DrawLines(115,Height-200,'Square');
|
||||
image.LineCap := pecRound;
|
||||
DrawLines(190,20,'Round cap');
|
||||
|
||||
image.LineCap := pecFlat;
|
||||
image.JoinStyle := pjsBevel;
|
||||
DrawLines(330,20,'Bevel join');
|
||||
image.JoinStyle := pjsMiter;
|
||||
DrawLines(430,Height-200,'Miter join');
|
||||
image.JoinStyle := pjsRound;
|
||||
DrawLines(530,20,'Round join');
|
||||
|
||||
image.Draw(Canvas,Left,Top,True);
|
||||
image.free;
|
||||
end;
|
||||
|
||||
procedure TTest17.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
var prev5: integer;
|
||||
begin
|
||||
prev5 := trunc(time/5);
|
||||
time := time+0.1;
|
||||
if prev5 <> trunc(time/5) then
|
||||
begin
|
||||
if dashstyle = psDashDotDot then
|
||||
dashstyle := psSolid else
|
||||
dashstyle := succ(dashstyle);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
126
bgrabitmap/test/testbgrafunc/utest18.pas
Normal file
126
bgrabitmap/test/testbgrafunc/utest18.pas
Normal file
@@ -0,0 +1,126 @@
|
||||
unit utest18;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
const
|
||||
nbPoints = 3;
|
||||
|
||||
type
|
||||
{ TTest18 }
|
||||
|
||||
TTest18 = class(TTest)
|
||||
protected
|
||||
virtualScreen,texture,backgroundTile,background: TBGRABitmap;
|
||||
pts: array of TPointF;
|
||||
dirs: array of TPointF;
|
||||
angle: single;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest18 }
|
||||
|
||||
constructor TTest18.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Affine image transformation';
|
||||
texture := TBGRABitmap.Create(ResourceDir+'pac_d1.bmp');
|
||||
texture.ReplaceColor(texture.GetPixel(0,0),BGRAPixelTransparent);
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
randomize;
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
end;
|
||||
|
||||
destructor TTest18.Destroy;
|
||||
begin
|
||||
texture.free;
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
background.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest18.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if pts = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
virtualScreen.PutImage(0,0,background,dmSet);
|
||||
virtualScreen.PutImageAffine(pts[1],pts[0],pts[2],texture);
|
||||
|
||||
virtualScreen.DrawPolyLineAntialias(pts,BGRAWhite,3);
|
||||
virtualScreen.DrawPolyLineAntialias(pts,BGRABlack,1);
|
||||
|
||||
virtualScreen.PutImageAngle(virtualScreen.Width div 2,virtualScreen.Height div 2,texture,angle,texture.Width/2,texture.Height/2);
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest18.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var i: integer;
|
||||
moveFactor: single;
|
||||
begin
|
||||
angle += ElapsedSec*20;
|
||||
if pts = nil then
|
||||
begin
|
||||
setlength(pts,nbPoints);
|
||||
setlength(dirs,nbPoints);
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i] := pointf(random(Width),random(Height));
|
||||
dirs[i] := pointf((random(Width)-width/2)/20,(random(Height)-height/2)/20);
|
||||
end;
|
||||
end;
|
||||
moveFactor := ElapsedSec*20;
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i].x := pts[i].x+dirs[i].x*moveFactor;
|
||||
if pts[i].x < 0 then
|
||||
begin
|
||||
pts[i].x := 0;
|
||||
dirs[i].x := abs(dirs[i].x);
|
||||
end;
|
||||
if pts[i].x > width-1 then
|
||||
begin
|
||||
pts[i].x := width-1;
|
||||
dirs[i].x := -abs(dirs[i].x);
|
||||
end;
|
||||
pts[i].y := pts[i].y+dirs[i].y*moveFactor;
|
||||
if pts[i].y < 0 then
|
||||
begin
|
||||
pts[i].y := 0;
|
||||
dirs[i].y := abs(dirs[i].y);
|
||||
end;
|
||||
if pts[i].y > height-1 then
|
||||
begin
|
||||
pts[i].y := height-1;
|
||||
dirs[i].y := -abs(dirs[i].y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
132
bgrabitmap/test/testbgrafunc/utest19.pas
Normal file
132
bgrabitmap/test/testbgrafunc/utest19.pas
Normal file
@@ -0,0 +1,132 @@
|
||||
unit utest19;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, ucube3d, BGRAGradientScanner;
|
||||
|
||||
type
|
||||
{ TTest19 }
|
||||
|
||||
TTest19 = class(TTest)
|
||||
protected
|
||||
virtualScreen,texture,backgroundTile,background: TBGRABitmap;
|
||||
gradient: TBGRAGradientScanner;
|
||||
scene: TCubeScene3D;
|
||||
|
||||
public
|
||||
constructor Create(TextureInterpolation: boolean; GradientTexture: boolean);
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses utexture, BGRAScene3D;
|
||||
|
||||
{ TTest19 }
|
||||
|
||||
constructor TTest19.Create(TextureInterpolation: boolean; GradientTexture: boolean);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
scene := TCubeScene3D.Create;
|
||||
scene.RenderingOptions.TextureInterpolation := TextureInterpolation;
|
||||
// scene.RenderingOptions.LightingInterpolation := liHighQuality;
|
||||
|
||||
if TextureInterpolation then
|
||||
Name := 'Perspective' else
|
||||
Name := 'Linear and perspective';
|
||||
|
||||
Name += ' texture mapping';
|
||||
|
||||
if gradientTexture then
|
||||
begin
|
||||
name += ' with gradient';
|
||||
gradient := TBGRAGradientScanner.Create(BGRAWhite,BGRABlack,gtRadial,PointF(0.5,0.5),PointF(0.7,0.5),True,True);
|
||||
scene.SetCubeTexture(gradient,1,1);
|
||||
end else
|
||||
begin
|
||||
texture := CreateGreenTexture;
|
||||
if TextureInterpolation then Name += ' with texture interpolation' else
|
||||
Name += ' without texture interpolation';
|
||||
texture.ScanInterpolationFilter := rfHalfCosine;
|
||||
scene.SetCubeTexture(texture);
|
||||
end;
|
||||
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
randomize;
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
end;
|
||||
|
||||
destructor TTest19.Destroy;
|
||||
begin
|
||||
scene.free;
|
||||
gradient.free;
|
||||
texture.free;
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
background.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest19.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
virtualScreen.PutImage(0,0,background,dmSet);
|
||||
|
||||
|
||||
if scene <> nil then
|
||||
begin
|
||||
scene.Surface := virtualScreen;
|
||||
|
||||
if (gradient <> nil) or scene.RenderingOptions.TextureInterpolation then
|
||||
begin
|
||||
scene.Render;
|
||||
end
|
||||
else
|
||||
begin
|
||||
scene.DefaultLightingNormal := lnNone;
|
||||
scene.RenderingOptions.PerspectiveMode := pmLinearMapping;
|
||||
scene.ViewCenter := PointF(virtualScreen.Width/4,virtualScreen.Height/2);
|
||||
scene.Render;
|
||||
scene.RenderingOptions.PerspectiveMode := pmPerspectiveMapping;
|
||||
scene.ViewCenter := PointF(virtualScreen.Width*3/4,virtualScreen.Height/2);
|
||||
scene.Render;
|
||||
end;
|
||||
end;
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest19.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var
|
||||
moveFactor: single;
|
||||
begin
|
||||
moveFactor := ElapsedSec*20;
|
||||
|
||||
with scene.cube.MainPart do
|
||||
begin
|
||||
RotateYRad(0.02*moveFactor);
|
||||
RotateXRad(-0.01*moveFactor);
|
||||
RotateZRad(0.005*moveFactor);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
65
bgrabitmap/test/testbgrafunc/utest2.pas
Normal file
65
bgrabitmap/test/testbgrafunc/utest2.pas
Normal file
@@ -0,0 +1,65 @@
|
||||
unit utest2;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utestpacrect;
|
||||
|
||||
type
|
||||
{ TTest2 }
|
||||
|
||||
TTest2 = class(TTestPacRect)
|
||||
protected
|
||||
virtualScreen: TBitmap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest2 }
|
||||
|
||||
constructor TTest2.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Canvas.Draw(TBitmap) on TBitmap. NOT RECOMMENDED! Non-flickering pacmans walking with a rectangle. Rectangle opacity depends on the standard Canvas rendering capacities on bitmap canvas.';
|
||||
virtualScreen := nil;
|
||||
end;
|
||||
|
||||
destructor TTest2.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest2.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var i: integer;
|
||||
begin
|
||||
if backgroundImg = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBitmap.Create;
|
||||
virtualscreen.width := Width;
|
||||
virtualscreen.Height := height;
|
||||
end;
|
||||
|
||||
//draw background as TBitmap on bitmap Canvas
|
||||
virtualscreen.Canvas.Draw(0,0,backgroundImg.Bitmap);
|
||||
|
||||
//draw sprites as TBitmaps on bitmap Canvas
|
||||
for i := 0 to high(pacLoc) do
|
||||
virtualscreen.Canvas.Draw(pacLoc[i].x,pacLoc[i].y,pacImg[numPacImg].Bitmap);
|
||||
|
||||
//draw virtualscreen as TBitmap
|
||||
Canvas.Draw(Left,Top,virtualscreen);
|
||||
end;
|
||||
|
||||
end.
|
92
bgrabitmap/test/testbgrafunc/utest22.pas
Normal file
92
bgrabitmap/test/testbgrafunc/utest22.pas
Normal file
@@ -0,0 +1,92 @@
|
||||
unit utest22;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utest;
|
||||
|
||||
type
|
||||
{ TTest22 }
|
||||
|
||||
TTest22 = class(TTest)
|
||||
protected
|
||||
virtualScreen,pac: TBGRABitmap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width, Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest22 }
|
||||
|
||||
constructor TTest22.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
randomize;
|
||||
Name := 'Fast clipping (rectangle)';
|
||||
pac := TBGRABitmap.Create(ResourceDir+'pac_d2.bmp');
|
||||
pac.ReplaceColor(pac.GetPixel(0,0),BGRAPixelTransparent);
|
||||
end;
|
||||
|
||||
destructor TTest22.Destroy;
|
||||
begin
|
||||
pac.free;
|
||||
virtualscreen.free;
|
||||
end;
|
||||
|
||||
procedure TTest22.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var c: TBGRAPixel; x1,y1,x2,y2,x3,y3: integer; w: single;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height,BGRABlack);
|
||||
|
||||
virtualscreen.ClipRect := rect(Width div 4,Height div 4, Width*3 div 4, Height*3 div 4);
|
||||
c := BGRA(random(256),random(256),random(256),random(128)+128);
|
||||
x1 := random(width);
|
||||
y1 := random(height);
|
||||
x2 := random(width);
|
||||
y2 := random(height);
|
||||
x3 := random(width);
|
||||
y3 := random(height);
|
||||
w := random(width+height)/500;
|
||||
|
||||
case random(12) of
|
||||
0: virtualscreen.DrawHorizLine(x1,y1,x2,c);
|
||||
1: virtualscreen.SetHorizLine(x1,y1,x2,c);
|
||||
2: virtualscreen.DrawLine(x1,y1,x2,y2,c,True);
|
||||
3: virtualscreen.DrawLineAntialias(x1,y1,x2,y2,c,w);
|
||||
4: virtualscreen.EraseLineAntialias(x1,y1,x2,y2,c.alpha,w);
|
||||
5: if random(2)= 0 then
|
||||
virtualscreen.FillPoly([PointF(x1,y1),PointF(x2,y2),PointF(x3,y3)],c,dmDrawWithTransparency)
|
||||
else virtualscreen.FillPolyAntialias([PointF(x1,y1),PointF(x2,y2),PointF(x3,y3)],c);
|
||||
6: virtualscreen.FillEllipseAntialias(x1,y1,x2-x1,y2-y1,c);
|
||||
7: virtualscreen.Rectangle(x1,y1,x2-x1,y2-y1,c,dmDrawWithTransparency);
|
||||
8: virtualscreen.RoundRectAntialias(x1,y1,x2,y2,abs((x2-x1)/6),abs((y2-y1)/6),c,w);
|
||||
9: virtualscreen.FillRect(x1,y1,x2-x1,y2-y1,c,dmDrawWithTransparency);
|
||||
10: virtualscreen.TextOutAngle(x1,y1,random(3600),'Some text',c,taCenter);
|
||||
11: virtualScreen.PutImage(x1,y1,pac,dmDrawWithTransparency);
|
||||
end;
|
||||
|
||||
virtualscreen.NoClip;
|
||||
virtualscreen.SetPixel(random(width),random(height),c);
|
||||
|
||||
//draw virtualscreen opaque on canvas
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest22.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
begin
|
||||
//nothing
|
||||
end;
|
||||
|
||||
end.
|
||||
|
92
bgrabitmap/test/testbgrafunc/utest23.pas
Normal file
92
bgrabitmap/test/testbgrafunc/utest23.pas
Normal file
@@ -0,0 +1,92 @@
|
||||
unit utest23;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, ucube3d;
|
||||
|
||||
type
|
||||
{ TTest23 }
|
||||
|
||||
TTest23 = class(TTest)
|
||||
protected
|
||||
virtualScreen,backgroundTile,background: TBGRABitmap;
|
||||
scene: TCubeScene3D;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses BGRAScene3D;
|
||||
|
||||
{ TTest23 }
|
||||
|
||||
constructor TTest23.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Multi-polygon antialiasing';
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
scene := TCubeScene3D.Create();
|
||||
scene.RenderingOptions.AntialiasingMode := am3dMultishape;
|
||||
end;
|
||||
|
||||
destructor TTest23.Destroy;
|
||||
begin
|
||||
scene.free;
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
background.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest23.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
virtualScreen.PutImage(0,0,background,dmSet);
|
||||
|
||||
if scene <> nil then
|
||||
begin
|
||||
scene.Surface := virtualScreen;
|
||||
scene.Render;
|
||||
end;
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest23.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var
|
||||
moveFactor: single;
|
||||
begin
|
||||
moveFactor := ElapsedSec*20;
|
||||
|
||||
with scene.cube.MainPart do
|
||||
begin
|
||||
RotateYRad(0.02*moveFactor);
|
||||
RotateXRad(-0.01*moveFactor);
|
||||
RotateZRad(0.005*moveFactor);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
96
bgrabitmap/test/testbgrafunc/utest24.pas
Normal file
96
bgrabitmap/test/testbgrafunc/utest24.pas
Normal file
@@ -0,0 +1,96 @@
|
||||
unit utest24;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, ucube3d;
|
||||
|
||||
type
|
||||
{ TTest24 }
|
||||
|
||||
TTest24 = class(TTest)
|
||||
protected
|
||||
virtualScreen,backgroundTile,texture,background: TBGRABitmap;
|
||||
scene: TCubeScene3D;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses utexture, BGRAScene3D;
|
||||
|
||||
{ TTest24 }
|
||||
|
||||
constructor TTest24.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Multi-polygon antialiasing with perspective mapping';
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
texture := CreateMarbleTexture(256,256);
|
||||
texture.ScanInterpolationFilter:= rfLinear;
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
scene := TCubeScene3D.Create();
|
||||
scene.RenderingOptions.AntialiasingMode := am3dMultishape;
|
||||
scene.SetCubeTexture(texture);
|
||||
end;
|
||||
|
||||
destructor TTest24.Destroy;
|
||||
begin
|
||||
scene.free;
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
background.Free;
|
||||
texture.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest24.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
virtualScreen.PutImage(0,0,background,dmSet);
|
||||
|
||||
if scene <> nil then
|
||||
begin
|
||||
scene.Surface := virtualScreen;
|
||||
scene.Render;
|
||||
end;
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest24.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var
|
||||
moveFactor: single;
|
||||
begin
|
||||
moveFactor := ElapsedSec*20;
|
||||
|
||||
with scene.cube.MainPart do
|
||||
begin
|
||||
RotateYRad(0.02*moveFactor);
|
||||
RotateXRad(-0.01*moveFactor);
|
||||
RotateZRad(0.005*moveFactor);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
167
bgrabitmap/test/testbgrafunc/utest25.pas
Normal file
167
bgrabitmap/test/testbgrafunc/utest25.pas
Normal file
@@ -0,0 +1,167 @@
|
||||
unit utest25;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics, BGRABitmap, BGRABitmapTypes, BGRACanvas, utest;
|
||||
|
||||
type
|
||||
{ TTest25 }
|
||||
|
||||
TTest25 = class(TTest)
|
||||
private
|
||||
pacman,virtualScreen: TBGRABitmap;
|
||||
alphaFactor: byte;
|
||||
time: single;
|
||||
pts: array of TPoint;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
procedure DrawOnCanvas(Canvas: TBGRACanvas);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses BGRAGradientScanner;
|
||||
|
||||
{ TTest25 }
|
||||
|
||||
constructor TTest25.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'BGRACanvas test (with aliasing on the left, with anti-aliasing on the right)';
|
||||
virtualScreen := nil;
|
||||
pacman := TBGRABitmap.Create(ResourceDir+'pac_d1.bmp');
|
||||
pacman.ReplaceColor(pacman.GetPixel(0,0),BGRAPixelTransparent);
|
||||
time := 0;
|
||||
end;
|
||||
|
||||
destructor TTest25.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
pacman.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest25.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
tx: integer;
|
||||
begin
|
||||
if time=0 then exit;
|
||||
|
||||
tx := (Width+1) div 2;
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> tx) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(tx,Height);
|
||||
//randseed := 1;
|
||||
setlength(pts, 20);
|
||||
for i := 0 to high(pts) do
|
||||
pts[i] := Point(Random(virtualScreen.Width),random(virtualScreen.Height));
|
||||
end;
|
||||
|
||||
virtualScreen.CanvasBGRA.AntialiasingMode := amOff;
|
||||
virtualScreen.CanvasBGRA.Font.Quality := fqSystem;
|
||||
DrawOnCanvas(virtualScreen.CanvasBGRA);
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
|
||||
virtualScreen.CanvasBGRA.AntialiasingMode := amOn;
|
||||
virtualScreen.CanvasBGRA.Font.Quality := fqFineClearTypeRGB;
|
||||
DrawOnCanvas(virtualScreen.CanvasBGRA);
|
||||
virtualscreen.Draw(Canvas,Left+Width div 2,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest25.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec;
|
||||
alphaFactor := round((sin(time)+1)/2*255);
|
||||
end;
|
||||
|
||||
procedure TTest25.DrawOnCanvas(Canvas: TBGRACanvas);
|
||||
var i,k: integer;
|
||||
grad: TBGRAGradientScanner;
|
||||
begin
|
||||
for k := 1 to 1 do
|
||||
begin
|
||||
grad := TBGRAGradientScanner.Create(BGRA(0,150,255),BGRA(0,0,0),gtLinear,PointF(0,0),PointF(0,Canvas.Height/40),True,True);
|
||||
With Canvas do
|
||||
begin
|
||||
Brush.style := bsSolid;
|
||||
Brush.Color := clWhite;
|
||||
Brush.Opacity := 255;
|
||||
FillRect(0,0,Width,Height);
|
||||
|
||||
Font.Orientation := 0;
|
||||
Font.Color := clBlack;
|
||||
Font.Height := Height div 20;
|
||||
Font.Texture := grad;
|
||||
TextOut(Font.Height div 2,0,'Font rendering');
|
||||
|
||||
Font.Orientation := -450;
|
||||
TextOut(Font.Height,Font.Height,'Text angle');
|
||||
|
||||
pen.width := 2;
|
||||
pen.opacity := 255;
|
||||
Brush.Color := clGreen;
|
||||
brush.Style := bsSolid;
|
||||
pen.Style := psDash;
|
||||
Ellipse(pts[6].x,pts[6].y,pts[7].x,pts[7].y);
|
||||
|
||||
pen.Style := psSolid;
|
||||
pen.width := 1;
|
||||
pen.opacity := 255;
|
||||
Brush.BGRAColor := BGRA(255,128,0);
|
||||
brush.style := bsFDiagonal;
|
||||
Ellipse(pts[14].x,pts[14].y,pts[15].x,pts[15].y);
|
||||
|
||||
pen.style := psClear;
|
||||
pen.opacity := 64;
|
||||
Brush.Color := clBlue;
|
||||
Brush.Opacity := 128;
|
||||
brush.style := bsCross;
|
||||
Rectangle(pts[8].x,pts[8].y,pts[9].x,pts[9].y);
|
||||
|
||||
pen.Style := psSolid;
|
||||
pen.width := 1;
|
||||
pen.opacity := 128;
|
||||
Brush.Color := clRed;
|
||||
Brush.Opacity := 64;
|
||||
brush.Style := bsSolid;
|
||||
RoundRect(pts[10].x,pts[10].y,pts[11].x,pts[11].y,abs(pts[11].x-pts[10].x) div 2,abs(pts[11].y-pts[10].y) div 2);
|
||||
|
||||
brush.style := bsClear;
|
||||
pen.width := 2;
|
||||
RoundRect(pts[16].x,pts[16].y,pts[17].x,pts[17].y,abs(pts[17].x-pts[16].x) div 2,abs(pts[17].y-pts[16].y) div 2);
|
||||
|
||||
pen.style := psClear;
|
||||
Brush.Color := clBlue;
|
||||
Brush.Opacity := 192;
|
||||
brush.style := bsSolid;
|
||||
//Polygon(pts);
|
||||
Pie(pts[12].x,pts[12].y,pts[13].x,pts[13].y,pts[6].x,pts[6].y,pts[7].x,pts[7].y);
|
||||
|
||||
Pen.Color := clBlack;
|
||||
pen.style := psSolid;
|
||||
pen.opacity := 128;
|
||||
MoveTo(pts[0]);
|
||||
for i := 0 to 5 do
|
||||
begin
|
||||
Pen.Width := i+1;
|
||||
LineTo(pts[i+1]);
|
||||
end;
|
||||
|
||||
Font.Texture := nil;
|
||||
end;
|
||||
Grad.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
111
bgrabitmap/test/testbgrafunc/utest26.pas
Normal file
111
bgrabitmap/test/testbgrafunc/utest26.pas
Normal file
@@ -0,0 +1,111 @@
|
||||
unit utest26;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
const
|
||||
nbPoints = 9;
|
||||
|
||||
type
|
||||
{ TTest26 }
|
||||
|
||||
TTest26 = class(TTest)
|
||||
protected
|
||||
virtualScreen,backgroundTile: TBGRABitmap;
|
||||
pts: array of TPointF;
|
||||
dirs: array of TPointF;
|
||||
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest26 }
|
||||
|
||||
constructor TTest26.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Gradient shapes (antialiased or not)';
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
randomize;
|
||||
virtualScreen := nil;
|
||||
end;
|
||||
|
||||
destructor TTest26.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest26.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if pts = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
virtualScreen.Fill(backgroundTile);
|
||||
|
||||
virtualScreen.FillQuadLinearColor(pts[3],pts[4],pts[5],pts[6],BGRA(0,192,0),BGRA(0,128,255),BGRA(255,128,0),BGRA(255,255,255));
|
||||
virtualScreen.FillTriangleLinearColorAntialias(pts[0],pts[1],pts[2],BGRA(255,0,0),BGRA(255,255,0),BGRA(255,0,255));
|
||||
virtualScreen.FillEllipseLinearColorAntialias(pts[7].x,pts[7].y,pts[8].x/4,pts[8].y/4,BGRABlack,BGRAWhite);
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest26.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var i: integer;
|
||||
moveFactor: single;
|
||||
begin
|
||||
if pts = nil then
|
||||
begin
|
||||
setlength(pts,nbPoints);
|
||||
setlength(dirs,nbPoints);
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i] := pointf(random(Width),random(Height));
|
||||
dirs[i] := pointf((random(Width)-width/2)/20,(random(Height)-height/2)/20);
|
||||
end;
|
||||
end;
|
||||
moveFactor := ElapsedSec*20;
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i].x := pts[i].x+dirs[i].x*moveFactor;
|
||||
if pts[i].x < 0 then
|
||||
begin
|
||||
pts[i].x := 0;
|
||||
dirs[i].x := abs(dirs[i].x);
|
||||
end;
|
||||
if pts[i].x > width-1 then
|
||||
begin
|
||||
pts[i].x := width-1;
|
||||
dirs[i].x := -abs(dirs[i].x);
|
||||
end;
|
||||
pts[i].y := pts[i].y+dirs[i].y*moveFactor;
|
||||
if pts[i].y < 0 then
|
||||
begin
|
||||
pts[i].y := 0;
|
||||
dirs[i].y := abs(dirs[i].y);
|
||||
end;
|
||||
if pts[i].y > height-1 then
|
||||
begin
|
||||
pts[i].y := height-1;
|
||||
dirs[i].y := -abs(dirs[i].y);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
97
bgrabitmap/test/testbgrafunc/utest27.pas
Normal file
97
bgrabitmap/test/testbgrafunc/utest27.pas
Normal file
@@ -0,0 +1,97 @@
|
||||
unit utest27;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, BGRAScene3D, utore3d;
|
||||
|
||||
type
|
||||
{ TTest27 }
|
||||
|
||||
TTest27 = class(TTest)
|
||||
protected
|
||||
virtualScreen,backgroundTile,background: TBGRABitmap;
|
||||
scene: TToreScene3D;
|
||||
public
|
||||
constructor Create(lightNormal: TLightingNormal3D; lightInterp: TLightingInterpolation3D);
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest27 }
|
||||
|
||||
constructor TTest27.Create(lightNormal: TLightingNormal3D; lightInterp: TLightingInterpolation3D);
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Torus with ';
|
||||
case lightNormal of
|
||||
lnFace: Name += 'flat';
|
||||
lnVertex: Name += 'vertex';
|
||||
lnFaceVertexMix: Name += 'half-vertex';
|
||||
lnNone: Name += 'no lighting';
|
||||
end;
|
||||
if lightNormal <> lnNone then
|
||||
case lightInterp of
|
||||
liLowQuality: if lightNormal <> lnFace then Name += ' low-quality shading'
|
||||
else Name += ' shading';
|
||||
liAlwaysHighQuality: Name += ' high-quality shading';
|
||||
end;
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
scene := TToreScene3D.Create();
|
||||
scene.RenderingOptions.AntialiasingMode := am3dNone;
|
||||
scene.RenderingOptions.LightingInterpolation := lightInterp;
|
||||
scene.DefaultLightingNormal:= lightNormal;
|
||||
end;
|
||||
|
||||
destructor TTest27.Destroy;
|
||||
begin
|
||||
scene.free;
|
||||
virtualScreen.Free;
|
||||
backgroundTile.Free;
|
||||
background.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest27.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
virtualScreen.PutImage(0,0,background,dmSet);
|
||||
|
||||
if scene <> nil then
|
||||
begin
|
||||
scene.Surface := virtualScreen;
|
||||
scene.Render;
|
||||
end;
|
||||
|
||||
virtualScreen.draw(Canvas,Left,Top);
|
||||
end;
|
||||
|
||||
procedure TTest27.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var
|
||||
moveFactor: single;
|
||||
begin
|
||||
moveFactor := ElapsedSec*20;
|
||||
scene.angle := scene.angle + moveFactor;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
43
bgrabitmap/test/testbgrafunc/utest3.pas
Normal file
43
bgrabitmap/test/testbgrafunc/utest3.pas
Normal file
@@ -0,0 +1,43 @@
|
||||
unit utest3;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utestpacrect;
|
||||
|
||||
type
|
||||
{ TTest3 }
|
||||
|
||||
TTest3 = class(TTestPacRect)
|
||||
public
|
||||
constructor Create;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest3 }
|
||||
|
||||
constructor TTest3.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'TBGRABitmap.Draw(Form). You should see flickering Pacmans walking on the form with a rectangle. The opacity of the rectangle depends on the rendering capacities of BGRABitmap on windows.';
|
||||
end;
|
||||
|
||||
procedure TTest3.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var i: integer;
|
||||
begin
|
||||
if backgroundImg = nil then exit;
|
||||
|
||||
//draw background opaque on canvas
|
||||
backgroundImg.Draw(Canvas,Left,Top,True);
|
||||
|
||||
//draw sprites transparent on canvas
|
||||
for i := 0 to high(pacLoc) do
|
||||
pacImg[numPacImg].Draw(Canvas,Left+pacLoc[i].x,Top+pacLoc[i].y,false);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
221
bgrabitmap/test/testbgrafunc/utest31.pas
Normal file
221
bgrabitmap/test/testbgrafunc/utest31.pas
Normal file
@@ -0,0 +1,221 @@
|
||||
unit utest31;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, BGRAGradients,
|
||||
BGRATextFX;
|
||||
|
||||
const
|
||||
nbPoints=3;
|
||||
|
||||
type
|
||||
|
||||
{ TTest31 }
|
||||
|
||||
TTest31 = class(TTest)
|
||||
virtualScreen: TBGRABitmap;
|
||||
pts: array of TPointF;
|
||||
dirs: array of TPointF;
|
||||
hsla1,hsla2: THSLAPixel;
|
||||
|
||||
textfx: TBGRATextEffect;
|
||||
phong: TPhongShading;
|
||||
wood: TBGRABitmap;
|
||||
|
||||
textfx_multi: TBGRATextEffect;
|
||||
colorArray: array of TBGRAPixel;
|
||||
colorTime: double;
|
||||
|
||||
textfx_lightpos: TBGRATextEffect;
|
||||
time: double;
|
||||
lightPos1: TPointF;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer); override;
|
||||
procedure OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses utexture;
|
||||
|
||||
{ TTest31 }
|
||||
|
||||
constructor TTest31.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Gradient and text effect';
|
||||
virtualScreen := nil;
|
||||
hsla1.alpha := $ffff;
|
||||
hsla1.hue := 0;
|
||||
hsla1.lightness := $8000;
|
||||
hsla1.saturation := $C000;
|
||||
hsla2 := hsla1;
|
||||
hsla2.hue := $2000;
|
||||
|
||||
phong := TPhongShading.Create;
|
||||
phong.LightPositionZ := 128;
|
||||
phong.SpecularIndex := 10;
|
||||
phong.SpecularFactor := 0.6;
|
||||
phong.LightSourceIntensity := 300;
|
||||
phong.AmbientFactor := 0.45;
|
||||
phong.NegativeDiffusionFactor := 0.3;
|
||||
|
||||
setlength(colorArray,6);
|
||||
colorArray[0] := BGRA(255,128,128);
|
||||
colorArray[1] := BGRA(255,160,0);
|
||||
colorArray[2] := BGRA(255,255,0);
|
||||
colorArray[3] := BGRA(160,255,0);
|
||||
colorArray[4] := BGRA(0,255,160);
|
||||
colorArray[5] := BGRA(128,128,255);
|
||||
end;
|
||||
|
||||
destructor TTest31.Destroy;
|
||||
begin
|
||||
phong.free;
|
||||
textfx.Free;
|
||||
textfx_lightpos.Free;
|
||||
textfx_multi.Free;
|
||||
wood.free;
|
||||
virtualScreen.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest31.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var font: TFont; h, r: integer;
|
||||
begin
|
||||
if pts = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(textfx);
|
||||
FreeAndNil(textfx_lightpos);
|
||||
FreeAndNil(textfx_multi);
|
||||
FreeAndNil(wood);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
if wood = nil then
|
||||
begin
|
||||
r := round(sqrt(Width*Height)/4);
|
||||
if r < 64 then r:= 64;
|
||||
wood := CreateWoodTexture(r,r);
|
||||
end;
|
||||
|
||||
font := TFont.Create;
|
||||
font.Name := 'Arial';
|
||||
if textfx = nil then
|
||||
begin
|
||||
font.Bold := true;
|
||||
font.Height := Height div 4;
|
||||
textfx := TBGRATextEffect.Create('BGRA text effect',font,True);
|
||||
font.Bold := false;
|
||||
end;
|
||||
if textfx_lightpos = nil then
|
||||
begin
|
||||
font.Height := Height div 20;
|
||||
textfx_lightpos := TBGRATextEffect.Create('Light position',font,True);
|
||||
end;
|
||||
if textfx_multi = nil then
|
||||
begin
|
||||
font.Height := Height div 12;
|
||||
font.Name := 'Lucida Console';
|
||||
font.Bold := true;
|
||||
textfx_multi := TBGRATextEffect.Create('Multicolor',font,True);
|
||||
end;
|
||||
font.Free;
|
||||
|
||||
virtualScreen.GradientFill(0,0,Width,Height,HSLAToBGRA(hsla1),HSLAToBGRA(hsla2),gtLinear,pts[0],pts[1],dmSet);
|
||||
|
||||
phong.LightPositionF := PointF(lightPos1.x * Width, lightPos1.y * Height);
|
||||
h := round(textfx.Height *0.07);
|
||||
phong.LightPositionZ := h*4;
|
||||
textfx.DrawShaded(virtualScreen,Width div 2,Height div 2-textfx.Height div 2, phong, h,wood, taCenter, True);
|
||||
|
||||
r := textfx_lightpos.height div 8;
|
||||
textfx_lightpos.DrawShadow(virtualScreen, phong.LightPosition.X+2*r,phong.LightPosition.Y+8+2*r,r,BGRABlack,taCenter);
|
||||
textfx_lightpos.DrawOutline(virtualScreen, phong.LightPosition.X,phong.LightPosition.Y+8,BGRABlack,taCenter);
|
||||
textfx_lightpos.Draw(virtualScreen, phong.LightPosition.X,phong.LightPosition.Y+8,BGRAWhite,taCenter);
|
||||
virtualscreen.FillEllipseLinearColorAntialias(phong.LightPosition.X,phong.LightPosition.Y,4,4,BGRABlack,BGRAWhite);
|
||||
|
||||
textfx_multi.DrawShadow(virtualScreen, round(pts[2].x),round(pts[2].y), round(textfx_multi.Height/8), BGRA(255,255,255,255),taCenter);
|
||||
textfx_multi.DrawMulticolored(virtualScreen, round(pts[2].x),round(pts[2].y), colorArray,taCenter);
|
||||
|
||||
//draw virtualscreen opaque on canvas
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest31.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
var i: integer;
|
||||
moveFactor: single;
|
||||
c,c2: TBGRAPixel;
|
||||
begin
|
||||
if pts = nil then
|
||||
begin
|
||||
setlength(pts,nbPoints);
|
||||
setlength(dirs,nbPoints);
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i] := pointf(random(Width),random(Height));
|
||||
dirs[i] := pointf((random(Width)-width/2)/20,(random(Height)-height/2)/20);
|
||||
end;
|
||||
dirs[2].x /= 10;
|
||||
dirs[2].y /= 10;
|
||||
end;
|
||||
moveFactor := ElapsedSec*20;
|
||||
for i := 0 to NbPoints-1 do
|
||||
begin
|
||||
pts[i].x := pts[i].x+dirs[i].x*moveFactor;
|
||||
if pts[i].x < 0 then
|
||||
begin
|
||||
pts[i].x := 0;
|
||||
dirs[i].x := abs(dirs[i].x);
|
||||
end;
|
||||
if pts[i].x > width-1 then
|
||||
begin
|
||||
pts[i].x := width-1;
|
||||
dirs[i].x := -abs(dirs[i].x);
|
||||
end;
|
||||
pts[i].y := pts[i].y+dirs[i].y*moveFactor;
|
||||
if pts[i].y < 0 then
|
||||
begin
|
||||
pts[i].y := 0;
|
||||
dirs[i].y := abs(dirs[i].y);
|
||||
end;
|
||||
if pts[i].y > height-1 then
|
||||
begin
|
||||
pts[i].y := height-1;
|
||||
dirs[i].y := -abs(dirs[i].y);
|
||||
end;
|
||||
end;
|
||||
inc(hsla1.hue, round(moveFactor*40) );
|
||||
inc(hsla2.hue, round(moveFactor*40) );
|
||||
|
||||
time := time+ElapsedSec;
|
||||
lightPos1 := pointF((sin(time*0.7+1)+1)/4+0.4,(cos(time*0.5+2)+1)/4+0.3);
|
||||
|
||||
colorTime += ElapsedSec;
|
||||
if colorTime > 0.3 then
|
||||
begin
|
||||
colorTime -= 0.3;
|
||||
c := colorArray[high(colorArray)];
|
||||
for i := 0 to high(colorArray) do
|
||||
begin
|
||||
c2 := colorArray[i];
|
||||
colorArray[i]:= c;
|
||||
c:= c2;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
158
bgrabitmap/test/testbgrafunc/utest32.pas
Normal file
158
bgrabitmap/test/testbgrafunc/utest32.pas
Normal file
@@ -0,0 +1,158 @@
|
||||
unit utest32;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTest32 }
|
||||
|
||||
TTest32 = class(TTest)
|
||||
virtualScreen,background: TBGRABitmap;
|
||||
position,speed,direction: single;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure DrawRings(ABitmap: TBGRABitmap; APath: IBGRAPath; ACount: integer; ARadius: single);
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer); override;
|
||||
procedure OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses BGRAPath, BGRAVectorize, BGRAGradientScanner, BGRAUTF8;
|
||||
|
||||
{ TTest32 }
|
||||
|
||||
constructor TTest32.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Curved text';
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
position := 0;
|
||||
speed := 0;
|
||||
direction := 1;
|
||||
end;
|
||||
|
||||
destructor TTest32.Destroy;
|
||||
begin
|
||||
virtualscreen.free;
|
||||
background.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest32.DrawRings(ABitmap: TBGRABitmap;
|
||||
APath: IBGRAPath; ACount: integer; ARadius: single);
|
||||
var
|
||||
step: single;
|
||||
cursor: TBGRACustomPathCursor;
|
||||
begin
|
||||
cursor := APath.getCursor;
|
||||
step := cursor.PathLength/ACount;
|
||||
cursor.Position:= 0;
|
||||
repeat
|
||||
with cursor.CurrentCoordinate do
|
||||
ABitmap.FillEllipseAntialias(x,y, ARadius,ARadius, CSSDarkSlateBlue);
|
||||
until cursor.MoveForward(step) < 0.5*step;
|
||||
cursor.Free;
|
||||
end;
|
||||
|
||||
procedure TTest32.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var path1: TBGRAPath;
|
||||
cursor1: TBGRAPathCursor;
|
||||
size: single;
|
||||
|
||||
procedure PrepareBackground;
|
||||
var
|
||||
path2: TBGRAPath;
|
||||
gradient: TBGRAGradientScanner;
|
||||
fontRenderer: TBGRAVectorizedFontRenderer;
|
||||
begin
|
||||
background := TBGRABitmap.Create(Width,Height,CSSLightSteelBlue);
|
||||
fontRenderer := TBGRAVectorizedFontRenderer.Create;
|
||||
background.FontRenderer := fontRenderer;
|
||||
background.FontHeight := round(size*0.09);
|
||||
background.FontQuality := fqFineAntialiasing;
|
||||
|
||||
DrawRings(background, path1, 20, size/150);
|
||||
|
||||
path2 := TBGRAPath.Create;
|
||||
path2.arc(width/2,height/2,size*0.4, Pi, 0, true);
|
||||
|
||||
fontRenderer.OutlineColor := BGRABlack;
|
||||
fontRenderer.OutlineWidth := size/600;
|
||||
fontRenderer.OutlineVisible := true;
|
||||
background.FontVerticalAnchor := fvaBaseline;
|
||||
|
||||
gradient := TBGRAGradientScanner.Create(CSSYellow, CSSOrange, gtLinear, PointF(0,height/2), PointF(0,height/2+size*0.5));
|
||||
background.TextOutCurved(path2, ' Left ...', gradient, taLeftJustify, 0);
|
||||
background.TextOutCurved(path2, 'Middle', gradient, taCenter, 0);
|
||||
background.TextOutCurved(path2, '... Right ', gradient, taRightJustify, 0);
|
||||
gradient.free;
|
||||
|
||||
fontRenderer.OutlineVisible := false;
|
||||
background.FontVerticalAnchor := fvaTop;
|
||||
|
||||
path2.Free;
|
||||
end;
|
||||
|
||||
var
|
||||
fontRenderer: TBGRAVectorizedFontRenderer;
|
||||
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
if width < height then size := width else size := height;
|
||||
path1 := TBGRAPath.Create;
|
||||
path1.arc(width/2,height/2,size*0.4, Pi, 0);
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
PrepareBackground;
|
||||
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
fontRenderer := TBGRAVectorizedFontRenderer.Create;
|
||||
virtualScreen.FontRenderer := fontRenderer;
|
||||
end else
|
||||
fontRenderer := virtualScreen.FontRenderer as TBGRAVectorizedFontRenderer;
|
||||
|
||||
virtualScreen.PutImage(0,0, background, dmSet);
|
||||
virtualScreen.FontHeight := background.FontHeight;
|
||||
virtualScreen.FontQuality := background.FontQuality;
|
||||
|
||||
cursor1 := path1.CreateCursor;
|
||||
speed := size/4/cursor1.PathLength;
|
||||
if position < 0 then
|
||||
begin
|
||||
position := 0;
|
||||
direction := 1;
|
||||
end;
|
||||
cursor1.Position := position*cursor1.PathLength;
|
||||
virtualScreen.TextOutCurved(cursor1, 'Curved text '+UTF8_ARABIC_LAM+UTF8_ARABIC_ALEPH, BGRABlack, taLeftJustify, virtualScreen.FontFullHeight/8);
|
||||
if cursor1.Position = cursor1.PathLength then direction := -1;
|
||||
cursor1.Free;
|
||||
|
||||
path1.Free;
|
||||
|
||||
//draw virtualscreen opaque on canvas
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest32.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
begin
|
||||
position += ElapsedSec*speed*direction;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
86
bgrabitmap/test/testbgrafunc/utest33.pas
Normal file
86
bgrabitmap/test/testbgrafunc/utest33.pas
Normal file
@@ -0,0 +1,86 @@
|
||||
unit utest33;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TTest33 }
|
||||
|
||||
TTest33 = class(TTest)
|
||||
virtualScreen: TBGRABitmap;
|
||||
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer); override;
|
||||
procedure OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest33 }
|
||||
|
||||
constructor TTest33.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Text vertical anchor';
|
||||
virtualScreen := nil;
|
||||
end;
|
||||
|
||||
destructor TTest33.Destroy;
|
||||
begin
|
||||
virtualscreen.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest33.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
const
|
||||
FontVerticalAnchorToStr: array[TFontVerticalAnchor] of string
|
||||
= ('Top of the font with space for Âccents', 'Center of the font', 'Top of the UPPÊRCASE letters',
|
||||
'Center of the UPPERCASE letters', 'Top of x and other small letters',
|
||||
'Center of x and other small letters', 'Baseline of the text',
|
||||
'Descent line for g q, etc.', 'Bottom of the font including bottom line spacing');
|
||||
var y,h: integer;
|
||||
textanchor: TFontVerticalAnchor;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
virtualScreen.Fill(CSSLightSteelBlue);
|
||||
virtualScreen.FontName := 'Times New Roman';
|
||||
h := Height div 20;
|
||||
virtualScreen.FontHeight := h;
|
||||
|
||||
y := 0;
|
||||
textanchor:= low(TFontVerticalAnchor);
|
||||
|
||||
repeat
|
||||
y += h;
|
||||
virtualScreen.HorizLine(0,y,virtualScreen.Width,BGRA(255,255,255),dmDrawWithTransparency);
|
||||
virtualScreen.FontVerticalAnchor := textanchor;
|
||||
virtualScreen.TextOut(virtualScreen.Width/2,y, FontVerticalAnchorToStr[textanchor], BGRABlack, taCenter, h/3);
|
||||
y += h;
|
||||
if textanchor >= high(TFontVerticalAnchor) then break;
|
||||
textanchor:= succ(textanchor);
|
||||
until false;
|
||||
|
||||
//draw virtualscreen opaque on canvas
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest33.OnTimer(Width, Height: Integer;
|
||||
ElapsedSec: Double);
|
||||
begin
|
||||
//nothing
|
||||
end;
|
||||
|
||||
end.
|
||||
|
65
bgrabitmap/test/testbgrafunc/utest4.pas
Normal file
65
bgrabitmap/test/testbgrafunc/utest4.pas
Normal file
@@ -0,0 +1,65 @@
|
||||
unit utest4;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utestpacrect;
|
||||
|
||||
type
|
||||
{ TTest4 }
|
||||
|
||||
TTest4 = class(TTestPacRect)
|
||||
protected
|
||||
virtualScreen: TBitmap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest4 }
|
||||
|
||||
constructor TTest4.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'TBGRABitmap.Draw(Bitmap). Non-flickering pacmans walking with a rectangle. Rectangle opacity depends on the rendering capacities of BGRABitmap on TBitmap.';
|
||||
virtualScreen := nil;
|
||||
end;
|
||||
|
||||
destructor TTest4.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest4.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var i: integer;
|
||||
begin
|
||||
if backgroundImg = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBitmap.Create;
|
||||
virtualscreen.width := Width;
|
||||
virtualscreen.Height := height;
|
||||
end;
|
||||
|
||||
//draw background opaque on bitmap canvas
|
||||
backgroundImg.Draw(virtualScreen.Canvas,0,0,true);
|
||||
|
||||
//draw sprites transparent on bitmap canvas
|
||||
for i := 0 to high(pacLoc) do
|
||||
pacImg[numPacImg].Draw(virtualscreen.Canvas,pacLoc[i].x,pacLoc[i].y,false);
|
||||
|
||||
//draw virtualscreen as TBitmap
|
||||
Canvas.Draw(Left,Top,VirtualScreen);
|
||||
end;
|
||||
|
||||
end.
|
68
bgrabitmap/test/testbgrafunc/utest5.pas
Normal file
68
bgrabitmap/test/testbgrafunc/utest5.pas
Normal file
@@ -0,0 +1,68 @@
|
||||
unit utest5;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utestpacrect;
|
||||
|
||||
type
|
||||
{ TTest5 }
|
||||
|
||||
TTest5 = class(TTestPacRect)
|
||||
protected
|
||||
virtualScreen: TBGRABitmap;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest5 }
|
||||
|
||||
constructor TTest5.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'TBGRABitmap.PutImage. This is the recommended way. Non-flickering pacmans walking with a rectangle. Rectangle opacity always there with the rendering capacities on BGRABitmap.';
|
||||
virtualScreen := nil;
|
||||
end;
|
||||
|
||||
destructor TTest5.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest5.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var i: integer;
|
||||
begin
|
||||
if backgroundImg = nil then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
//draw background opaque in BGRA bitmap
|
||||
virtualscreen.PutImage(0,0,backgroundImg,dmSet);
|
||||
end;
|
||||
|
||||
//draw sprites transparent in BGRA bitmap
|
||||
for i := 0 to high(pacLoc) do
|
||||
virtualscreen.PutImage(pacLoc[i].x,pacLoc[i].y,pacImg[numPacImg],dmDrawWithTransparency);
|
||||
|
||||
//draw virtualscreen opaque on canvas
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
|
||||
//erase sprites
|
||||
for i := 0 to high(pacLoc) do
|
||||
virtualscreen.FillRect(RectWithSize(pacLoc[i].x,pacLoc[i].y,
|
||||
pacImg[numPacImg].Width,pacImg[numPacImg].Height),
|
||||
backgroundImg,dmSet);
|
||||
end;
|
||||
|
||||
end.
|
86
bgrabitmap/test/testbgrafunc/utest6.pas
Normal file
86
bgrabitmap/test/testbgrafunc/utest6.pas
Normal file
@@ -0,0 +1,86 @@
|
||||
unit utest6;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utestback, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
{ TTest6 }
|
||||
|
||||
TTest6 = class(TTestBack)
|
||||
protected
|
||||
image,virtualScreen: TBGRABitmap;
|
||||
zoomFactor: single;
|
||||
time: single;
|
||||
procedure DrawImage(x,y: integer; pzoomfactor: single; mode : TResampleMode);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses utest;
|
||||
|
||||
{ TTest6 }
|
||||
|
||||
procedure TTest6.DrawImage(x, y: integer; pzoomfactor: single; mode : TResampleMode);
|
||||
var temp: TBGRABitmap;
|
||||
width,height: integer;
|
||||
begin
|
||||
if pzoomfactor = 0 then exit;
|
||||
width := (round(image.width*pzoomfactor)+1) and not 1; //even size for centering
|
||||
if width <= 0 then width := 1;
|
||||
height := (round(image.height*pzoomfactor)+1) and not 1; //even size for centering
|
||||
if height <= 0 then height := 1;
|
||||
temp := image.Resample(width,height,mode);
|
||||
virtualScreen.PutImage(x-width div 2,y-height div 2,temp,dmDrawWithTransparency);
|
||||
temp.Free;
|
||||
end;
|
||||
|
||||
constructor TTest6.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Simple stretch vs fine resample';
|
||||
virtualScreen := nil;
|
||||
image := TBGRABitmap.Create(ResourceDir+'resampletest.png');
|
||||
time := Pi/4;
|
||||
end;
|
||||
|
||||
destructor TTest6.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
image.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest6.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
begin
|
||||
UpdateBackground(Width,Height);
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
FreeAndNil(virtualScreen);
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
virtualscreen.PutImage(0,0,backgroundImg,dmSet);
|
||||
DrawImage(virtualScreen.Width div 4,virtualScreen.Height div 2, zoomFactor, rmSimpleStretch);
|
||||
image.ResampleFilter := rfHalfCosine;
|
||||
DrawImage(3*virtualScreen.Width div 4,virtualScreen.Height div 2, zoomFactor, rmFineResample);
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest6.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec*0.5;
|
||||
zoomFactor := (sin(time)+1)*Height/image.Height/2;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
125
bgrabitmap/test/testbgrafunc/utest7.pas
Normal file
125
bgrabitmap/test/testbgrafunc/utest7.pas
Normal file
@@ -0,0 +1,125 @@
|
||||
unit utest7;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
BGRAClasses, SysUtils, utest, Graphics, BGRABitmap, BGRABitmapTypes, BGRAGradientScanner;
|
||||
|
||||
type
|
||||
{ TTest7 }
|
||||
|
||||
TTest7 = class(TTest)
|
||||
protected
|
||||
pacman,virtualScreen,background: TBGRABitmap;
|
||||
time: single;
|
||||
multigrad: TBGRACustomGradient;
|
||||
pixels: array of record
|
||||
x,y,dx,dy: single;
|
||||
end;
|
||||
procedure DrawPacman(x,y: integer; angle: single);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer({%H-}Width,{%H-}Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTest7 }
|
||||
|
||||
procedure TTest7.DrawPacman(x, y: integer; angle: single);
|
||||
var temp: TBGRABitmap;
|
||||
begin
|
||||
temp := pacman.FilterRotate(pointF((pacman.width-1)/2,(pacman.height-1)/2),angle);
|
||||
virtualScreen.PutImage(x-temp.width div 2,y-temp.height div 2,temp,dmDrawWithTransparency);
|
||||
temp.Free;
|
||||
end;
|
||||
|
||||
constructor TTest7.Create;
|
||||
var temp: TBGRABitmap;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Smart zoom x3 and rotate';
|
||||
virtualScreen := nil;
|
||||
background := nil;
|
||||
pacman := TBGRABitmap.Create(ResourceDir+'pac_d1.bmp');
|
||||
pacman.ReplaceColor(pacman.GetPixel(0,0),BGRAPixelTransparent);
|
||||
temp := pacman.FilterSmartZoom3(moMediumSmooth);
|
||||
pacman.Free;
|
||||
pacman := temp;
|
||||
time := 0;
|
||||
multigrad := TBGRAHueGradient.Create(0,0,65535,40000,[hgoRepeat,hgoPositiveDirection,hgoLightnessCorrection]);
|
||||
end;
|
||||
|
||||
destructor TTest7.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
pacman.free;
|
||||
multigrad.Free;
|
||||
background.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest7.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var
|
||||
i: Integer;
|
||||
smallW,smallH: integer;
|
||||
pixBmp: TBGRABitmap;
|
||||
begin
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(background);
|
||||
end;
|
||||
|
||||
smallW := (Width+4) div 8;
|
||||
smallH := (Height+4) div 8;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
background := TBGRABitmap.Create(Width,Height);
|
||||
background.GradientFill(0,0,Width,Height,multigrad,gtRadial,PointF(0,0),PointF(Width/2,Height/2),dmSet,False);
|
||||
|
||||
setlength(pixels, round(sqrt(smallW*smallH)) );
|
||||
for i := 0 to high(pixels) do
|
||||
begin
|
||||
pixels[i].x := random(smallW);
|
||||
pixels[i].y := random(smallH);
|
||||
pixels[i].dx := (random(1001)-500)/500;
|
||||
pixels[i].dy := (random(1001)-500)/500;
|
||||
end;
|
||||
end;
|
||||
|
||||
virtualscreen.PutImage(0,0,background,dmSet);
|
||||
|
||||
pixBmp := TBGRABitmap.Create(smallW, smallH);
|
||||
for i := 0 to high(pixels) do
|
||||
begin
|
||||
pixBmp.DrawPixelF(pixels[i].x, pixels[i].y, BGRABlack, dmDrawWithTransparency);
|
||||
IncF(pixels[i].x, pixels[i].dx);
|
||||
IncF(pixels[i].y, pixels[i].dy);
|
||||
if pixels[i].x <= -1 then pixels[i].x := smallW else
|
||||
if pixels[i].x >= smallW then pixels[i].x := -1;
|
||||
if pixels[i].y <= -1 then pixels[i].y := smallH else
|
||||
if pixels[i].y >= smallH then pixels[i].y := -1;
|
||||
end;
|
||||
virtualScreen.StretchPutImage(rect(0,0,Width,Height), pixBmp, dmDrawWithTransparency);
|
||||
pixBmp.Free;
|
||||
|
||||
DrawPacman(virtualScreen.Width div 4,virtualScreen.Height div 2, ln(time+1)*100);
|
||||
DrawPacman(3*virtualScreen.Width div 4,virtualScreen.Height div 2, -time*4);
|
||||
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest7.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec*5;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
99
bgrabitmap/test/testbgrafunc/utest8.pas
Normal file
99
bgrabitmap/test/testbgrafunc/utest8.pas
Normal file
@@ -0,0 +1,99 @@
|
||||
unit utest8;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Graphics, BGRABitmap, BGRABitmapTypes, BGRATransform, utest;
|
||||
|
||||
type
|
||||
{ TTest8 }
|
||||
|
||||
TTest8 = class(TTest)
|
||||
private
|
||||
backgroundTile: TBGRABitmap;
|
||||
pacman,virtualScreen: TBGRABitmap;
|
||||
twirled: TBGRABitmap;
|
||||
alphaFactor: byte;
|
||||
time: single;
|
||||
procedure DrawPacman(x,y: integer; palphaFactor: byte);
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses Math;
|
||||
|
||||
{ TTest8 }
|
||||
|
||||
procedure TTest8.DrawPacman(x, y: integer; palphaFactor: byte);
|
||||
begin
|
||||
virtualScreen.PutImage(x-Pacman.width div 2,y-Pacman.height div 2,Pacman,dmDrawWithTransparency,palphaFactor);
|
||||
end;
|
||||
|
||||
constructor TTest8.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Global opacity applied to pacman, background scrolling and twirl';
|
||||
virtualScreen := nil;
|
||||
twirled := nil;
|
||||
pacman := TBGRABitmap.Create(ResourceDir+'pac_d1.bmp');
|
||||
pacman.ReplaceColor(pacman.GetPixel(0,0),BGRAPixelTransparent);
|
||||
time := Pi/4;
|
||||
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
end;
|
||||
|
||||
destructor TTest8.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
twirled.free;
|
||||
pacman.free;
|
||||
backgroundTile.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest8.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var twirl: TBGRATwirlScanner;
|
||||
begin
|
||||
if time=0 then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(twirled);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
begin
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
twirled := TBGRABitmap.Create(Width,Height);
|
||||
end;
|
||||
|
||||
virtualscreen.Fill(backgroundTile);
|
||||
DrawPacman(virtualScreen.Width div 4,virtualScreen.Height div 2, alphaFactor);
|
||||
DrawPacman(3*virtualScreen.Width div 4,virtualScreen.Height div 2, 255-alphaFactor);
|
||||
|
||||
twirl := TBGRATwirlScanner.Create(virtualscreen,point(width div 2, height div 2),min(Width,Height)/3,0.3,2);
|
||||
twirled.Fill(virtualscreen);
|
||||
twirled.FillRect(floor(twirl.Center.X-twirl.Radius),floor(twirl.Center.Y-twirl.Radius),
|
||||
ceil(twirl.Center.X+twirl.Radius),ceil(twirl.Center.Y+twirl.Radius),twirl,dmSet);
|
||||
twirled.Draw(Canvas,Left,Top,True);
|
||||
twirl.Free;
|
||||
end;
|
||||
|
||||
procedure TTest8.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec;
|
||||
alphaFactor := round((sin(time)+1)/2*255);
|
||||
backgroundTile.ScanOffset := point(round((sin(time*0.3)+1)/2*1023) mod backgroundTile.Width,
|
||||
round((sin(time*1.7)+1)/2*63) mod backgroundTile.Height);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
93
bgrabitmap/test/testbgrafunc/utest9.pas
Normal file
93
bgrabitmap/test/testbgrafunc/utest9.pas
Normal file
@@ -0,0 +1,93 @@
|
||||
unit utest9;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, utestback, Graphics, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
type
|
||||
{ TTest9 }
|
||||
|
||||
TTest9 = class(TTestBack)
|
||||
protected
|
||||
pacman,virtualScreen,masked: TBGRABitmap;
|
||||
time: single;
|
||||
lightPos1,lightPos2: TPointF;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnPaint(Canvas: TCanvas; Left,Top,Width,Height: Integer); override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses math, utest;
|
||||
|
||||
{ TTest9 }
|
||||
|
||||
constructor TTest9.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
Name := 'Simple mask, ellipse and radial gradient';
|
||||
virtualScreen := nil;
|
||||
masked := nil;
|
||||
pacman := TBGRABitmap.Create(ResourceDir+'pac_d1.bmp');
|
||||
pacman.ReplaceColor(pacman.GetPixel(0,0),BGRAPixelTransparent);
|
||||
time := 0;
|
||||
end;
|
||||
|
||||
destructor TTest9.Destroy;
|
||||
begin
|
||||
virtualScreen.Free;
|
||||
masked.Free;
|
||||
pacman.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTest9.OnPaint(Canvas: TCanvas; Left,Top,Width, Height: Integer);
|
||||
var mask: TBGRABitmap; x,y: single;
|
||||
begin
|
||||
UpdateBackground(Width,Height);
|
||||
if time = 0 then exit;
|
||||
|
||||
if (virtualscreen <> nil) and ((virtualscreen.width <> width) or (virtualscreen.Height <> height)) then
|
||||
begin
|
||||
FreeAndNil(virtualScreen);
|
||||
FreeAndNil(masked);
|
||||
end;
|
||||
|
||||
if virtualscreen = nil then
|
||||
virtualscreen := TBGRABitmap.Create(Width,Height);
|
||||
|
||||
if masked = nil then
|
||||
begin
|
||||
masked := backgroundImg.Duplicate;
|
||||
masked.PutImage(virtualScreen.Width div 2,virtualScreen.Height div 2, pacman, dmDrawWithTransparency);
|
||||
end;
|
||||
|
||||
virtualscreen.PutImage(0,0,backgroundImg,dmSet);
|
||||
virtualScreen.FillRect(0,0,virtualScreen.Width,virtualScreen.Height,BGRA(0,0,0,192),dmDrawWithTransparency);
|
||||
|
||||
mask := TBGRABitmap.Create(Width,Height,BGRABlack);
|
||||
mask.FillEllipseAntialias(lightPos1.X*Width,lightPos1.Y*Height,40,40,BGRAWhite);
|
||||
x := lightPos2.X*Width;
|
||||
y := lightPos2.Y*Height;
|
||||
mask.GradientFill(floor(x-60),floor(y-60),ceil(x+60),ceil(y+60),BGRAWhite,BGRAPixelTransparent,gtRadial,pointf(x,y),pointf(x+60,y),dmDrawWithTransparency,True,False);
|
||||
virtualScreen.FillMask(0,0,mask,masked);
|
||||
mask.free;
|
||||
|
||||
virtualscreen.Draw(Canvas,Left,Top,True);
|
||||
end;
|
||||
|
||||
procedure TTest9.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
begin
|
||||
time := time+ElapsedSec*0.5;
|
||||
lightPos1 := pointF((sin(time)+1)/4+0.2,(cos(time*0.3)+1)/4+0.3);
|
||||
lightPos2 := pointF((sin(time*0.7+1)+1)/4+0.4,(cos(time*0.5+2)+1)/4+0.3);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
51
bgrabitmap/test/testbgrafunc/utestback.pas
Normal file
51
bgrabitmap/test/testbgrafunc/utestback.pas
Normal file
@@ -0,0 +1,51 @@
|
||||
unit utestback;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utest;
|
||||
|
||||
type
|
||||
{ TTestBack }
|
||||
|
||||
TTestBack = class(TTest)
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure UpdateBackground(Width,Height: integer);
|
||||
protected
|
||||
backgroundTile,backgroundImg: TBGRABitmap;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestBack }
|
||||
|
||||
constructor TTestBack.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
backgroundImg := nil;
|
||||
end;
|
||||
|
||||
destructor TTestBack.Destroy;
|
||||
begin
|
||||
backgroundImg.Free;
|
||||
backgroundTile.free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTestBack.UpdateBackground(Width,Height: integer);
|
||||
begin
|
||||
if (backgroundImg <> nil) and ((backgroundImg.Width <> Width) or (backgroundImg.Height <> Height)) then
|
||||
FreeAndNil(backgroundImg);
|
||||
|
||||
if backgroundImg = nil then
|
||||
backgroundImg := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
104
bgrabitmap/test/testbgrafunc/utestpacrect.pas
Normal file
104
bgrabitmap/test/testbgrafunc/utestpacrect.pas
Normal file
@@ -0,0 +1,104 @@
|
||||
unit utestpacrect;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes, Graphics, utest;
|
||||
|
||||
const NbPacman = 20;
|
||||
|
||||
type
|
||||
{ TTestPacRect }
|
||||
|
||||
TTestPacRect = class(TTest)
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure OnTimer(Width,Height: Integer; ElapsedSec: Double); override;
|
||||
protected
|
||||
pacLoc: array of TPoint;
|
||||
pacImg: array of TBGRABitmap;
|
||||
pacSize : TPoint;
|
||||
backgroundTile,backgroundImg: TBGRABitmap;
|
||||
numPacImg: integer;
|
||||
function AddTranspRectTo(filename: string): TBGRABitmap;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TTestPacRect }
|
||||
|
||||
constructor TTestPacRect.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
randomize;
|
||||
setlength(pacImg,4);
|
||||
pacImg[0] := AddTranspRectTo(ResourceDir+'pac_d1.bmp');
|
||||
pacImg[1] := AddTranspRectTo(ResourceDir+'pac_d2.bmp');
|
||||
pacImg[2] := AddTranspRectTo(ResourceDir+'pac_d3.bmp');
|
||||
pacImg[3] := AddTranspRectTo(ResourceDir+'pac_d2.bmp');
|
||||
|
||||
backgroundTile := TBGRABitmap.Create(ResourceDir+'diamondback.png');
|
||||
backgroundImg := nil;
|
||||
|
||||
numPacImg := 0;
|
||||
pacSize := Point(pacImg[0].Width,pacImg[0].Height);
|
||||
end;
|
||||
|
||||
destructor TTestPacRect.Destroy;
|
||||
var i: integer;
|
||||
begin
|
||||
backgroundImg.Free;
|
||||
backgroundTile.Free;
|
||||
for i := 0 to high(pacImg) do
|
||||
pacImg[i].Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TTestPacRect.OnTimer(Width, Height: Integer; ElapsedSec: Double);
|
||||
var i: integer;
|
||||
begin
|
||||
if pacLoc = nil then
|
||||
begin
|
||||
setlength(pacLoc,NbPacman);
|
||||
for i := 0 to high(pacLoc) do
|
||||
pacLoc[i] := Point(random(Width+pacSize.X)-pacSize.X,random(Height+pacSize.Y)-pacSize.Y);
|
||||
end else
|
||||
begin
|
||||
for i := 0 to high(pacLoc) do
|
||||
if (pacLoc[i].Y <= -pacSize.Y) or (pacLoc[i].Y >= Height) then
|
||||
pacLoc[i] := Point(random(Width+pacSize.X)-pacSize.X,random(Height+pacSize.Y)-pacSize.Y)
|
||||
else
|
||||
begin
|
||||
inc(pacLoc[i].X,4);
|
||||
if pacLoc[i].X >= Width then
|
||||
begin
|
||||
pacLoc[i].X := -pacSize.X;
|
||||
pacLoc[i].Y := random(Height+pacSize.Y)-pacSize.Y;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
numPacImg := (numPacImg+1) mod length(pacImg);
|
||||
|
||||
if (backgroundImg <> nil) and ((backgroundImg.Width <> Width) or (backgroundImg.Height <> Height)) then
|
||||
FreeAndNil(backgroundImg);
|
||||
|
||||
if backgroundImg = nil then
|
||||
backgroundImg := backgroundTile.GetPart(rect(0,0,Width,Height));
|
||||
end;
|
||||
|
||||
function TTestPacRect.AddTranspRectTo(filename: string): TBGRABitmap;
|
||||
var originalImage: TBGRABitmap;
|
||||
begin
|
||||
originalImage := TBGRABitmap.Create(filename);
|
||||
originalImage.ReplaceColor(originalImage.GetPixel(0,0),BGRAPixelTransparent);
|
||||
result := TBGRABitmap.Create(originalImage.Width+originalImage.Height,OriginalImage.Height);
|
||||
result.PutImage(0,0,originalImage,dmSet);
|
||||
result.Rectangle(originalImage.Width,0,result.Width,result.Height,BGRABlack,BGRA(0,0,0,64),dmDrawWithTransparency);
|
||||
originalImage.Free;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
81
bgrabitmap/test/testbgrafunc/utexture.pas
Normal file
81
bgrabitmap/test/testbgrafunc/utexture.pas
Normal file
@@ -0,0 +1,81 @@
|
||||
unit utexture;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRABitmap, BGRABitmapTypes;
|
||||
|
||||
function CreateGreenTexture: TBGRABitmap;
|
||||
function CreateMarbleTexture(tx,ty: integer): TBGRABitmap;
|
||||
function CreateWoodTexture(tx,ty: integer): TBGRABitmap;
|
||||
|
||||
implementation
|
||||
|
||||
uses BGRAGradients;
|
||||
|
||||
function Interp256(value1,value2,position: integer): integer; inline; overload;
|
||||
begin
|
||||
result := (value1*(256-position) + value2*position) shr 8;
|
||||
end;
|
||||
|
||||
function Interp256(color1,color2: TBGRAPixel; position: integer): TBGRAPixel; inline; overload;
|
||||
begin
|
||||
result.red := Interp256(color1.red,color2.red, position);
|
||||
result.green := Interp256(color1.green,color2.green, position);
|
||||
result.blue := Interp256(color1.blue,color2.blue, position);
|
||||
result.alpha := Interp256(color1.alpha,color2.alpha, position);
|
||||
end;
|
||||
|
||||
function CreateGreenTexture: TBGRABitmap;
|
||||
var
|
||||
p: PBGRAPixel;
|
||||
i: Integer;
|
||||
begin
|
||||
result := CreatePerlinNoiseMap(256,256);
|
||||
BGRAReplace(result,result.Resample(32,32));
|
||||
p := result.data;
|
||||
for i := 1 to result.NbPixels do
|
||||
begin
|
||||
p^ := Interp256( BGRA(0,128,0), BGRA(192,255,0), p^.red );
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
|
||||
function CreateMarbleTexture(tx,ty: integer): TBGRABitmap;
|
||||
var
|
||||
colorOscillation: integer;
|
||||
p: PBGRAPixel;
|
||||
i: Integer;
|
||||
begin
|
||||
result := CreateCyclicPerlinNoiseMap(tx,ty,0.5,0.5,0.8,rfBestQuality);
|
||||
p := result.Data;
|
||||
for i := 0 to result.NbPixels-1 do
|
||||
begin
|
||||
colorOscillation := round(sqrt(sqrt((sin(p^.red*Pi/128+0.5)+1)/2))*256);
|
||||
p^ := Interp256(BGRA(161,117,105),BGRA(218,197,180),colorOscillation);
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
|
||||
function CreateWoodTexture(tx,ty: integer): TBGRABitmap;
|
||||
var
|
||||
colorOscillation, globalColorVariation: integer;
|
||||
p: PBGRAPixel;
|
||||
i: Integer;
|
||||
begin
|
||||
result := CreateCyclicPerlinNoiseMap(tx,ty,1.5,1.5,1,rfBestQuality);
|
||||
p := result.Data;
|
||||
for i := 0 to result.NbPixels-1 do
|
||||
begin
|
||||
colorOscillation := round(sqrt((sin(p^.red*Pi/16)+1)/2)*256);
|
||||
globalColorVariation := p^.red;
|
||||
p^:= Interp256( Interp256(BGRA(247,188,120),BGRA(255,218,170),colorOscillation),
|
||||
Interp256(BGRA(157,97,60),BGRA(202,145,112),colorOscillation), globalColorVariation);
|
||||
inc(p);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
123
bgrabitmap/test/testbgrafunc/utore3d.pas
Normal file
123
bgrabitmap/test/testbgrafunc/utore3d.pas
Normal file
@@ -0,0 +1,123 @@
|
||||
unit utore3d;
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, BGRAScene3D;
|
||||
|
||||
type
|
||||
|
||||
{ TToreScene3D }
|
||||
|
||||
TToreScene3D = class(TBGRAScene3D)
|
||||
private
|
||||
shape,lightObj: IBGRAObject3D;
|
||||
procedure CreateLight;
|
||||
procedure CreateShape;
|
||||
public
|
||||
angle: single;
|
||||
constructor Create;
|
||||
procedure Render; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses BGRABitmapTypes, BGRAMatrix3D;
|
||||
|
||||
{ TToreScene3D }
|
||||
|
||||
constructor TToreScene3D.Create;
|
||||
begin
|
||||
inherited Create;
|
||||
CreateLight;
|
||||
CreateShape;
|
||||
end;
|
||||
|
||||
procedure TToreScene3D.Render;
|
||||
begin
|
||||
with shape.MainPart do
|
||||
begin
|
||||
ResetTransform;
|
||||
Translate(sin(angle*Pi/180+Pi/4)*10,0,0);
|
||||
Scale(20);
|
||||
RotateZDeg(angle*0.3);
|
||||
RotateXDeg(angle*0.1+90);
|
||||
end;
|
||||
with lightObj.MainPart do
|
||||
begin
|
||||
ResetTransform;
|
||||
RotateYDeg(angle);
|
||||
Translate(60,0,0);
|
||||
end;
|
||||
inherited Render;
|
||||
end;
|
||||
|
||||
procedure TToreScene3D.CreateShape;
|
||||
const NbX = 40;
|
||||
NbY = 20;
|
||||
var
|
||||
v: array[0..NbY-1,0..NbX-1] of IBGRAVertex3D;
|
||||
i,j: integer;
|
||||
m: TMatrix3D;
|
||||
p,ofs: TPoint3D;
|
||||
begin
|
||||
shape := CreateObject(BGRA(255,0,0));
|
||||
|
||||
m := MatrixRotateY(2*Pi/NbY);
|
||||
|
||||
p := Point3D(0.3,0,0);
|
||||
ofs := Point3D(1,0,0);
|
||||
for i := 0 to NbY-1 do
|
||||
begin
|
||||
v[i,0] := shape.MainPart.Add(p+ofs);
|
||||
p := m*p;
|
||||
end;
|
||||
|
||||
m := MatrixRotateZ(2*Pi/NbX);
|
||||
for j := 1 to NbX-1 do
|
||||
for i := 0 to NbY-1 do
|
||||
v[i,j] := shape.MainPart.Add(m*v[i,j-1].SceneCoord);
|
||||
|
||||
for j := 0 to NbX-1 do
|
||||
for i := 0 to NbY-1 do
|
||||
shape.AddFace([v[i,j],v[i,(j+1)mod NbX],v[(i+1) mod NbY,(j+1)mod NbX],v[(i+1) mod NbY,j]]);
|
||||
end;
|
||||
|
||||
procedure TToreScene3D.CreateLight;
|
||||
var v: array of IBGRAVertex3D;
|
||||
lamp: IBGRAMaterial3D;
|
||||
begin
|
||||
lightObj := CreateObject(BGRAWhite);
|
||||
DefaultLightingNormal := lnVertex;
|
||||
DefaultMaterial.SpecularIndex := 10;
|
||||
{ if DefaultLightingNormal = lnFace then
|
||||
begin
|
||||
AmbiantLightness := 0.4;
|
||||
AddPointLight(lightObj.Vertices.Add(0,0,0),40,0.8,-0.3)
|
||||
end
|
||||
else
|
||||
begin }
|
||||
AmbiantLightColor := BGRA(128,128,128);
|
||||
AddPointLight(lightObj.MainPart.Add(0,0,0),40,BGRA(128,128,64),-0.3);
|
||||
//end;
|
||||
|
||||
v := lightObj.MainPart.Add([-1,-2,-2, 1,-1,-1, 1,1,-1, -1,2,-2,
|
||||
-1,-2,+2, 1,-1,+1, 1,1,+1, -1,2,+2]);
|
||||
|
||||
lamp := CreateMaterial;
|
||||
lamp.LightThroughFactor := 0.0001;
|
||||
lightObj.Material := lamp;
|
||||
lightObj.AddFace([v[0],v[1],v[2],v[3]],true);
|
||||
lightObj.AddFace([v[4],v[5],v[1],v[0]],true);
|
||||
lightObj.AddFace([v[7],v[6],v[5],v[4]],true);
|
||||
lightObj.AddFace([v[3],v[2],v[6],v[7]],true);
|
||||
lightObj.AddFace([v[1],v[5],v[6],v[2]],true);
|
||||
//lightObj.AddFace([v[4],v[0],v[3],v[7]],true);
|
||||
|
||||
AddPointLight(lightObj.MainPart.Add(5,0,0),4,1,-0.3);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user