Re: Fixed pattern with colorWithPatternImage
Re: Fixed pattern with colorWithPatternImage
- Subject: Re: Fixed pattern with colorWithPatternImage
- From: Daniel Lopes <email@hidden>
- Date: Mon, 6 Sep 2010 15:14:26 -0300
If I pass nil only the left part is filled. Which I think is right. See the
image above:
http://cl.ly/2HPb
Daniel Lopes
On Mon, Sep 6, 2010 at 2:21 PM, Ken Ferry <email@hidden> wrote:
> It's legal to pass nil for the left and right caps if you don't have any,
> which apparently you do not.
>
> -Ken
>
>
> On Mon, Sep 6, 2010 at 10:09 AM, Daniel Lopes <email@hidden>wrote:
>
>> Perfect, I did this:
>>
>> - (void)drawRect:(NSRect)dirtyRect {
>>
>> NSImage *pattern = [NSImage imageNamed:@"TitlePattern.png"];
>>
>> NSDrawThreePartImage([self bounds], pattern, pattern, pattern, NO,
>> NSCompositeSourceOver, 1, NO);
>>
>> }
>>
>> Thanks again.
>> Daniel Lopes
>>
>>
>>
>> On Sun, Sep 5, 2010 at 10:04 PM, Daniel Lopes <email@hidden>wrote:
>>
>>> Thanks everybody. I'm without my mac now, so I will try all the
>>> recomendations tomorrow, anyway... big thanks for all help (until now I
>>> didnt found a good a place where I can have help to learn Cocoa for Mac, and
>>> not iPhone).
>>>
>>> Sent from my iPad
>>>
>>> On 05/09/2010, at 19:42, Ken Ferry <email@hidden> wrote:
>>>
>>>
>>>
>>> On Sun, Sep 5, 2010 at 3:41 PM, Ken Ferry < <email@hidden>
>>> email@hidden> wrote:
>>>
>>>>
>>>>
>>>> On Sat, Sep 4, 2010 at 1:16 PM, Daniel Lopes < <email@hidden>
>>>> email@hidden> wrote:
>>>>
>>>>> Hello Quincey,
>>>>>
>>>>> Thanks, I thought that a simple thing like that could be done easier.
>>>>> My background is from web dev (specially Ruby).
>>>>>
>>>>
>>>> NSDrawThreePartImage looks like it should be very easy in this case. In
>>>> fact, it looks like you do have a separate top image (though you could pass
>>>> nil if you didn't).
>>>>
>>>
>>> Oh, you probably want to go left to right, not top to bottom.
>>>
>>> Nevertheless, it's one function call.
>>>
>>> -Ken
>>>
>>>
>>>
>>>>
>>>> -Ken
>>>>
>>>>
>>>>>
>>>>> That app is just a simple pet project and for that I will use a simple
>>>>> gradient instead of the image. I tried the image because I want a small
>>>>> noise instead of a plain gradient.
>>>>>
>>>>> But really thanks for all the help, I will study the link that you sent
>>>>> and also study Coregraphics.
>>>>>
>>>>> Sent from my iPad
>>>>>
>>>>> On 04/09/2010, at 14:52, Quincey Morris <<email@hidden>
>>>>> email@hidden> wrote:
>>>>>
>>>>> > On Sep 4, 2010, at 10:13, Daniel - Area wrote:
>>>>> >
>>>>> >> My code is basically this:
>>>>> >> <http://pastie.org/1138167>http://pastie.org/1138167
>>>>> >>
>>>>> >> a) Looking my code I think the issue is exactly what you said. But
>>>>> >> what is the right object and properties to access the full size of
>>>>> the
>>>>> >> view?
>>>>> >
>>>>> > No, what I said is not the problem. You're not using the 'rect'
>>>>> parameter at all.
>>>>> >
>>>>> > Consulting the 'colorWithPatternImage:' documentation:
>>>>> >
>>>>> >> Parameters
>>>>> >> image
>>>>> >> The image to use as the pattern for the color object. The image is
>>>>> tiled starting at the bottom of the window. The image is not scaled.
>>>>> >
>>>>> > The pattern is tiled relative to the window, not to the view. So, the
>>>>> 'colorWithPatternImage:' isn't a viable approach in this case.
>>>>> >
>>>>> > You're going to have to browse the documentation to find a different
>>>>> approach (or search for sample code you can adapt). One possibility might be
>>>>> NSGradient, another might be NSDrawThreePartImage. These are both discussed
>>>>> here:
>>>>> >
>>>>> >
>>>>> <http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html>
>>>>> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html
>>>>> >
>>>>> > Or, you might be able to drop down to core graphics, and use
>>>>> something like CGContextDrawTiledImage.
>>>>> >
>>>>> >
>>>>> >
>>>>> > _______________________________________________
>>>>> >
>>>>> > Cocoa-dev mailing list ( <email@hidden>
>>>>> email@hidden)
>>>>> >
>>>>> > Please do not post admin requests or moderator comments to the list.
>>>>> > Contact the moderators at cocoa-dev-admins(at)<http://lists.apple.com>
>>>>> lists.apple.com
>>>>> >
>>>>> > Help/Unsubscribe/Update your Subscription:
>>>>> >
>>>>> >
>>>>> > This email sent to <email@hidden>email@hidden
>>>>> _______________________________________________
>>>>>
>>>>> Cocoa-dev mailing list ( <email@hidden>
>>>>> email@hidden)
>>>>>
>>>>> Please do not post admin requests or moderator comments to the list.
>>>>> Contact the moderators at cocoa-dev-admins(at)<http://lists.apple.com>
>>>>> lists.apple.com
>>>>>
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>
>>>>> This email sent to <email@hidden>email@hidden
>>>>>
>>>>
>>>>
>>>
>>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden