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_widthandPoixState::ui_heightmethods which take into
account remaining screen space with regards to current UI cursor position and
frame padding. - Added configurable
scroll_sizeto the UI theme for the width of rendered
scrollbars. - Added
PixState::mouse_dbl_clickedmethod indicating mouse was double clicked
last frame. - Added
PixState::dbl_clickedmethod indicating mouse was double clicked on
the previous UI widget drawn. - Added
PixState::set_column_offsetandPixState::reset_column_offsetto
allow controlling thex-offsetcursor position when rendering UI elements. - Added
ThemeBuildertopix_engine::prelude. - Added
PixState::focused_windowthat takes aWindowIdto check for focus. - Added
PixState::audio_sizeto query the current size of the audio queue
device. - Added
TrianglecontainsPointimplementation. - Added arrow keyboard navigation to
PixState::select_boxwhile 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,LightandLightSourceare now defined. - Changed how
PixState::on_updatehandles frame rates and no longer sleeps
whenvsyncis 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_staticforonce_cell.
Fixed
- Fixed widgets to properly render the label with the current
fillcolor. - Fixed
PixState::bulletto be more indented. - Fixed
PixState::tabsize - Fixed
PixState::select_listpadding - Fixed
PixState::mod_downto correctly returntruewhen multiple modifiers
are pressed. - Fixed off-by-one error in
Ellipse::bounding_rect. - Fixed
target_frame_rateepsilon. - Fixed update rate limiting when
vsyncis disabled and notarget_frame_rate - set.
- Fixed
PixState::select_boxexpanding on focus and unexpanding when focus
is lost. - Fixed
PixState::font_sizeaffectingThemefont size.
Breaking
- Changed
PixState::tab_barto take aselectedparameter to control the
initial selected tab and changed the callback to take a generic type instead
of ausize. PixState::enqueue_audionow returns aPixResultin 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::focusedto returntruewhether any active windows have
focus. - Renamed
PixState::keymodstoPixState::keymodwhich now returns a single
&KeyModvalue instead of aHashSet<KeyMod>sinceKeyModis already a
set of bitflags. - Changed
PixState::delta_timeandPixState::elapsedto return aDuration
instead of milliseconds. - Changed
PixState::avg_frame_rateto return anf32instead ofusize. - Changed
PixState::stroke_weightto accept au16instead 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 acceptingfalseorNone. - Added
PartialEqtoNumtrait. - Modified
ContainsandIntersectstraits to be more generic and have a
singlecontainsorintersectsmethod to allow for future implementations
of other shapes. - Added
PixState::audio_queued_sizeand changedPixState::audio_sizeto
return the buffer capacity instead of the queued size. - Added support for multiple concrete channel types for
AudioCallbackvia
an associated trait type. - Removed
vcpkgfeature support due to flaky error rates.Windowsbuilds now
can utilize a build script with static linking.macOSandLinuxcan
continue usinghomebrewor their distros package manager. - Changed
PixEngineBuilder::scaleto only set rendering scale and to not
affect window size, to mirrorPixState::scale. Removed
WindowBuilder::scale. - Renamed all primitive
as_bytesandas_arraymethods topoints
andcoords.
Version 0.5.4
[0.5.4] - 2022-01-26
Added
- Added
PixState::smoothandPixState::no_smoothto toggle anti-alias
drawing of shapes. - Added
PixState::day,PixState::month,PixState::year,PixState::hour,
PixState::minute, andPixState::secondmethods. - 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
shapesexample. - Added
PixState::bezierandPixState::bezier_detailmethods. - Added
IntoIteratorfor array-like types for&Tand&mut T. - Added audio callback and capture support with new types:
AudioSpecDesired,
AudioSpec,AudioDevice, a new trait:AudioCallbackand new methods:
PixState::open_playbackandPixState::open_capture. - Added
PixState::audio_drivermethod to return the driver for the Audio Queue. - Added
audio_callbackandaudio_capture_and_replayexamples.
Changed
- Removed sleeping when audio queue got too full in favor of a maximum buffer
size with a warning indicatingresume_audiowas not called. - Updated
READMEwith better installation steps and a Table of Contents. - Moved
rayonto adev-dependency. - Added a
loggingexample. - Fixed
Color::TRANSPARENTto have0alpha 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
Coloraddition and subtraction operations. - Renamed
audioexample toaudio_queue. - Removed
wasmchecks and dependencies until future Web-Assembly implementation starts in
earnest. - Made
PixState::presentpublic so that the current canvas can be updated in the middle of, or
outside ofAppState::on_update. - Fixed various documentation errors.
Breaking
- Made
WindowBuilder::newcrate-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
ThemeBuilderto default to "dark" theme. - Changed radio and checkboxes to scale based on
font_size.
Added
- Fixed mapping of
WindowEvent::Exposed. - Raw audio sample example.
AudioStatusenum for representing the playback status of the audio device.PixState::audio_statusandPixState::audio_sample_ratemethods.PixState::resume_audioandPixState::pause_audiomethods.PixEngineBuilder::audio_channelsto choose the number of audio channels to
play to. Defaults to1for mono.SpacingBuilderstruct to construct custom theme spacing easier.PixState::menumethod 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_deadzonewhich 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::iconandWindowBuilder::iconnow take an
Into<Icon>parameter that can converted into either aPathBufor an
Imagewhich 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
Unknownevent variants toUnsupportedto 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
logfacade added for logging support.- Added methods to
PixEngineBuilderto control cache sizes. - Added
PixState::elapsedmethod which returns the total elasped time since
application start. - A lot of documentation, examples, and README images.
UI
- Added
ThemeandThemeBuiilderstructs to customize UI theming for colors,
fonts, sizes, styles and spacing.PixEngineBuilderupdated with theme
customizing methods. Default is a dark theme. - Added several new UI widget rendering methods and a new
guiexample demoing
their usage. Cursor::nomethod added.
Window
PixStatemethods 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_canvasandPixState::save_texturemethods.
Drawing
Color::from_hex_alphaandColor::as_hex_alphaadded that take/return RGBA
values.Color::blendedmethod added.PixState::set_viewportandPixState::clear_viewportmethods added to
control the rendering viewport.
Shapes
Rect::resizedandRect::resize_bymethods added.- Added various
offsetmethods to shapes. Ellipse::diametermethod for circular ellipses.Ellipse::bounding_rectmethod.Point::distmethod.SerializeandDeserializeadded for shapes with const generics when the
serdefeature is enabled.
Changed
Core
- Several types changed to
must_use. - Several optimizations and performance improvements regarding caching and
memory management.
UI
PixEngineBuilder::with_fontupdated to take anything that can be turned into
aFontstruct which includes a path as before, but can now also take static
font data loaded frominclude_bytes!for example.PixState::textupdated to return the bounding box of rendered text.- Added
PixState::wrap_widthandPixState::no_wrapmethods to control text
wrap width.
Drawing
- Many
Colormethods madeconst. Color::set_levelsmethod added.- Changed shapes to use anti-aliasing where possible by default.
- Added
PixState::stroke_weightmethod to draw thick lines.
Shapes
- Fixed radius handling in a circle
Ellipse. Line::new,Tri::new, andQuad::newupdated to support different types
for each point parameter.Line,Tri, andQuadmacros updated to have better type inference.
Breaking
Core
coremodule removed and all included modules moved up a level.PixResultchanged to returnanyhow::Error, which can include a backtrace
on nightly. Many other types of errors returned now all return the same
PixResultstruct.AppStatemethods that handle events changed to return aboolindicating
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_dirmethod in favor of including assets
required by the library in the binary. PixEngineBuilder::buildnow returns aPixResultif any of the build
settings are invalid.math::constants::*moved intomath.
Textures
Texturestruct removed in favor ofTextureId. All methods for getting or
updating textures now take aTextureIdinstead.- Removed
unsafefromPixState::delete_texture. Now it will simply return a
PixResultif theTextureIdis invalid.
Shapes
- All shapes had their
valuesmethod changed toas_arrayandset_values
method removed in favor ofas_bytes_mut. - All shapes now have
as_bytesandas_bytes_mutmethods. - Removed
Buttonstruct and changedPixState::buttonAPI to just return a
boolif the button was clicked or not instead of having aclicked
method. UsePixState::hoveredmethod to check if the previously rendered
item was hovered.
UI
PixEngineBuilder::with_fontchanged to not takesizeas a parameter. Added
an additionalPixEngineBuilder::with_font_sizemethod.PixState::primary_window_idremoved.
Drawing
Color::new,Color::new_alpha,Color::rgb, andColor::rgbachanged to
takeu8RGB/A values. Affectsrgb!andcolor!macros. RGBA setter
methods also updated to takeu8.Color::levelsmade non-const instead computing levels at run-time as needed.Color::from_rawrenamed toColor::from_levelsand removedunsafe.Color::from_hexandColor::as_hexchanged to take/return RGB
values with the topu32bits being0x00.Color::from_hex_alphaand
Color::as_hex_alphaadded that take/return RGBA values.Color::rgb_channelsandColor::rgba_channelsremoved in favor of
Color::channels.- Color constants moved from the prelude to constants on
Color. e.g.Color::RED. PixState::polygonandPixState::wireframechanged 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,roundandtruncmethods 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::preludeandcrate::prelude_3dfor common imports.Copy,Clone,Debug,Default,PartialEq,Eq, andHash
implementations for many/most structs where appropriate.SerializeandDeserializeimplemented for most structs with with theserde
feature enabled.- New optional
AppStatemethods: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.
PixEngineBuilderstruct added with several settings for configuring the
PixEngineinitialization.
State
PixStatemethods for interacting with the window andPixEnginestate: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).
PixStatemethods for controlling drawing and thePixEnginerender 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::scalewhich 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 asRadiansorDegrees.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
WindowBuilderstruct for opening windows:new(): Create a newWindowBuilderinstance.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 fromWindowBuilderand open it.
PixStatewindow 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::Resultandwindow::Errorfor window related failures.
Drawing
ColorModeenum withRgb,Hsb, andHslvariants.Colorstruct with several methods for creating and converting between color
modes.Colormacrosrgb!(),hsb!(), andhsl!().- Additional
Colorconstants matching the SVG 1.0 Color
Keywords. color::Resultandcolor::Errortypes for conversion failures.Drawtrait for types that can be drawn usingPixState.- Several new shape drawing methods on
PixState. - New
Texturestruct and methods for hardware-accelerated rendering. LightandLightSourcestructs 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. DerefandDerefMutinto an array of values representing a shape.IntoIteratorfor structs where applicable.ContainsandIntersectstraits and implementations for defining collision
detection.Drawimplementations.Rectstruct extended with several constructor and utility methods.- Several new shape structs:
Ellipse,Line,Point,Quad,Sphere, and
Triwith convenience macros.
Image
- New
Imagemethods for converting and manipulating images. image::Resultandimage::Errorfor image failures.
Events
WindowEventstruct.KeyModstruct for detecting key modifiers on key press and release events.
Misc
mathmodule for noise and randomization utilities.Numtrait for generic number handling.Vectortype for doing N-dimensional vector math.- Attribution for
Emulogicfont. - New
katakanaprovided font along with default unicode fonts for fallbacks. - Several new examples:
2d_raycasting3d_raytracingcolorsflockingfluid_simulationimagematrixmazetextures
- Extensive documentation additions and README improvements.
Changed
description,categoryandkeywordsupdated inCargo.toml.- Updated to resolver 2
inCargo.toml - Updated
LICENSE.mdtoMIT/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. PixEngineResultrenamed toPixResult.PixEngineErrrenamed toPixErrorandPixEngineErr::new()removed.PixEngineStategeneric 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 implementsAppStateand returns
PixResultinstead ofPixEngineResult.
State
Statetrait renamed toAppState.StateDatastruct renamed toPixState. Affects all methods from theState
trait which was renamed toPixState.AppState::on_start,AppState::on_update, andAppState::on_stopchanged
to returnPixResult<()>. UsePixState::quit()instead of returningfalse
in order to terminate the application.AppState::on_updateno longer takeselapsed. UsePixState::delta_time()
instead.- `StateData::enable_coord_wra...