kredki 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/kredki/core/application.rb +314 -0
- data/lib/kredki/core/color.rb +100 -0
- data/lib/kredki/core/event/block_event_reaction.rb +44 -0
- data/lib/kredki/core/event/composite_event_manager.rb +37 -0
- data/lib/kredki/core/event/event.rb +91 -0
- data/lib/kredki/core/event/event_manager.rb +60 -0
- data/lib/kredki/core/event/event_manager_jobs.rb +53 -0
- data/lib/kredki/core/event/event_reaction.rb +36 -0
- data/lib/kredki/core/event/family/drop_event.rb +40 -0
- data/lib/kredki/core/event/family/exit_event.rb +5 -0
- data/lib/kredki/core/event/family/focus_enter_event.rb +5 -0
- data/lib/kredki/core/event/family/focus_leave_event.rb +5 -0
- data/lib/kredki/core/event/family/hide_event.rb +5 -0
- data/lib/kredki/core/event/family/joystick_event.rb +102 -0
- data/lib/kredki/core/event/family/key_event.rb +40 -0
- data/lib/kredki/core/event/family/mouse_event.rb +190 -0
- data/lib/kredki/core/event/family/pastele_event.rb +11 -0
- data/lib/kredki/core/event/family/show_event.rb +5 -0
- data/lib/kredki/core/event/family/text_event.rb +23 -0
- data/lib/kredki/core/event/family/tick_event.rb +5 -0
- data/lib/kredki/core/event/family/update_complete_event.rb +5 -0
- data/lib/kredki/core/event/family/window_event.rb +108 -0
- data/lib/kredki/core/event/job_event_reaction.rb +44 -0
- data/lib/kredki/core/event/joystick_event_manager.rb +30 -0
- data/lib/kredki/core/event/keyboard_event_manager.rb +29 -0
- data/lib/kredki/core/event/method_event_reaction.rb +46 -0
- data/lib/kredki/core/event/mouse_event_manager.rb +27 -0
- data/lib/kredki/core/font.rb +53 -0
- data/lib/kredki/core/job/after_job.rb +59 -0
- data/lib/kredki/core/job/job.rb +108 -0
- data/lib/kredki/core/job/loop_job.rb +87 -0
- data/lib/kredki/core/job/play_animation_job.rb +44 -0
- data/lib/kredki/core/job/play_job.rb +41 -0
- data/lib/kredki/core/job/play_loop_animation_job.rb +98 -0
- data/lib/kredki/core/job/play_loop_job.rb +104 -0
- data/lib/kredki/core/job/side_job.rb +62 -0
- data/lib/kredki/core/kernel-path.rb +71 -0
- data/lib/kredki/core/kredki.rb +89 -0
- data/lib/kredki/core/linear_gradient.rb +43 -0
- data/lib/kredki/core/media/clipboard.rb +35 -0
- data/lib/kredki/core/media/joystick.rb +199 -0
- data/lib/kredki/core/media/keyboard.rb +84 -0
- data/lib/kredki/core/media/keyboard_modifiers_decoder.rb +154 -0
- data/lib/kredki/core/media/mouse.rb +197 -0
- data/lib/kredki/core/paint/animation.rb +247 -0
- data/lib/kredki/core/paint/area.rb +67 -0
- data/lib/kredki/core/paint/block_shape_area.rb +102 -0
- data/lib/kredki/core/paint/ellipse.rb +22 -0
- data/lib/kredki/core/paint/paint.rb +392 -0
- data/lib/kredki/core/paint/picture.rb +126 -0
- data/lib/kredki/core/paint/rectangle.rb +202 -0
- data/lib/kredki/core/paint/scene.rb +277 -0
- data/lib/kredki/core/paint/shape.rb +394 -0
- data/lib/kredki/core/paint/shape_area.rb +57 -0
- data/lib/kredki/core/paint/text.rb +222 -0
- data/lib/kredki/core/pastele/pastele-extern.rb +139 -0
- data/lib/kredki/core/pastele/pastele.rb +205 -0
- data/lib/kredki/core/radial_gradient.rb +45 -0
- data/lib/kredki/core/setup.rb +214 -0
- data/lib/kredki/core/window/pane.rb +178 -0
- data/lib/kredki/core/window/pane_event_manager.rb +44 -0
- data/lib/kredki/core/window/pane_events.rb +366 -0
- data/lib/kredki/core/window/window.rb +584 -0
- data/lib/kredki/core.rb +2 -0
- data/lib/kredki/hide.rb +9 -0
- data/lib/kredki/irb.rb +90 -0
- data/lib/kredki/module.rb +3 -0
- data/lib/kredki/pads/application.rb +13 -0
- data/lib/kredki/pads/button.rb +151 -0
- data/lib/kredki/pads/checkbox/checkbox.rb +68 -0
- data/lib/kredki/pads/checkbox/checkbox_button.rb +65 -0
- data/lib/kredki/pads/context/item.rb +65 -0
- data/lib/kredki/pads/context/item_group.rb +10 -0
- data/lib/kredki/pads/context/layer.rb +59 -0
- data/lib/kredki/pads/context/menu.rb +77 -0
- data/lib/kredki/pads/context/pad.rb +26 -0
- data/lib/kredki/pads/context/primary_layer.rb +51 -0
- data/lib/kredki/pads/context/secondary_layer.rb +60 -0
- data/lib/kredki/pads/item/item.rb +140 -0
- data/lib/kredki/pads/item/item_group.rb +44 -0
- data/lib/kredki/pads/item/item_x.rb +22 -0
- data/lib/kredki/pads/item/item_y.rb +31 -0
- data/lib/kredki/pads/label.rb +71 -0
- data/lib/kredki/pads/layer.rb +326 -0
- data/lib/kredki/pads/layout/align.rb +10 -0
- data/lib/kredki/pads/layout/layout.rb +88 -0
- data/lib/kredki/pads/layout/way.rb +99 -0
- data/lib/kredki/pads/layout/x_way.rb +119 -0
- data/lib/kredki/pads/layout/y_way.rb +120 -0
- data/lib/kredki/pads/list/item.rb +117 -0
- data/lib/kredki/pads/list/item_group.rb +36 -0
- data/lib/kredki/pads/list/pad.rb +74 -0
- data/lib/kredki/pads/list/tree/item.rb +138 -0
- data/lib/kredki/pads/list/tree/item_group.rb +86 -0
- data/lib/kredki/pads/list/tree/pad.rb +94 -0
- data/lib/kredki/pads/module.rb +11 -0
- data/lib/kredki/pads/note.rb +212 -0
- data/lib/kredki/pads/notes.rb +32 -0
- data/lib/kredki/pads/option/option.rb +121 -0
- data/lib/kredki/pads/option/option_item.rb +15 -0
- data/lib/kredki/pads/option/option_item_group.rb +16 -0
- data/lib/kredki/pads/option/option_layer.rb +81 -0
- data/lib/kredki/pads/pad/animation_pad.rb +106 -0
- data/lib/kredki/pads/pad/glyph_pad.rb +71 -0
- data/lib/kredki/pads/pad/pad.rb +1290 -0
- data/lib/kredki/pads/pad/pad_events.rb +358 -0
- data/lib/kredki/pads/pad/picture_pad.rb +89 -0
- data/lib/kredki/pads/pad/rectangle_pad.rb +181 -0
- data/lib/kredki/pads/pad/scroll_pad.rb +176 -0
- data/lib/kredki/pads/pad/shape_pad.rb +148 -0
- data/lib/kredki/pads/pad/space_pad.rb +33 -0
- data/lib/kredki/pads/pad/text_pad.rb +310 -0
- data/lib/kredki/pads/pane.rb +267 -0
- data/lib/kredki/pads/portal_layer.rb +94 -0
- data/lib/kredki/pads/radio/group.rb +45 -0
- data/lib/kredki/pads/radio/item.rb +69 -0
- data/lib/kredki/pads/radio/item_button.rb +143 -0
- data/lib/kredki/pads/service/event_queue.rb +79 -0
- data/lib/kredki/pads/service/service.rb +248 -0
- data/lib/kredki/pads/service/service_event_manager.rb +43 -0
- data/lib/kredki/pads/service/service_filter.rb +98 -0
- data/lib/kredki/pads/service/service_inherited.rb +48 -0
- data/lib/kredki/pads/setup.rb +36 -0
- data/lib/kredki/pads/slider/slider.rb +145 -0
- data/lib/kredki/pads/slider/slider_x.rb +41 -0
- data/lib/kredki/pads/slider/slider_y.rb +41 -0
- data/lib/kredki/pads/table/cell.rb +22 -0
- data/lib/kredki/pads/table/column.rb +63 -0
- data/lib/kredki/pads/table/column_layout.rb +88 -0
- data/lib/kredki/pads/table/pad.rb +116 -0
- data/lib/kredki/pads/table/row.rb +24 -0
- data/lib/kredki/pads/table/scroll_rows.rb +50 -0
- data/lib/kredki/pads/text/editable_text_verse.rb +77 -0
- data/lib/kredki/pads/text/editable_text_verses.rb +59 -0
- data/lib/kredki/pads/text/navigable_text_pad.rb +413 -0
- data/lib/kredki/pads/text/text_edition.rb +97 -0
- data/lib/kredki/pads/text/text_navigation.rb +109 -0
- data/lib/kredki/pads/toolbar/item.rb +62 -0
- data/lib/kredki/pads/toolbar/item_group.rb +22 -0
- data/lib/kredki/pads/toolbar/layer.rb +41 -0
- data/lib/kredki/pads/toolbar/pad.rb +51 -0
- data/lib/kredki/pads/toolbar/primary_layer.rb +64 -0
- data/lib/kredki/pads/window.rb +11 -0
- data/lib/kredki/script.rb +29 -0
- data/lib/kredki/setup.rb +2 -0
- data/lib/kredki/test.rb +35 -0
- data/lib/kredki.rb +10 -0
- data/lib/readme.md +31 -0
- data/stuff/config/config.rb +431 -0
- data/stuff/config/pads_config.rb +111 -0
- data/stuff/dll/SDL3.dll +0 -0
- data/stuff/dll/pastele.dll +0 -0
- data/stuff/dll/thorvg-1.dll +0 -0
- data/stuff/font/MartianMono-StdRg.ttf +0 -0
- data/stuff/font/MavenPro-Medium.ttf +0 -0
- data/stuff/font/MavenPro-Regular.ttf +0 -0
- data/stuff/glyph/alert-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/alert-triangle-svgrepo-com.svg +12 -0
- data/stuff/glyph/archivebox-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-ccw-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-cw-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-2-rectangle-path-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-4-way-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-ccw-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-circle-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-cw-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-from-line-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-line-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-shape-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-from-shape-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-right-arrow-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-shape-turn-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-shape-turn-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-small-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-thin-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-to-line-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-left-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-line-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-shape-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-to-shape-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-trend-down-svgrepo-com.svg +12 -0
- data/stuff/glyph/arrow-trend-up-svgrepo-com.svg +12 -0
- data/stuff/glyph/arrow-turn-down-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-down-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-left-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-left-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-right-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-right-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-up-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-turn-up-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/arrow-up-arrow-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/arrow-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/at-sign-svgrepo-com.svg +4 -0
- data/stuff/glyph/bag-svgrepo-com.svg +4 -0
- data/stuff/glyph/bell-slash-svgrepo-com.svg +6 -0
- data/stuff/glyph/bell-svgrepo-com.svg +5 -0
- data/stuff/glyph/book-open-svgrepo-com.svg +5 -0
- data/stuff/glyph/bookmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/box-svgrepo-com.svg +6 -0
- data/stuff/glyph/calendar-svgrepo-com.svg +5 -0
- data/stuff/glyph/camera-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/caret-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/cart-svgrepo-com.svg +6 -0
- data/stuff/glyph/chart-pie-svgrepo-com.svg +5 -0
- data/stuff/glyph/chartbar-2-svgrepo-com.svg +7 -0
- data/stuff/glyph/chartbar-svgrepo-com.svg +7 -0
- data/stuff/glyph/checkmark-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/checkmark-double-svgrepo-com.svg +5 -0
- data/stuff/glyph/checkmark-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/checkmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-left-chevron-right-svgrepo-com.svg +5 -0
- data/stuff/glyph/chevron-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-down-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-right-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-small-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/chevron-up-chevron-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/chevron-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/clock-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-arrow-up-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-download-svgrepo-com.svg +4 -0
- data/stuff/glyph/cloud-slash-svgrepo-com.svg +5 -0
- data/stuff/glyph/cloud-svgrepo-com.svg +4 -0
- data/stuff/glyph/columns-svgrepo-com.svg +5 -0
- data/stuff/glyph/command-svgrepo-com.svg +4 -0
- data/stuff/glyph/compass-svgrepo-com.svg +5 -0
- data/stuff/glyph/credit-card-svgrepo-com.svg +5 -0
- data/stuff/glyph/crop-svgrepo-com.svg +5 -0
- data/stuff/glyph/crown-svgrepo-com.svg +4 -0
- data/stuff/glyph/delete-left-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-desktop-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-mobile-svgrepo-com.svg +4 -0
- data/stuff/glyph/device-tablet-svgrepo-com.svg +4 -0
- data/stuff/glyph/doc-svgrepo-com.svg +5 -0
- data/stuff/glyph/dot-small-svgrepo-com.svg +4 -0
- data/stuff/glyph/dots-3-horizontal-svgrepo-com.svg +6 -0
- data/stuff/glyph/dots-3-vertical-svgrepo-com.svg +6 -0
- data/stuff/glyph/dots-6-horizontal-svgrepo-com.svg +9 -0
- data/stuff/glyph/dots-6-vertical-svgrepo-com.svg +9 -0
- data/stuff/glyph/dots-9-svgrepo-com.svg +12 -0
- data/stuff/glyph/emoji-frown-svgrepo-com.svg +4 -0
- data/stuff/glyph/emoji-meh-svgrepo-com.svg +4 -0
- data/stuff/glyph/emoji-smile-svgrepo-com.svg +4 -0
- data/stuff/glyph/envelope-svgrepo-com.svg +5 -0
- data/stuff/glyph/external-link-svgrepo-com.svg +5 -0
- data/stuff/glyph/eye-slash-svgrepo-com.svg +15 -0
- data/stuff/glyph/eye-svgrepo-com.svg +4 -0
- data/stuff/glyph/filter-svgrepo-com.svg +4 -0
- data/stuff/glyph/flame-svgrepo-com.svg +4 -0
- data/stuff/glyph/floppy-disk-svgrepo-com.svg +4 -0
- data/stuff/glyph/folder-svgrepo-com.svg +4 -0
- data/stuff/glyph/fullscreen-alt-svgrepo-com.svg +7 -0
- data/stuff/glyph/fullscreen-exit-alt-svgrepo-com.svg +7 -0
- data/stuff/glyph/fullscreen-exit-svgrepo-com.svg +5 -0
- data/stuff/glyph/fullscreen-svgrepo-com.svg +5 -0
- data/stuff/glyph/gear-svgrepo-com.svg +4 -0
- data/stuff/glyph/giftbox-svgrepo-com.svg +6 -0
- data/stuff/glyph/half-star-svgrepo-com.svg +4 -0
- data/stuff/glyph/hashtag-svgrepo-com.svg +4 -0
- data/stuff/glyph/headphones-svgrepo-com.svg +4 -0
- data/stuff/glyph/heart-half-svgrepo-com.svg +4 -0
- data/stuff/glyph/heart-svgrepo-com.svg +4 -0
- data/stuff/glyph/house-svgrepo-com.svg +4 -0
- data/stuff/glyph/image-svgrepo-com.svg +4 -0
- data/stuff/glyph/info-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/key-svgrepo-com.svg +4 -0
- data/stuff/glyph/layers-3-svgrepo-com.svg +6 -0
- data/stuff/glyph/layout-svgrepo-com.svg +6 -0
- data/stuff/glyph/line-3-svgrepo-com.svg +6 -0
- data/stuff/glyph/link-alt-svgrepo-com.svg +5 -0
- data/stuff/glyph/link-svgrepo-com.svg +6 -0
- data/stuff/glyph/list-bullet-svgrepo-com.svg +9 -0
- data/stuff/glyph/location-svgrepo-com.svg +4 -0
- data/stuff/glyph/lock-open-svgrepo-com.svg +4 -0
- data/stuff/glyph/lock-svgrepo-com.svg +4 -0
- data/stuff/glyph/map-pin-svgrepo-com.svg +4 -0
- data/stuff/glyph/medal-svgrepo-com.svg +13 -0
- data/stuff/glyph/media-backward-end-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-backward-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-forward-end-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-forward-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-pause-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-pause-svgrepo-com.svg +5 -0
- data/stuff/glyph/media-play-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-play-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-stop-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/media-stop-svgrepo-com.svg +4 -0
- data/stuff/glyph/message-bubble-2-svgrepo-com.svg +4 -0
- data/stuff/glyph/message-bubble-svgrepo-com.svg +4 -0
- data/stuff/glyph/mic-slash-svgrepo-com.svg +6 -0
- data/stuff/glyph/mic-svgrepo-com.svg +5 -0
- data/stuff/glyph/minus-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/minus-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/minus-svgrepo-com.svg +4 -0
- data/stuff/glyph/moon-svgrepo-com.svg +4 -0
- data/stuff/glyph/music-note-svgrepo-com.svg +4 -0
- data/stuff/glyph/nosign-svgrepo-com.svg +4 -0
- data/stuff/glyph/paper-clip-svgrepo-com.svg +4 -0
- data/stuff/glyph/paper-plane-svgrepo-com.svg +4 -0
- data/stuff/glyph/pen-tool-svgrepo-com.svg +4 -0
- data/stuff/glyph/pencil-svgrepo-com.svg +5 -0
- data/stuff/glyph/percent-svgrepo-com.svg +6 -0
- data/stuff/glyph/phone-incoming-svgrepo-com.svg +5 -0
- data/stuff/glyph/phone-missed-svgrepo-com.svg +4 -0
- data/stuff/glyph/phone-outgoing-svgrepo-com.svg +5 -0
- data/stuff/glyph/phone-slash-svgrepo-com.svg +4 -0
- data/stuff/glyph/phone-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/plus-svgrepo-com.svg +4 -0
- data/stuff/glyph/power-svgrepo-com.svg +5 -0
- data/stuff/glyph/printer-svgrepo-com.svg +5 -0
- data/stuff/glyph/question-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/scissors-svgrepo-com.svg +5 -0
- data/stuff/glyph/search-svgrepo-com.svg +4 -0
- data/stuff/glyph/server-svgrepo-com.svg +5 -0
- data/stuff/glyph/shape-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-rhombus-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-square-svgrepo-com.svg +4 -0
- data/stuff/glyph/shape-triangle-svgrepo-com.svg +12 -0
- data/stuff/glyph/share-svgrepo-com.svg +4 -0
- data/stuff/glyph/shield-slash-svgrepo-com.svg +13 -0
- data/stuff/glyph/shield-svgrepo-com.svg +4 -0
- data/stuff/glyph/shippingbox-svgrepo-com.svg +7 -0
- data/stuff/glyph/slider-3-horizontal-svgrepo-com.svg +9 -0
- data/stuff/glyph/slider-3-vertical-svgrepo-com.svg +9 -0
- data/stuff/glyph/speaker-svgrepo-com.svg +4 -0
- data/stuff/glyph/speaker-wave-1-svgrepo-com.svg +5 -0
- data/stuff/glyph/speaker-wave-2-svgrepo-com.svg +6 -0
- data/stuff/glyph/speaker-xmark-svgrepo-com.svg +5 -0
- data/stuff/glyph/square-4-grid-svgrepo-com.svg +7 -0
- data/stuff/glyph/square-on-square-svgrepo-com.svg +5 -0
- data/stuff/glyph/star-svgrepo-com.svg +4 -0
- data/stuff/glyph/sun-svgrepo-com.svg +12 -0
- data/stuff/glyph/tag-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-align-center-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-justify-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-left-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-align-right-svgrepo-com.svg +7 -0
- data/stuff/glyph/text-bold-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-heading-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-italic-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-svgrepo-com.svg +4 -0
- data/stuff/glyph/text-underline-svgrepo-com.svg +5 -0
- data/stuff/glyph/thumbs-down-svgrepo-com.svg +5 -0
- data/stuff/glyph/thumbs-up-svgrepo-com.svg +5 -0
- data/stuff/glyph/trash-svgrepo-com.svg +5 -0
- data/stuff/glyph/tray-svgrepo-com.svg +4 -0
- data/stuff/glyph/umbrela-svgrepo-com.svg +4 -0
- data/stuff/glyph/user-svgrepo-com.svg +5 -0
- data/stuff/glyph/users-svgrepo-com.svg +7 -0
- data/stuff/glyph/video-svgrepo-com.svg +12 -0
- data/stuff/glyph/waveform-ecg-svgrepo-com.svg +4 -0
- data/stuff/glyph/wi-fi-svgrepo-com.svg +7 -0
- data/stuff/glyph/xmark-circle-svgrepo-com.svg +4 -0
- data/stuff/glyph/xmark-small-svgrepo-com.svg +4 -0
- data/stuff/glyph/xmark-svgrepo-com.svg +4 -0
- data/stuff/glyph/zap-svgrepo-com.svg +4 -0
- data/stuff/glyph/zoom-in-svgrepo-com.svg +5 -0
- data/stuff/glyph/zoom-out-svgrepo-com.svg +5 -0
- data/stuff/readme.md +266 -0
- data/stuff/so/libSDL3.so +0 -0
- data/stuff/so/libpastele.so +0 -0
- data/stuff/so/libthorvg-1.so +0 -0
- metadata +427 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
# Graphical object with custom fill and stroke.
|
|
3
|
+
class Shape < Paint
|
|
4
|
+
|
|
5
|
+
# Helper for creating Shape path.
|
|
6
|
+
class Crayon
|
|
7
|
+
|
|
8
|
+
# Set [+x+, +y+] as crayon position.
|
|
9
|
+
def jump x, y = x
|
|
10
|
+
Pastele.shape_move_to @shape.pointer, x, y
|
|
11
|
+
@x = x
|
|
12
|
+
@y = y
|
|
13
|
+
self
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Make line from crayon position to [+x+, +y+] then set [+x+, +y+] as crayon position.
|
|
17
|
+
def line x, y
|
|
18
|
+
Pastele.shape_line_to @shape.pointer, x, y
|
|
19
|
+
@shape.update if @autoupdate
|
|
20
|
+
@x = x
|
|
21
|
+
@y = y
|
|
22
|
+
self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Make bezier curve from crayon position to [+x+, +y+] with control points [+cx1+, +cy1+] and [+cx2+, +cy2+]. Then set [+x+, +y+] as crayon position.
|
|
26
|
+
def curve x, y, cx1, cy1, cx2, cy2
|
|
27
|
+
Pastele.shape_cubic_to @shape.pointer, cx1, cy1, cx2, cy2, x, y
|
|
28
|
+
@shape.update if @autoupdate
|
|
29
|
+
@x = x
|
|
30
|
+
@y = y
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Make ellipse of +size_x+ and +size_y+ with the center at crayon position.
|
|
35
|
+
def ellipse size_x, size_y = size_x
|
|
36
|
+
Pastele.shape_append_circle @shape.pointer, @x, @y, size_x * 0.5, size_y * 0.5
|
|
37
|
+
@shape.update if @autoupdate
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Make rectangle of +w+ width and +h+ height with +corner_ss+, +corner_es+, +corner_se+ and +corner_ee+ corners.
|
|
42
|
+
# The rectangle is placed at crayon position.
|
|
43
|
+
def rectangle w, h = w, corner_ss = 0, corner_es = corner_ss, corner_se = corner_ss, corner_ee = corner_ss
|
|
44
|
+
Pastele.shape_append_round_rect @shape.pointer, @x - w * 0.5, @y - h * 0.5, w, h, corner_ss, corner_es, corner_se, corner_ee
|
|
45
|
+
@shape.update if @autoupdate
|
|
46
|
+
self
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Make line from the crayon position to the first path position.
|
|
50
|
+
def close
|
|
51
|
+
Pastele.shape_close @shape.pointer
|
|
52
|
+
@shape.update if @autoupdate
|
|
53
|
+
self
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# :section: LEVEL 2
|
|
57
|
+
|
|
58
|
+
def initialize shape, reset = true, x = 0, y = 0
|
|
59
|
+
@shape = shape
|
|
60
|
+
@autoupdate = true
|
|
61
|
+
Pastele.shape_reset @shape.pointer if reset
|
|
62
|
+
jump x, y
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
attr_accessor :autoupdate
|
|
66
|
+
attr :shape
|
|
67
|
+
|
|
68
|
+
# Publicate prepared path.
|
|
69
|
+
def commit
|
|
70
|
+
@shape.update
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get Crayon to create custom path.
|
|
75
|
+
#
|
|
76
|
+
# +block+ is called in Crayon context if given.
|
|
77
|
+
def draw reset = true, x = 0, y = 0, &block
|
|
78
|
+
crayon = Crayon.new self, reset, x, y
|
|
79
|
+
if block
|
|
80
|
+
crayon.autoupdate = false
|
|
81
|
+
crayon.set &block
|
|
82
|
+
crayon.commit
|
|
83
|
+
crayon.autoupdate = true
|
|
84
|
+
end
|
|
85
|
+
crayon
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Set fill.
|
|
89
|
+
def set_fill *fill
|
|
90
|
+
return send_bundle :set_fill, yield(self.fill) if block_given?
|
|
91
|
+
fill = Util.uncover fill
|
|
92
|
+
return if @fill == fill && fill != :random
|
|
93
|
+
norm_fill = Kredki.fill fill
|
|
94
|
+
case norm_fill
|
|
95
|
+
when Color
|
|
96
|
+
Pastele.shape_set_fill_color @pointer, *norm_fill
|
|
97
|
+
when LinearGradient
|
|
98
|
+
Pastele.shape_set_fill_linear_gradient @pointer, *norm_fill.ffi
|
|
99
|
+
when RadialGradient
|
|
100
|
+
Pastele.shape_set_fill_radial_gradient @pointer, *norm_fill.ffi
|
|
101
|
+
end
|
|
102
|
+
@fill = fill
|
|
103
|
+
update
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# See #set_fill.
|
|
107
|
+
def fill= param
|
|
108
|
+
send_bundle :set_fill, param
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Get fill.
|
|
112
|
+
def fill
|
|
113
|
+
@fill
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Available fill rules.
|
|
117
|
+
class FillRule
|
|
118
|
+
class << self
|
|
119
|
+
# Default fill rule.
|
|
120
|
+
def winding = 0
|
|
121
|
+
def even_odd = 1
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Set fill rule.
|
|
126
|
+
def set_fill_rule rule = @fill_rule
|
|
127
|
+
return set_fill_rule yield @fill_rule if block_given?
|
|
128
|
+
return if @fill_rule == rule
|
|
129
|
+
Pastele.shape_set_fill_rule @pointer, FillRule.send(rule || :winding)
|
|
130
|
+
@fill_rule = rule
|
|
131
|
+
update
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# See #set_fill_rule.
|
|
135
|
+
def fill_rule= param
|
|
136
|
+
send_bundle :set_fill_rule, param
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Get fill rule.
|
|
140
|
+
def fill_rule
|
|
141
|
+
@fill_rule
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Set stroke features.
|
|
145
|
+
def set_stroke *a, **ka
|
|
146
|
+
a.map do |it|
|
|
147
|
+
case it
|
|
148
|
+
when Hash
|
|
149
|
+
set_stroke **it
|
|
150
|
+
when Numeric
|
|
151
|
+
set_stroke_width it
|
|
152
|
+
else
|
|
153
|
+
send_bundle :set_stroke_fill, it
|
|
154
|
+
end
|
|
155
|
+
end.any? | send_branch(__method__, ka)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# See #set_stroke.
|
|
159
|
+
def stroke= param
|
|
160
|
+
send_bundle :set_stroke, param
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Set stroke fill.
|
|
164
|
+
def set_stroke_fill *stroke_fill
|
|
165
|
+
return send_bundle :set_stroke_fill, yield(self.stroke_fill) if block_given?
|
|
166
|
+
stroke_fill = Util.uncover stroke_fill
|
|
167
|
+
return if @stroke_fill == stroke_fill && stroke_fill != :random
|
|
168
|
+
norm_fill = Kredki.fill stroke_fill
|
|
169
|
+
case norm_fill
|
|
170
|
+
when Color
|
|
171
|
+
Pastele.shape_set_stroke_color @pointer, *norm_fill
|
|
172
|
+
when LinearGradient
|
|
173
|
+
Pastele.shape_set_stroke_linear_gradient @pointer, *norm_fill.ffi
|
|
174
|
+
when RadialGradient
|
|
175
|
+
Pastele.shape_set_stroke_radial_gradient @pointer, *norm_fill.ffi
|
|
176
|
+
end
|
|
177
|
+
@stroke_fill = stroke_fill
|
|
178
|
+
update
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# See #set_stroke_fill.
|
|
182
|
+
def stroke_fill= param
|
|
183
|
+
send_bundle :set_stroke_fill, param
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Get stroke fill.
|
|
187
|
+
def stroke_fill
|
|
188
|
+
@stroke_fill
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Set stroke width.
|
|
192
|
+
def set_stroke_width stroke_width = @stroke_width
|
|
193
|
+
return set_stroke_width yield @stroke_width if block_given?
|
|
194
|
+
return if @stroke_width == stroke_width
|
|
195
|
+
update_stroke_width stroke_width
|
|
196
|
+
update
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def update_stroke_width stroke_width
|
|
200
|
+
Pastele.shape_set_stroke_width @pointer, stroke_width.to_f
|
|
201
|
+
@stroke_width = stroke_width
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# See #set_stroke_width.
|
|
205
|
+
def stroke_width= param
|
|
206
|
+
send_bundle :set_stroke_width, param
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Get stroke width.
|
|
210
|
+
def stroke_width
|
|
211
|
+
@stroke_width
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Available stroke path ending methods.
|
|
215
|
+
class StrokeCap
|
|
216
|
+
class << self
|
|
217
|
+
# Default stroke cap.
|
|
218
|
+
def square = 0
|
|
219
|
+
def round = 1
|
|
220
|
+
def butt = 2
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# Set stroke path ending method.
|
|
225
|
+
def set_stroke_cap stroke_cap = @stroke_cap
|
|
226
|
+
return set_stroke_cap yield @stroke_cap if block_given?
|
|
227
|
+
return if @stroke_cap == stroke_cap
|
|
228
|
+
Pastele.shape_set_stroke_cap @pointer, StrokeCap.send(stroke_cap || :square)
|
|
229
|
+
@stroke_cap = stroke_cap
|
|
230
|
+
update
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# See #set_stroke_cap.
|
|
234
|
+
def stroke_cap= param
|
|
235
|
+
send_bundle :set_stroke_cap, param
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Get stroke path ending method.
|
|
239
|
+
def stroke_cap
|
|
240
|
+
@stroke_cap
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Available stroke connection methods.
|
|
244
|
+
class StrokeJoin
|
|
245
|
+
class << self
|
|
246
|
+
# Default stroke join.
|
|
247
|
+
def bevel = 0
|
|
248
|
+
def round = 1
|
|
249
|
+
# def miter = 2 ### intentional commented out; miter is set when join is numeric
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Set stroke connection method.
|
|
254
|
+
def set_stroke_join stroke_join = @stroke_join
|
|
255
|
+
return set_stroke_join yield @stroke_join if block_given?
|
|
256
|
+
return if @stroke_join == stroke_join
|
|
257
|
+
if stroke_join.is_a? Numeric
|
|
258
|
+
Pastele.shape_set_stroke_join @pointer, 2
|
|
259
|
+
Pastele.shape_set_stroke_miterlimit @pointer, stroke_join
|
|
260
|
+
else
|
|
261
|
+
Pastele.shape_set_stroke_join @pointer, StrokeJoin.send(stroke_join || :bevel)
|
|
262
|
+
end
|
|
263
|
+
@stroke_join = stroke_join
|
|
264
|
+
update
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# See #set_stroke_join.
|
|
268
|
+
def stroke_join= param
|
|
269
|
+
send_bundle :set_stroke_join, param
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Get stroke connection method.
|
|
273
|
+
def stroke_join
|
|
274
|
+
@stroke_join
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Set stroke dash pattern.
|
|
278
|
+
def set_stroke_pattern *stroke_pattern
|
|
279
|
+
return send_bundle :set_stroke_pattern, yield(self.stroke_pattern) if block_given?
|
|
280
|
+
return if @stroke_pattern == stroke_pattern
|
|
281
|
+
Pastele.shape_set_stroke_dash @pointer, Fiddle::Pointer[stroke_pattern.pack "f*"], stroke_pattern.length, 0
|
|
282
|
+
@stroke_pattern = stroke_pattern
|
|
283
|
+
update
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# See #set_stroke_pattern.
|
|
287
|
+
def stroke_pattern= param
|
|
288
|
+
send_bundle :set_stroke_pattern, param
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Get stroke dash pattern.
|
|
292
|
+
def stroke_pattern
|
|
293
|
+
@stroke_pattern
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# Set whether stroke is drawn behind the fill.
|
|
297
|
+
def set_stroke_behind value = true
|
|
298
|
+
return if (c = stroke_behind) == (value = block_given? ? yield(c) : value == Not ? !c : value)
|
|
299
|
+
Pastele.shape_set_paint_order @pointer, value ? 1 : 0
|
|
300
|
+
@stroke_behind = value
|
|
301
|
+
true
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# See #set_stroke_behind.
|
|
305
|
+
def stroke_behind= value
|
|
306
|
+
set_stroke_behind value
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Get whether stroke is drawn behind the fill.
|
|
310
|
+
def stroke_behind
|
|
311
|
+
@stroke_behind
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# See #stroke_behind.
|
|
315
|
+
def stroke_behind?
|
|
316
|
+
!!stroke_behind
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# Set stroke displayed part.
|
|
320
|
+
def set_stroke_trim *stroke_trim
|
|
321
|
+
return send_bundle :set_stroke_trim, yield(self.stroke_trim) if block_given?
|
|
322
|
+
stroke_trim = Util.uncover stroke_trim
|
|
323
|
+
return if @stroke_trim == stroke_trim
|
|
324
|
+
start, finish, simultaneous = *StrokeTrim[stroke_trim].to_a
|
|
325
|
+
Pastele.shape_set_stroke_trim @pointer, start, finish, simultaneous ? 1 : 0
|
|
326
|
+
@stroke_trim = stroke_trim
|
|
327
|
+
update
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# See #set_stroke_trim.
|
|
331
|
+
def stroke_trim= param
|
|
332
|
+
send_bundle :set_stroke_trim, param
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
# Get stroke displayed part.
|
|
336
|
+
def stroke_trim
|
|
337
|
+
@stroke_trim
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
# Get features.
|
|
341
|
+
def to_hash
|
|
342
|
+
super.merge({
|
|
343
|
+
fill: @fill,
|
|
344
|
+
stroke_width: @stroke_width,
|
|
345
|
+
stroke_fill: @stroke_fill
|
|
346
|
+
})
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
# :section: LEVEL 2
|
|
350
|
+
|
|
351
|
+
class StrokeTrim
|
|
352
|
+
|
|
353
|
+
def initialize start, finish, simultaneous
|
|
354
|
+
@start = start
|
|
355
|
+
@finish = finish
|
|
356
|
+
@simultaneous = simultaneous
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
def self.[](param)
|
|
360
|
+
case param
|
|
361
|
+
in self
|
|
362
|
+
param
|
|
363
|
+
in [start, finish]
|
|
364
|
+
self.new start, finish, false
|
|
365
|
+
in [start, finish, simultaneous]
|
|
366
|
+
self.new start, finish, simultaneous
|
|
367
|
+
else raise_ia param
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def to_a
|
|
372
|
+
[@start, @finish, @simultaneous]
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def initialize extended = false, pointer = nil
|
|
377
|
+
super pointer || Pastele.shape_new
|
|
378
|
+
ObjectSpace.define_finalizer(self, Shape.finalizer(@pointer)) unless pointer
|
|
379
|
+
|
|
380
|
+
@stroke_width = 0
|
|
381
|
+
set_stroke_join :bevel
|
|
382
|
+
@fill = Kredki.color
|
|
383
|
+
Pastele.shape_set_fill_color @pointer, *@fill
|
|
384
|
+
@stroke_fill = Kredki.color
|
|
385
|
+
Pastele.shape_set_stroke_color @pointer, *@stroke_fill
|
|
386
|
+
@is_mask = false
|
|
387
|
+
update unless extended
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def self.finalizer pointer
|
|
391
|
+
proc{ Pastele.shape_delete pointer }
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require_relative 'shape'
|
|
2
|
+
require_relative 'area'
|
|
3
|
+
|
|
4
|
+
module Kredki
|
|
5
|
+
# Base class for Shape's with defined size.
|
|
6
|
+
class ShapeArea < Shape
|
|
7
|
+
include Area
|
|
8
|
+
|
|
9
|
+
# Set a feature recognized by its class.
|
|
10
|
+
def << feature
|
|
11
|
+
case feature
|
|
12
|
+
in [x, y]
|
|
13
|
+
set_size x, y
|
|
14
|
+
in Numeric
|
|
15
|
+
set_size feature
|
|
16
|
+
else
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Get features.
|
|
22
|
+
def to_hash
|
|
23
|
+
super.merge({
|
|
24
|
+
size_x: @size_x,
|
|
25
|
+
size_y: @size_y
|
|
26
|
+
})
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# :section: LEVEL 2
|
|
30
|
+
|
|
31
|
+
def initialize
|
|
32
|
+
@size_x = @size_y = 100
|
|
33
|
+
@redraw_flag = true
|
|
34
|
+
|
|
35
|
+
super
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def pivot
|
|
39
|
+
[@size_x * 0.5, @size_y * 0.5]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def update_stroke_width ...
|
|
43
|
+
super
|
|
44
|
+
@redraw_flag = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def update
|
|
48
|
+
if @redraw_flag
|
|
49
|
+
@redraw_flag = false
|
|
50
|
+
redraw
|
|
51
|
+
true
|
|
52
|
+
else
|
|
53
|
+
super
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
module Kredki
|
|
2
|
+
class Text < Paint
|
|
3
|
+
|
|
4
|
+
# Set content.
|
|
5
|
+
def set_content content = @content
|
|
6
|
+
return set_content yield @content if block_given?
|
|
7
|
+
return if @content == content
|
|
8
|
+
Pastele.text_set_text @pointer, content.to_s
|
|
9
|
+
@content = content
|
|
10
|
+
update_size
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# See #set_content.
|
|
14
|
+
def content= param
|
|
15
|
+
send_bundle :set_content, param
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Get content.
|
|
19
|
+
def content
|
|
20
|
+
@content
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Get size in X axis.
|
|
24
|
+
def size_x
|
|
25
|
+
@size_x
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Set size in X axis. It can also affect the size in Y axis.
|
|
29
|
+
def set_size_y size_y = @size_y
|
|
30
|
+
return set_size_y yield @size_y if block_given?
|
|
31
|
+
return if @size_y == size_y
|
|
32
|
+
Pastele.text_set_size @pointer, size_y
|
|
33
|
+
@size_y = size_y
|
|
34
|
+
update_size
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# See #set_size_y.
|
|
38
|
+
def size_y= param
|
|
39
|
+
send_bundle :set_size_y, param
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Get size in Y axis.
|
|
43
|
+
def size_y
|
|
44
|
+
@size_y
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get size.
|
|
48
|
+
def size
|
|
49
|
+
[@size_x, @size_y]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Set font.
|
|
53
|
+
def set_font font
|
|
54
|
+
return set_font yield @font if block_given?
|
|
55
|
+
return if @font == font
|
|
56
|
+
Pastele.text_set_font @pointer, Kredki.font(font).name
|
|
57
|
+
@font = font
|
|
58
|
+
update_size
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# See #set_font.
|
|
62
|
+
def font= param
|
|
63
|
+
send_bundle :set_font, param
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Get font.
|
|
67
|
+
def font
|
|
68
|
+
@font
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Set fill color.
|
|
72
|
+
def set_fill *fill
|
|
73
|
+
return send_bundle :set_fill, yield(self.fill) if block_given?
|
|
74
|
+
fill = Util.uncover fill
|
|
75
|
+
return if @fill == fill && fill != :random
|
|
76
|
+
norm_fill = Kredki.fill fill
|
|
77
|
+
case norm_fill
|
|
78
|
+
when Color
|
|
79
|
+
Pastele.text_set_fill_color @pointer, *norm_fill.to_rgb
|
|
80
|
+
when LinearGradient
|
|
81
|
+
Pastele.text_set_fill_linear_gradient @pointer, *norm_fill.ffi
|
|
82
|
+
when RadialGradient
|
|
83
|
+
Pastele.text_set_fill_radial_gradient @pointer, *norm_fill.ffi
|
|
84
|
+
end
|
|
85
|
+
@fill = fill
|
|
86
|
+
update
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# See #set_fill.
|
|
90
|
+
def fill= param
|
|
91
|
+
send_bundle :set_fill, param
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Get fill color.
|
|
95
|
+
def fill
|
|
96
|
+
@fill
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Set stroke features.
|
|
100
|
+
def set_stroke *a, **ka
|
|
101
|
+
a.map do |it|
|
|
102
|
+
case it
|
|
103
|
+
when Hash
|
|
104
|
+
set_stroke **it
|
|
105
|
+
when Numeric
|
|
106
|
+
set_stroke_width it
|
|
107
|
+
else
|
|
108
|
+
send_bundle :set_stroke_fill, it
|
|
109
|
+
end
|
|
110
|
+
end.any? | send_branch(__method__, ka)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# See #set_stroke.
|
|
114
|
+
def stroke= param
|
|
115
|
+
send_bundle :set_stroke, param
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Set stroke fill.
|
|
119
|
+
def set_stroke_fill *stroke_fill
|
|
120
|
+
return send_bundle :set_stroke_fill, yield(self.stroke_fill) if block_given?
|
|
121
|
+
stroke_fill = Util.uncover stroke_fill
|
|
122
|
+
return if @stroke_fill == stroke_fill && stroke_fill != :random
|
|
123
|
+
update_stroke stroke_fill, @stroke_width
|
|
124
|
+
@stroke_fill = stroke_fill
|
|
125
|
+
update
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# See #set_stroke_fill.
|
|
129
|
+
def stroke_fill= param
|
|
130
|
+
send_bundle :set_stroke_fill, param
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Get stroke fill.
|
|
134
|
+
def stroke_fill
|
|
135
|
+
@stroke_fill
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Set stroke width.
|
|
139
|
+
def set_stroke_width stroke_width = @stroke_width
|
|
140
|
+
return set_stroke_width yield @stroke_width if block_given?
|
|
141
|
+
return if @stroke_width == stroke_width
|
|
142
|
+
update_stroke @stroke_fill, stroke_width
|
|
143
|
+
@stroke_width = stroke_width
|
|
144
|
+
update
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# See #set_stroke_width.
|
|
148
|
+
def stroke_width= param
|
|
149
|
+
send_bundle :set_stroke_width, param
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Get stroke width.
|
|
153
|
+
def stroke_width
|
|
154
|
+
@stroke_width
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Get +string+ width rendered with +@font+ and +@size_y+ up to character at +index+.
|
|
158
|
+
# If +index+ is +null+ or -1, +string+ width is returned.
|
|
159
|
+
# If +index+ is equal to string length, +string+ width is returned plus last character rsb.
|
|
160
|
+
def substring_width index = nil, string = @content
|
|
161
|
+
Pastele.text_get_text_width(@pointer, string.to_s, index || -1).ceil
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Get index of nearest character for +string+ rendered with +@font+ and +@size_y+, truncated to +size_max+.
|
|
165
|
+
def nearest_character_index size_max, string = @content
|
|
166
|
+
return 0 if size_max <= 0
|
|
167
|
+
Pastele.text_nearest_character_index @pointer, string.to_s, size_max
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Set a feature recognized by its class.
|
|
171
|
+
def << feature
|
|
172
|
+
case feature
|
|
173
|
+
in String
|
|
174
|
+
set_content feature
|
|
175
|
+
in Numeric
|
|
176
|
+
set_size_y feature
|
|
177
|
+
else
|
|
178
|
+
super
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# :section: LEVEL 2
|
|
183
|
+
|
|
184
|
+
def initialize
|
|
185
|
+
super Pastele.text_new
|
|
186
|
+
ObjectSpace.define_finalizer(self, Text.finalizer(@pointer))
|
|
187
|
+
|
|
188
|
+
@content = "TEXT"
|
|
189
|
+
@font = Kredki.font
|
|
190
|
+
@fill = Kredki.color
|
|
191
|
+
@stroke_fill = Kredki.color
|
|
192
|
+
@stroke_width = 0
|
|
193
|
+
@size_y = Kredki.text_size
|
|
194
|
+
|
|
195
|
+
Pastele.text_set_text @pointer, @content
|
|
196
|
+
Pastele.text_set_font @pointer, @font.name
|
|
197
|
+
Pastele.text_set_size @pointer, @size_y
|
|
198
|
+
Pastele.text_set_fill_color @pointer, *@fill.to_a(:rgb)
|
|
199
|
+
update_size
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def self.finalizer pointer
|
|
203
|
+
proc{ Pastele.text_delete pointer }
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def pivot
|
|
207
|
+
[@size_x * 0.5, @size_y * 0.5]
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def update_size
|
|
211
|
+
@size_x = substring_width
|
|
212
|
+
update_transform
|
|
213
|
+
update
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def update_stroke color, width
|
|
217
|
+
c = Kredki.color color
|
|
218
|
+
Pastele.text_set_outline @pointer, width, *c.to_rgb
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
end
|
|
222
|
+
end
|