-
Notifications
You must be signed in to change notification settings - Fork 0
More updates for the API. #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| Filter :: module { | ||
| apply :: (filter, image) = pic_nat_filter_apply(filter, image) | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
|
|
||
|
|
||
| BrushMetal :: module { | ||
| new :: () = pic_nat_brush_metal_new() | ||
| radius :: (filter, radius) = pic_nat_brush_metal_set_rad(filter, radius) | ||
| amount :: (filter, radius) = pic_nat_brush_metal_set_amount(filter, radius) | ||
| shine :: (filter, radius) = pic_nat_brush_metal_set_shine(filter, radius) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
|
|
||
| Image :: module { | ||
| new :: (w, h) = pic_nat_image_new(w, h) | ||
| newWithType :: (w, h, type) = pic_nat_image_new_typed(w, h, type) | ||
| getContext :: (img) = pic_nat_image_get_context(img) | ||
| fromPath :: (path) = pic_nat_image_new_from_path(path) | ||
|
|
||
| resize :: (img, w, h) = pic_nat_image_resize(img, w, h) | ||
|
|
||
| Type :: module { | ||
| RGB := 1 | ||
| ARGB := 2 | ||
| ARGB_PRE := 3 | ||
| BGR := 4 | ||
| } | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,10 +2,15 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.Color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.Graphics2D; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.Image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.image.BufferedImage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.io.File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.io.IOException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import javax.imageio.ImageIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.editor.CanvasFrame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.editor.icons.ImageLoader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.piccode.rt.Context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.piccode.rt.PiccodeException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.piccode.rt.PiccodeNumber; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,6 +71,57 @@ public static void addFunctions() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new PiccodeReference(image); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeFunctionFactory.create("image_new_from_path", List.of("path"), (args, namedArgs, frame) -> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var path = namedArgs.get("path"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ctx = frame == null ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Context.top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Context.getContextAt(frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var caller = ctx.getTopFrame().caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, path, Type.STRING); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BufferedImage image = ImageIO.read(new File(path.raw().toString())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new PiccodeReference(image); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (IOException ex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var def = (BufferedImage) ImageLoader.getImage(-1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new PiccodeReference(def); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+82
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting bug and null-handling in image_new_from_path
- PiccodeValue.verifyType(caller, path, Type.STRING);
-
- try {
- BufferedImage image = ImageIO.read(new File(path.raw().toString()));
- return new PiccodeReference(image);
- } catch (IOException ex) {
- var def = (BufferedImage) ImageLoader.getImage(-1);
- return new PiccodeReference(def);
- }
+ PiccodeValue.verifyType(caller, path, Type.STRING);
+
+ try {
+ var _path = ((PiccodeString) path).raw();
+ BufferedImage image = ImageIO.read(new File(_path));
+ if (image == null) {
+ var def = (BufferedImage) ImageLoader.getImage(-1);
+ return new PiccodeReference(def);
+ }
+ return new PiccodeReference(image);
+ } catch (IOException ex) {
+ var def = (BufferedImage) ImageLoader.getImage(-1);
+ return new PiccodeReference(def);
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeFunctionFactory.create("image_resize", List.of("img" ,"w", "h"), (args, namedArgs, frame) -> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var img = namedArgs.get("img"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var w = namedArgs.get("w"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var h = namedArgs.get("h"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ctx = frame == null ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Context.top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Context.getContextAt(frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var caller = ctx.getTopFrame().caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, img, Type.REFERENCE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, w, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, h, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _buffered_image = ((PiccodeReference)img).deref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!(_buffered_image instanceof BufferedImage)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new PiccodeException(caller.file, caller.line, caller.column, "Expected a buffer image. Found " + _buffered_image); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var bufferedmage = (BufferedImage) _buffered_image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _w = (int) (double) ((PiccodeNumber) w).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _h = (int) (double) ((PiccodeNumber) h).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Image resultingImage = bufferedmage.getScaledInstance(_w, _h, Image.SCALE_DEFAULT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BufferedImage outputImage = new BufferedImage(_w, _h, BufferedImage.TYPE_INT_RGB); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outputImage.getGraphics().drawImage(resultingImage, 0, 0, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+109
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Preserve alpha, improve scaling path, and dispose graphics
- if (!(_buffered_image instanceof BufferedImage)) {
- throw new PiccodeException(caller.file, caller.line, caller.column, "Expected a buffer image. Found " + _buffered_image);
- }
-
- var bufferedmage = (BufferedImage) _buffered_image;
+ if (!(_buffered_image instanceof BufferedImage)) {
+ throw new PiccodeException(caller.file, caller.line, caller.column, "Expected a buffered image. Found " + _buffered_image);
+ }
+
+ var bufferedImage = (BufferedImage) _buffered_image;
var _w = (int) (double) ((PiccodeNumber) w).raw();
var _h = (int) (double) ((PiccodeNumber) h).raw();
-
- Image resultingImage = bufferedmage.getScaledInstance(_w, _h, Image.SCALE_DEFAULT);
- BufferedImage outputImage = new BufferedImage(_w, _h, BufferedImage.TYPE_INT_RGB);
- outputImage.getGraphics().drawImage(resultingImage, 0, 0, null);
-
- return new PiccodeReference(outputImage);
+
+ int destType = bufferedImage.getColorModel().hasAlpha()
+ ? BufferedImage.TYPE_INT_ARGB
+ : BufferedImage.TYPE_INT_RGB;
+ BufferedImage outputImage = new BufferedImage(_w, _h, destType);
+ Graphics2D g2 = outputImage.createGraphics();
+ try {
+ g2.drawImage(bufferedImage, 0, 0, _w, _h, null);
+ } finally {
+ g2.dispose();
+ }
+
+ return new PiccodeReference(outputImage);🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new PiccodeReference(outputImage); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeFunctionFactory.create("image_get_context", List.of("img"), (args, namedArgs, frame) -> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var img = namedArgs.get("img"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.Color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.Graphics2D; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.awt.image.BufferedImage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.editor.CanvasFrame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -165,6 +166,70 @@ public static void addFunctions() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gfx.drawOval(_x, _y, _w, _h); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeFunctionFactory.create("draw_image", List.of("ctx", "img", "x", "y"), (args, namedArgs, frame) -> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _ctx = namedArgs.get("ctx"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _img = namedArgs.get("img"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var x = namedArgs.get("x"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var y = namedArgs.get("y"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ctx = frame == null ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Context.top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Context.getContextAt(frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var caller = ctx.getTopFrame().caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, _ctx, Type.REFERENCE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, _img, Type.REFERENCE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, x, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, y, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var obj = (PiccodeReference) _ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var imgObj = (PiccodeReference) _img; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _gfx = obj.deref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _image = imgObj.deref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!(_gfx instanceof Graphics2D)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new PiccodeException(caller.file, caller.line, caller.column, "Context is not a correct object. Expected Graphics2D"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!(_image instanceof BufferedImage)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new PiccodeException(caller.file, caller.line, caller.column, "Image in not a correct object. Expected a BufferedImage but found" + _image); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var gfx = (Graphics2D) _gfx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var img = (BufferedImage) _image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _x = (int) (double) ((PiccodeNumber) x).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _y = (int) (double) ((PiccodeNumber) y).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gfx.drawImage(img, _x, _y, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeFunctionFactory.create("draw_text", List.of("ctx", "text", "x", "y"), (args, namedArgs, frame) -> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _ctx = namedArgs.get("ctx"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _text = namedArgs.get("text"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var x = namedArgs.get("x"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var y = namedArgs.get("y"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ctx = frame == null ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Context.top | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Context.getContextAt(frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var caller = ctx.getTopFrame().caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, _ctx, Type.REFERENCE); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, _text, Type.STRING); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, x, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PiccodeValue.verifyType(caller, y, Type.NUMBER); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var obj = (PiccodeReference) _ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _gfx = obj.deref(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!(_gfx instanceof Graphics2D)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new PiccodeException(caller.file, caller.line, caller.column, "Context is not a correct object. Expected Graphics2D"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var gfx = (Graphics2D) _gfx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _x = (int) (double) ((PiccodeNumber) x).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var _y = (int) (double) ((PiccodeNumber) y).raw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| gfx.drawString(_text.toString(), _x, _y); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, null); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+206
to
+232
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. draw_text uses toString() on PiccodeString instead of the raw string (renders wrong text) Use the underlying string value; toString() will likely print the object identity. - var gfx = (Graphics2D) _gfx;
- var _x = (int) (double) ((PiccodeNumber) x).raw();
- var _y = (int) (double) ((PiccodeNumber) y).raw();
-
- gfx.drawString(_text.toString(), _x, _y);
+ var gfx = (Graphics2D) _gfx;
+ var _x = (int) (double) ((PiccodeNumber) x).raw();
+ var _y = (int) (double) ((PiccodeNumber) y).raw();
+ var text = ((PiccodeString) _text).raw();
+
+ gfx.drawString(text, _x, _y);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
💡 Verification agent
🧩 Analysis chain
Verify native symbol change to pic_nat_gfx_drop.
Confirm that pic_nat_gfx_drop is implemented and registered in the native gfx module; otherwise this will fail at runtime.
🏁 Script executed:
Length of output: 161
Missing native symbol registration for pic_nat_gfx_drop
The call to
pic_nat_gfx_drop(ctx)isn’t backed by any implementation in the native gfx module. Without it, this will fail at runtime with an undefined symbol error. Please:pic_nat_gfx_dropdefinition in the native gfx source (e.g.native/gfx.c).pic_nat_gfx_destroy), update the call inpiccode/context/ctx.picsaccordingly.🤖 Prompt for AI Agents