is this the section to...?

Questions/discussion about contributing to Alchemy

Re: is this the section to...?

Postby Karl DD on Thu, 14 Jan 2010 16:00:04 GMT

That file is corrupt it seems.

In any case you can just upload the "org.alchemy.create.CreateModule-1.0.0.zip" file that is compiled.
And post the source here directly into the forum.
User avatar
Karl DD
Site Admin
 
Posts: 564
Joined: Sun, 20 Jan 2008 02:45:28 GMT
Location: Pittsburgh, PA

Re: is this the section to...?

Postby MichaelAquilina on Fri, 15 Jan 2010 13:18:25 GMT

Karl DD wrote:That file is corrupt it seems.

In any case you can just upload the "org.alchemy.create.CreateModule-1.0.0.zip" file that is compiled.
And post the source here directly into the forum.


hope this works. sorry for the hassle
Attachments
org.alchemy.create.CreateModule-1.0.0.zip
(2.89 KB) Downloaded 19 times
MichaelAquilina
 
Posts: 13
Joined: Sat, 09 Jan 2010 14:06:27 GMT

Re: is this the section to...?

Postby Karl DD on Fri, 15 Jan 2010 13:45:24 GMT

I tried to run it now but it threw a Null Pointer Exception error.
I quickly decompiled your code and it seems you are using the constructor:
Code: Select all
    public CreateModule() {
        p2 = new Point();
    }


The constructor has to be left blank actually, I should make a note of that.
Instead use the setup() function which is called when the user first activates the module:
Code: Select all
   protected void setup() {
        p2 = new Point();
    }


If you can make that little change and upload it again, I'll have a play.
I'm surprised that didn't create an error at your end?
User avatar
Karl DD
Site Admin
 
Posts: 564
Joined: Sun, 20 Jan 2008 02:45:28 GMT
Location: Pittsburgh, PA

Re: is this the section to...?

Postby MichaelAquilina on Fri, 15 Jan 2010 14:58:03 GMT

I changed the code and made it cleaner. The second point P2 was removed, following your suggestion :)
Basically I created a method named drawingCall(Point) which handles the drawing of the lines.
The method was used to replace wherever the line

Code: Select all
canvas.getCurrentCreateShape().lineTo(p);


was called. This happens in mouseDragged() and mouseReleased()
Then the method would call your function to draw the shape from the arrays of the shape
which you have designed in your original alchemy program. I couldnt find a "get" function so the
createShapes array is accessed directly and call the first two shapes in the createShapes array.
The two shapes are created in the mousePressed() method

Code: Select all
protected void drawingCall(Point primaryPoint)
    {
        // the >>canvas.getCurrentCreateShape().lineTo(p);<<
        // command is replaced by drawingCall()

            // change for offset and randomness
            int differBy = 30;
            int randomness = 30;

            //Creating point for second line
            Point secondaryPoint = new Point();
            secondaryPoint.x += primaryPoint.x + differBy + (int)math.random(-randomness,+randomness);//math.noise(differBy);
            secondaryPoint.y += primaryPoint.y + differBy + (int)math.random(-randomness,+randomness);//math.noise(differBy);

            //drawing shapes
            // WARNING - THE FIRST TWO SHAPES IN CREATESHAPES ARRAY ARE DRAWN
            canvas.createShapes.get(0).curveTo(primaryPoint);
            canvas.createShapes.get(1).curveTo(secondaryPoint);
    }
Attachments
org.alchemy.create.CreateModule-1.0.0.zip
revised version
(2.85 KB) Downloaded 27 times
MichaelAquilina
 
Posts: 13
Joined: Sat, 09 Jan 2010 14:06:27 GMT

Re: is this the section to...?

Postby Karl DD on Sat, 16 Jan 2010 00:02:21 GMT

Hey,

Actually, I found a small bug in my code for the module template, that was causing the module to throw an error when loading from the main Alchemy application.

If you add the following lines to the <runtime> part of modules/CreateModule/plugin.xml, then that should fix the bug. Sorry about that!
Code: Select all
        <library id="CreateModule" path="/" type="code">
            <export prefix="*" />
        </library>

I have updated the tutorial and the module source code as well.

But yeah, your code looks and works good.
It is fine to access the createShapes array directly. But because shapes can be cleared by the user with a shortcut key (i.e. when drawing shapes), I would check to make sure that
Code: Select all
canvas.createShapes.get(0) != null

Or you could get some null pointer errors.

Karl
User avatar
Karl DD
Site Admin
 
Posts: 564
Joined: Sun, 20 Jan 2008 02:45:28 GMT
Location: Pittsburgh, PA

Re: is this the section to...?

Postby MichaelAquilina on Sat, 16 Jan 2010 10:22:43 GMT

hey there,

i'm glad you liked my work, even though it was just a small piece of code.
i was also playing with the CreateModule code while waiting for your reply and its quite fun to be honest =)
an interesting idea is having both lines overlapping each other while being random at the same time.
i've also been around on the forum and seen some rude comments about the undo feature. i have a solution
for the undo, unless you have come up with something already :)
MichaelAquilina
 
Posts: 13
Joined: Sat, 09 Jan 2010 14:06:27 GMT

Re: is this the section to...?

Postby Karl DD on Sat, 16 Jan 2010 15:23:59 GMT

MichaelAquilina wrote:i've also been around on the forum and seen some rude comments about the undo feature. i have a solution
for the undo, unless you have come up with something already


Would love to hear your idea!
User avatar
Karl DD
Site Admin
 
Posts: 564
Joined: Sun, 20 Jan 2008 02:45:28 GMT
Location: Pittsburgh, PA

Re: is this the section to...?

Postby MichaelAquilina on Sat, 16 Jan 2010 16:07:45 GMT

the idea is that either -the states of the whole drawing board is saved as a whole and then reprinted up to the step until the undo is called -- or --each shape's drawing information is saved and each shape is redrawn from scratch....

the second option sounds harder but you could then extend it with selection capabilities. i havent seen a dictionary of all the shapes which are on the drawing board, some sort of ID to associate each item being created. if that can be done, then it would help me a lot :)
MichaelAquilina
 
Posts: 13
Joined: Sat, 09 Jan 2010 14:06:27 GMT

Re: is this the section to...?

Postby marc121 on Fri, 29 Jan 2010 10:38:22 GMT

Everyone here is good looking. Obviously the best looking section on this site.



_________________________________________

hidden cameras |Business answering service |long island disc jockeys
marc121
 
Posts: 1
Joined: Fri, 29 Jan 2010 10:34:24 GMT

Previous

Return to Development

Who is online

Users browsing this forum: No registered users and 0 guests