-
Notifications
You must be signed in to change notification settings - Fork 0
Make drawing to the canvas work again #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughA new rendering module was added to the codebase, providing wrappers for native graphics context retrieval and line drawing. Java-side, a native graphics integration class was introduced, registering functions to bridge Piccode and Java 2D graphics. The Piccode main method now initializes these native modules at startup. Build configuration and editor canvas logic were also updated. Documentation was corrected for naming and usage accuracy. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Piccode Main
participant PiccodeGfxModule
participant EditorWindow
participant CanvasFrame
participant Render Module
participant Java2D Graphics
User->>Piccode Main: Start application
Piccode Main->>PiccodeGfxModule: initializeNativeAppModules()
PiccodeGfxModule->>Piccode Main: Register native functions
Piccode Main->>EditorWindow: Launch editor
EditorWindow->>CanvasFrame: paintComponent()
CanvasFrame->>Render Module: getContext()
Render Module->>PiccodeGfxModule: pic_nat_get_gfx()
PiccodeGfxModule->>Java2D Graphics: Return Graphics2D context
CanvasFrame->>Render Module: drawLine(ctx, x1, y1, x2, y2)
Render Module->>PiccodeGfxModule: pic_nat_draw_line(ctx, x1, y1, x2, y2)
PiccodeGfxModule->>Java2D Graphics: Draw line
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
piccode/render/context.pics(1 hunks)pom.xml(2 hunks)src/main/java/org/editor/CanvasFrame.java(2 hunks)src/main/java/org/editor/nativemods/PiccodeGfxModule.java(1 hunks)src/main/java/org/piccode/piccode/Piccode.java(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/java/org/editor/CanvasFrame.java (1)
src/main/java/org/editor/events/AccessEvents.java (1)
compileAndRender(19-36)
src/main/java/org/editor/nativemods/PiccodeGfxModule.java (1)
src/main/java/org/editor/CanvasFrame.java (1)
CanvasFrame(41-333)
🔇 Additional comments (10)
pom.xml (2)
19-25: LGTM: Repository update policies properly configured.The explicit snapshot and release update policies ensure consistent dependency resolution behavior across environments.
78-78: LGTM: Branch-specific snapshot dependency.Using
main-SNAPSHOTis more explicit than a generic snapshot and properly ties the dependency to a specific branch.src/main/java/org/piccode/piccode/Piccode.java (3)
5-5: LGTM: Import added for native graphics module.The import is correctly placed and supports the native graphics integration.
19-19: LGTM: Native modules initialized before editor launch.Good placement of initialization - native modules are set up before the editor window starts.
23-25: LGTM: Clean native module initialization.The method reference approach keeps the code clean and the separation of concerns is well maintained.
piccode/render/context.pics (1)
3-7: LGTM: Clean Piccode wrapper module for native graphics.The Render module provides a clean interface to the native graphics functions with appropriate function signatures for context retrieval and line drawing operations.
src/main/java/org/editor/CanvasFrame.java (2)
120-120: Synchronous compilation ensures graphics context availability.The change from asynchronous to synchronous execution ensures the Graphics2D context is available when native graphics functions are called during compilation. This is necessary for the native graphics integration to work correctly.
130-130: LGTM: Context reset before compilation.Resetting the context before each compilation ensures a clean state and prevents potential issues with stale context data.
src/main/java/org/editor/nativemods/PiccodeGfxModule.java (2)
24-33: LGTM: Graphics context management is well implemented.The function properly handles Graphics2D object allocation and retrieval through the Piccode context system with appropriate null checks.
83-88: LGTM: Clean object wrapping implementation.The helper method properly creates Piccode objects with hash and class information for Graphics2D instances.
With the language improvements we are now able to load native functions and draw to the screen using piccodescript. This has always been implemented but the old implementation was kinda wacky. This is just the first stage and the native apis WILL change in the future.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation