paint Drawing with brush

Find quick help here to get you started with Hollywood
Post Reply
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

paint Drawing with brush

Post by sinisrus »

Hello is it possible to paint with brush (picture brush)

if you look at the picture the left paint (A) with brush is very easy with hollywood
On the other hand I do not know how to draw like on the right (B) side

Is it possibl with hollywood to paint as Example B ??

thank you

Image
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: paint Drawing with brush

Post by Bugala »

not simple, but you make a loop to check mousex() and mousey() positions as long as mouse mousebutton is down (isleftmouse() = true)

not real code:

Code: Select all

left mouse button pressed:
oldx = mousex()
oldy = mousey()

repeat
newx = mousex()
newy = mousey()

compare oldx and newx and oldy and newy and based upon that you can figure out if mouse have moved and which way.

suppose oldx = 100 and newx = 105 (notice you also need to have y:s, but im skipping them)

for x = oldx to newx
displaybrush(1, x, y)
next

oldx = newx
oldy = newy

until isleftmouse() = false

explanation of the logic:
When mouse button is pressed, it will first save mouses x and y cordinates at that moment, this is necessary because repeat-until loop is referring to oldx and newx, and idea is that end of reapat-until loop, newx (which is current x) and y will become the new oldx and oldy. However, the first time you enter the loop, there is no oldx or oldy, since it isnt done until at end of that loop. Therefore you need to take that oldx and oldy before entering the loop for first time.

Inside the loop you compare old and new mouse co-ordinates. Suppose your mosue starts from 100, 200, and then at next check mouse have moved to co-ordinates 105, 200.

If you use your old style (A), which is to displaybrush to mouses current location, then you will effectively have painted only to location 100,200 and 105,200, but you would also need to draw to locations 101, 102, 103 and 104 (of x) to make it work like B.

For this reason you make that other loop which will "trace" mouses path from previous co-ordinate to new co-ordinate and along the way use displaybrush to each pixel, hence making it make that line kind of brush on B.

But notice that this isnt so simple, for while from 100, 200 to 105,200 it is quite simple, just draw brush to 100,200, 101,200, 102,200, 103,200, 104,200 and 105,200, suppose your co-ordinates are:
100, 200 and new one is 103, 202.

Now which locations should you now draw? How does your line work?

Should it be 100, 200 - 101, 200 - 101, 201 - 102, 201 - 102, 202 - 103, 202?

Or maybe: 100, 200 - 101, 201 - 102, 201 - 103, 202?

Or what?

not to mention the programming of that logic.

But thats how it basically works.

In case you didnt already notice, notice also that it is not a good idea of keeping to use displaybrush command to add more layers to the screen, but you should make it so that you are for example displaying smaller brush into a bigger brush, and then this altered bigger brush becomes the new bigger brush. This way you will only have 2 layers on screen at a time (big brush and paint brush), instead of ending up having 1000 layers, which would make it very heavy program to run and work, even if they are still at screen, not to mention they would take lot of memory as well.
sinisrus
Posts: 347
Joined: Tue Apr 21, 2015 5:43 pm

Re: paint Drawing with brush

Post by sinisrus »

it is complicated :-/

thnak
Post Reply