Releases: lukexor/pix-engine
Releases · lukexor/pix-engine
Release 0.8.0
Release 0.6.0
[0.6.0] - 2022-06-20
Added
- Added
PixState::ui_width
andPoixState::ui_height
methods which take into
account remaining screen space with regards to current UI cursor position and
frame padding. - Added configurable
scroll_size
to the UI theme for the width of rendered
scrollbars. - Added
PixState::mouse_dbl_clicked
method indicating mouse was double clicked
last frame. - Added
PixState::dbl_clicked
method indicating mouse was double clicked on
the previous UI widget drawn. - Added
PixState::set_column_offset
andPixState::reset_column_offset
to
allow controlling thex-offset
cursor position when rendering UI elements. - Added
ThemeBuilder
topix_engine::prelude
. - Added
PixState::focused_window
that takes aWindowId
to check for focus. - Added
PixState::audio_size
to query the current size of the audio queue
device. - Added
Triangle
contains
Point
implementation. - Added arrow keyboard navigation to
PixState::select_box
while focused.
Changed
- Improved element focus and blur.
- Increased the relative font size of
PixState::monospace
. - Removed indent of children under
PixState::collapsing_header
. - Fixed UI elements being able to take focus if disabled.
- Blur focus by clicking outside on UI elements and by pressing escape/enter in
input fields. - Default types and dimensions for
Point
,Vector
,Line
,Triangle
,
Quad
,Light
andLightSource
are now defined. - Changed how
PixState::on_update
handles frame rates and no longer sleeps
whenvsync
is enabled. - Changed vertical scroll direction to be natural.
- Set default audio buffer size to 4096.
- Updated audio buffer doucmentation.
- Changed default audio settings to use device defaults.
- Swapped
lazy_static
foronce_cell
.
Fixed
- Fixed widgets to properly render the label with the current
fill
color. - Fixed
PixState::bullet
to be more indented. - Fixed
PixState::tab
size - Fixed
PixState::select_list
padding - Fixed
PixState::mod_down
to correctly returntrue
when multiple modifiers
are pressed. - Fixed off-by-one error in
Ellipse::bounding_rect
. - Fixed
target_frame_rate
epsilon. - Fixed update rate limiting when
vsync
is disabled and notarget_frame_rate
- set.
- Fixed
PixState::select_box
expanding on focus and unexpanding when focus
is lost. - Fixed
PixState::font_size
affectingTheme
font size.
Breaking
- Changed
PixState::tab_bar
to take aselected
parameter to control the
initial selected tab and changed the callback to take a generic type instead
of ausize
. PixState::enqueue_audio
now returns aPixResult
in the event the audio
device fails, or the max queue size is reached.- Removed clearing the screen by default in
AppState::on_update
, leaving it to
the application to choose when to clear the screen. - Changed
PixState::focused
to returntrue
whether any active windows have
focus. - Renamed
PixState::keymods
toPixState::keymod
which now returns a single
&KeyMod
value instead of aHashSet<KeyMod>
sinceKeyMod
is already a
set of bitflags. - Changed
PixState::delta_time
andPixState::elapsed
to return aDuration
instead of milliseconds. - Changed
PixState::avg_frame_rate
to return anf32
instead ofusize
. - Changed
PixState::stroke_weight
to accept au16
instead of au8
. - Removed generic type aliases for all types that now have reasonable defaults.
- Removed
PixState::no_*
(e.g.no_stroke
,no_fill
, etc) methods in favor
of the main setter method acceptingfalse
orNone
. - Added
PartialEq
toNum
trait. - Modified
Contains
andIntersects
traits to be more generic and have a
singlecontains
orintersects
method to allow for future implementations
of other shapes. - Added
PixState::audio_queued_size
and changedPixState::audio_size
to
return the buffer capacity instead of the queued size. - Added support for multiple concrete channel types for
AudioCallback
via
an associated trait type. - Removed
vcpkg
feature support due to flaky error rates.Windows
builds now
can utilize a build script with static linking.macOS
andLinux
can
continue usinghomebrew
or their distros package manager. - Changed
PixEngineBuilder::scale
to only set rendering scale and to not
affect window size, to mirrorPixState::scale
. Removed
WindowBuilder::scale
. - Renamed all primitive
as_bytes
andas_array
methods topoints
andcoords
.
Version 0.5.4
[0.5.4] - 2022-01-26
Added
- Added
PixState::smooth
andPixState::no_smooth
to toggle anti-alias
drawing of shapes. - Added
PixState::day
,PixState::month
,PixState::year
,PixState::hour
,
PixState::minute
, andPixState::second
methods. - Added
[[T; 2]; 2]
,[[T; 3]; 2]
,[T; 4]
, and[T; 6]
array conversions
toLine
. - Added
[[T; 2]; 3]
,[[T; 3]; 3]
,[T; 6]
, and[T; 9]
array conversions
toTri
. - Added
shapes
example. - Added
PixState::bezier
andPixState::bezier_detail
methods. - Added
IntoIterator
for array-like types for&T
and&mut T
. - Added audio callback and capture support with new types:
AudioSpecDesired
,
AudioSpec
,AudioDevice
, a new trait:AudioCallback
and new methods:
PixState::open_playback
andPixState::open_capture
. - Added
PixState::audio_driver
method to return the driver for the Audio Queue. - Added
audio_callback
andaudio_capture_and_replay
examples.
Changed
- Removed sleeping when audio queue got too full in favor of a maximum buffer
size with a warning indicatingresume_audio
was not called. - Updated
README
with better installation steps and a Table of Contents. - Moved
rayon
to adev-dependency
. - Added a
logging
example. - Fixed
Color::TRANSPARENT
to have0
alpha channel. - Removed allowing
clippy::return_self_not_must_use
(Issue #9). - Changed audio queue to not sleep if too full and instead warn (and eventually
panic) if queue gets too full to avoid system contention. - Optimized
Color
addition and subtraction operations. - Renamed
audio
example toaudio_queue
. - Removed
wasm
checks and dependencies until future Web-Assembly implementation starts in
earnest. - Made
PixState::present
public so that the current canvas can be updated in the middle of, or
outside ofAppState::on_update
. - Fixed various documentation errors.
Breaking
- Made
WindowBuilder::new
crate-visible only. PreferPixState::window
.
Version 0.5.3
[0.5.3] - 2021-12-21
Changed
- Engine loop sleeps remainder of target frame rate to reduce CPU usage.
- Default audio sample rate to 48,000 Hz.
- Fixed
ThemeBuilder
to default to "dark" theme. - Changed radio and checkboxes to scale based on
font_size
.
Added
- Fixed mapping of
WindowEvent::Exposed
. - Raw audio sample example.
AudioStatus
enum for representing the playback status of the audio device.PixState::audio_status
andPixState::audio_sample_rate
methods.PixState::resume_audio
andPixState::pause_audio
methods.PixEngineBuilder::audio_channels
to choose the number of audio channels to
play to. Defaults to1
for mono.SpacingBuilder
struct to construct custom theme spacing easier.PixState::menu
method that renders a clickable menu item with hover state.
Breaking
- Disabled audio playback by default on startup. To queue and play audio you must first call
PixState::resume_audio
.
Version 0.5.2
[0.5.2] - 2021-12-13
Changed
- Updated MSRV in README.
Version 0.5.1
[0.5.1] - 2021-12-13
Added
- Basic gamepad controller support and a new event:
JoyHatMotion
. PixEngineBuider::with_deadzone
which alters the default gamepad axis
deadzone.AppState::on_controller_pressed
,AppState::on_controller_released
,
AppState::on_controller_axis_motion
,AppState::on_controller_update
.- More supported events:
AudioDeviceAdded
,AudioDeviceRemoved
,
WindowEvent::Exposed
,Key::Kp*
events for Keypad support. - Warning logs for unsupported events.
Changed
Core
PixEngineBuilder::icon
andWindowBuilder::icon
now take an
Into<Icon>
parameter that can converted into either aPathBuf
or an
Image
which allows loading an icon from a file, or a static or dynamic
image.
UI
- Various UI padding now use frame padding instead of item padding.
Breaking
- Changed
Unknown
event variants toUnsupported
to better reflect that some
events are known, but are not supported by this library.
Version 0.5.0
[0.5.0] - 2021-11-27
Added
Core
log
facade added for logging support.- Added methods to
PixEngineBuilder
to control cache sizes. - Added
PixState::elapsed
method which returns the total elasped time since
application start. - A lot of documentation, examples, and README images.
UI
- Added
Theme
andThemeBuiilder
structs to customize UI theming for colors,
fonts, sizes, styles and spacing.PixEngineBuilder
updated with theme
customizing methods. Default is a dark theme. - Added several new UI widget rendering methods and a new
gui
example demoing
their usage. Cursor::no
method added.
Window
PixState
methods for getting and setting window dimensions changed to return
a result instead of panicking and will return the dimensions for the current
window target instead of only the primary window.PixState::save_canvas
andPixState::save_texture
methods.
Drawing
Color::from_hex_alpha
andColor::as_hex_alpha
added that take/return RGBA
values.Color::blended
method added.PixState::set_viewport
andPixState::clear_viewport
methods added to
control the rendering viewport.
Shapes
Rect::resized
andRect::resize_by
methods added.- Added various
offset
methods to shapes. Ellipse::diameter
method for circular ellipses.Ellipse::bounding_rect
method.Point::dist
method.Serialize
andDeserialize
added for shapes with const generics when the
serde
feature is enabled.
Changed
Core
- Several types changed to
must_use
. - Several optimizations and performance improvements regarding caching and
memory management.
UI
PixEngineBuilder::with_font
updated to take anything that can be turned into
aFont
struct which includes a path as before, but can now also take static
font data loaded frominclude_bytes!
for example.PixState::text
updated to return the bounding box of rendered text.- Added
PixState::wrap_width
andPixState::no_wrap
methods to control text
wrap width.
Drawing
- Many
Color
methods madeconst
. Color::set_levels
method added.- Changed shapes to use anti-aliasing where possible by default.
- Added
PixState::stroke_weight
method to draw thick lines.
Shapes
- Fixed radius handling in a circle
Ellipse
. Line::new
,Tri::new
, andQuad::new
updated to support different types
for each point parameter.Line
,Tri
, andQuad
macros updated to have better type inference.
Breaking
Core
core
module removed and all included modules moved up a level.PixResult
changed to returnanyhow::Error
, which can include a backtrace
on nightly. Many other types of errors returned now all return the same
PixResult
struct.AppState
methods that handle events changed to return abool
indicating
whether the event is to be consumed or not, and thus skipping any additional
handling the engine may have for said event.pix_engine::prelude::*
cleaned up by removing several type aliases which can
be imported frompix_engine::shape
.- Removed
PixEngineBuilder::asset_dir
method in favor of including assets
required by the library in the binary. PixEngineBuilder::build
now returns aPixResult
if any of the build
settings are invalid.math::constants::*
moved intomath
.
Textures
Texture
struct removed in favor ofTextureId
. All methods for getting or
updating textures now take aTextureId
instead.- Removed
unsafe
fromPixState::delete_texture
. Now it will simply return a
PixResult
if theTextureId
is invalid.
Shapes
- All shapes had their
values
method changed toas_array
andset_values
method removed in favor ofas_bytes_mut
. - All shapes now have
as_bytes
andas_bytes_mut
methods. - Removed
Button
struct and changedPixState::button
API to just return a
bool
if the button was clicked or not instead of having aclicked
method. UsePixState::hovered
method to check if the previously rendered
item was hovered.
UI
PixEngineBuilder::with_font
changed to not takesize
as a parameter. Added
an additionalPixEngineBuilder::with_font_size
method.PixState::primary_window_id
removed.
Drawing
Color::new
,Color::new_alpha
,Color::rgb
, andColor::rgba
changed to
takeu8
RGB/A values. Affectsrgb!
andcolor!
macros. RGBA setter
methods also updated to takeu8
.Color::levels
made non-const instead computing levels at run-time as needed.Color::from_raw
renamed toColor::from_levels
and removedunsafe
.Color::from_hex
andColor::as_hex
changed to take/return RGB
values with the topu32
bits being0x00
.Color::from_hex_alpha
and
Color::as_hex_alpha
added that take/return RGBA values.Color::rgb_channels
andColor::rgba_channels
removed in favor of
Color::channels
.- Color constants moved from the prelude to constants on
Color
. e.g.Color::RED
. PixState::polygon
andPixState::wireframe
changed to take a type that can
be converted intoIntoIterator<Item = Into<PointI2>>
.- All shape drawing methods have more strict requirements that types can be
converted intoi32
. - All shape drawing methods with floating point representations have had
floor
,ceil
,round
andtrunc
methods added.
Version 0.4.2
Overview
This release is a major refactor of the library with a renewed architecture, a ton of new features, ergonomics and performance improvements.
[0.4.2] - 2021-09-02
Added
Core
crate::prelude
andcrate::prelude_3d
for common imports.Copy
,Clone
,Debug
,Default
,PartialEq
,Eq
, andHash
implementations for many/most structs where appropriate.Serialize
andDeserialize
implemented for most structs with with theserde
feature enabled.- New optional
AppState
methods:on_key_pressed()
: Called on key press and key repeat.on_key_released()
: Called on key release.on_key_typed()
: Called on character typed (ignores special keys like Ctrl and Backspace).on_mouse_dragged()
: Called on mouse motion while button is being heled.on_mouse_pressed()
: Called on mouse button press.on_mouse_released()
: Called on mouse button release.on_mouse_clicked()
: Called on mouse button released followed by a press.on_mouse_dbl_clicked()
: Called on mouse button double click.on_mouse_motion()
: Called on mouse motion.on_mouse_wheel()
: Called on mouse wheel scroll.on_window_event()
: Called on a window event (e.g. closed, resized, moved).on_event()
: Called for every user or system event as a catch-all.
PixEngineBuilder
struct added with several settings for configuring the
PixEngine
initialization.
State
PixState
methods for interacting with the window andPixEngine
state:delta_time()
: Time elapsed since last frame.frame_count()
Total number of frame since application start.frame_rate()
: Average frames per second rendered.target_frame_rate()
: Target frame rate.set_frame_rate()
: Set target frame rate.clear_frame_rate()
: Clear target frame rate.quit()
: Quit the application.abort_quit()
: Abort quitting the application (useful in
AppState::on_stop()
as a confirmation).
PixState
methods for controlling drawing and thePixEngine
render loop:background()
: Set the color for clearing the screen and clear to it immediately.fill()
: Set the fill color for drawing operations.no_fill()
: Clear the fill color to transparent.stroke()
: Set the stroke color for drawing operations.no_stroke()
: Clear the stroke color to transparent.clip()
: Set a clipping rectangle for drawing to the canvas.no_clip()
: Clear the clipping rectangle.running()
: Whether the engine loop is running and calling
AppState::on_update()
or not.run()
: Start the engine loop if it's not already running.no_run()
: Disable the engine loop if it's currently running.redraw()
: Run render loop one time if it's not currently running.runtimes()
: Run render loop N times if it's not currently running.show_frame_rate()
: Set whether to show the average frame rate in the title
bar or not.scale()
: Set the X, Y rendering scale for the canvas. Note this is
different thanPixEngineBuilder::scale
which scales the window dimensions.font_size()
: Set the font size.size_of()
: Get the dimensions of a given string with the currentfont_size
.font_style()
: Set the font style (e.g. NORMAL, BOLD, ITALIC, UNDERLINE,
STRIKETHROUGH).font_family()
: Set the font family. (e.g. "courier_new.ttf").rect_mode()
: Set how (x, y) coordinates are treated for drawing squares
and rectangles.ellipse_mode()
: Set how (x, y) coordinates are treated
for drawing circles and ellipses.image_mode()
: Set how (x, y) coordinates are treated for drawing images.angle_mode()
: Set whether angles are interpreted asRadians
orDegrees
.blend_mode()
: Set drawing blend mode for images and textures.push()
: Save the current drawing settings to a stack.pop()
: Restore previous drawing settings from the stack.
Window
WindowBuilder
struct for opening windows:new()
: Create a newWindowBuilder
instance.with_dimensions()
: Set window (width, height).with_title()
: Set window title.position()
: Set window (x, y) position.position_centered()
: Center window in the display.fullscreen()
: Make the window fullscreen.resizable()
: Allow window resizing.borderless()
: Disable window border.scale()
: Set window dimension scale.icon()
: Set window icon.build()
: Build window fromWindowBuilder
and open it.
PixState
window methods:focused()
: Wether the current window target has focus.primary_window_id()
: The primary window ID.window_id()
: The current window target ID.window()
: Create a newWindowBuilder
.close_window()
: Close a given window.dimensions()
: The current window target (width, height) dimensions.set_dimensions()
: Set the current window target (width, height) dimensions.width()
: The current window target width.set_width()
: Set the current window target width.height()
: The current window target height.set_height()
: Set the current window target height.display_dimensionsc()
: The current display (width, height) dimensions.display_width()
: The current display width.display_height()
: The current display height.show_window()
: Show the current window target if hidden.hide_window()
: Hide the current window target if shown.fullscreen()
: Whether the application is currently in fullscreen mode.set_fullscreen()
: Set fullscreen to true or false.vsync()
: Whether vertical sync is enabled.set_vsync()
: Set vertical sync to true or false.cursor()
: Set the mouse cursor icon to either a system icon or custom image.no_cursor()
: Clear mouse cursor back to default.with_window()
: Target a window for drawing operations with a closure.
window::Result
andwindow::Error
for window related failures.
Drawing
ColorMode
enum withRgb
,Hsb
, andHsl
variants.Color
struct with several methods for creating and converting between color
modes.Color
macrosrgb!()
,hsb!()
, andhsl!()
.- Additional
Color
constants matching the SVG 1.0 Color
Keywords. color::Result
andcolor::Error
types for conversion failures.Draw
trait for types that can be drawn usingPixState
.- Several new shape drawing methods on
PixState
. - New
Texture
struct and methods for hardware-accelerated rendering. Light
andLightSource
structs for doing basic 3D light rendering.
UI
- New Immediate-mode UI drawing methods for buttons. More to come in future
versions.
Shapes
- Made shape structs generic over their type and number of dimensions using new
const generics. - Conversion implementations to convert shapes between units for better
ergonomics. Deref
andDerefMut
into an array of values representing a shape.IntoIterator
for structs where applicable.Contains
andIntersects
traits and implementations for defining collision
detection.Draw
implementations.Rect
struct extended with several constructor and utility methods.- Several new shape structs:
Ellipse
,Line
,Point
,Quad
,Sphere
, and
Tri
with convenience macros.
Image
- New
Image
methods for converting and manipulating images. image::Result
andimage::Error
for image failures.
Events
WindowEvent
struct.KeyMod
struct for detecting key modifiers on key press and release events.
Misc
math
module for noise and randomization utilities.Num
trait for generic number handling.Vector
type for doing N-dimensional vector math.- Attribution for
Emulogic
font. - New
katakana
provided font along with default unicode fonts for fallbacks. - Several new examples:
2d_raycasting
3d_raytracing
colors
flocking
fluid_simulation
image
matrix
maze
textures
- Extensive documentation additions and README improvements.
Changed
description
,category
andkeywords
updated inCargo.toml
.- Updated to resolver 2
inCargo.toml
- Updated
LICENSE.md
toMIT/Apache-2.0
. - Updated
README
, documentation and usage examples. - Updated and refined examples.
Breaking
Core
- Root imports have been removed in favor of
crate::prelude
. PixEngineResult
renamed toPixResult
.PixEngineErr
renamed toPixError
andPixEngineErr::new()
removed.PixEngine
State
generic parameter removed in favor of passing application
toPixEngine::run()
.PixEngine::new()
removed. UsePixEngine::builder()
instead.PixEngine::set_icon()
moved toPixEngineBuilder::icon()
and changed to
takeAsRef<Path>
.PixEngine::fullscreen()
moved toPixEngineBuilder::fullscreen()
.PixEngine::vsync()
moved toPixEngineBuilder::vsync()
.PixEngine::set_audio_sample_rate()
moved to
PixEngineBuilder::audio_sample_rate()
.PixEngine::run()
now takes a type that implementsAppState
and returns
PixResult
instead ofPixEngineResult
.
State
State
trait renamed toAppState
.StateData
struct renamed toPixState
. Affects all methods from theState
trait which was renamed toPixState
.AppState::on_start
,AppState::on_update
, andAppState::on_stop
changed
to returnPixResult<()>
. UsePixState::quit()
instead of returningfalse
in order to terminate the application.AppState::on_update
no longer takeselapsed
. UsePixState::delta_time()
instead.- `StateData::enable_coord_wra...