This repository was archived by the owner on May 28, 2025. It is now read-only.
Repository navigation
Implemented CG Transparency APIs. #576
Merged
Jared (jaredhms)
merged 2 commits into
microsoft:master
from
vectorform:feature/CGTransparency
Jun 27, 2016
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
samples/CGCatalog/CGCatalog/Samples/CGCCGContextBeginTransparencyLayerWithRect.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //****************************************************************************** | ||
| // | ||
| // Copyright (c) 2016 Microsoft Corporation. All rights reserved. | ||
| // | ||
| // This code is licensed under the MIT License (MIT). | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
| //****************************************************************************** | ||
|
|
||
| #pragma once | ||
|
|
||
| #import "CGCBaseViewController.h" | ||
| #import <Foundation/Foundation.h> | ||
|
|
||
| @interface CGCCGContextBeginTransparencyLayerWithRect : CGCBaseViewController | ||
|
|
||
| @end |
90 changes: 90 additions & 0 deletions
90
samples/CGCatalog/CGCatalog/Samples/CGCCGContextBeginTransparencyLayerWithRect.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| //****************************************************************************** | ||
| // | ||
| // Copyright (c) 2016 Microsoft Corporation. All rights reserved. | ||
| // | ||
| // This code is licensed under the MIT License (MIT). | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| // THE SOFTWARE. | ||
| // | ||
| //****************************************************************************** | ||
|
|
||
| #import "CGCCGContextBeginTransparencyLayerWithRect.h" | ||
|
|
||
| @interface TransparencyViewRect : UIView | ||
|
|
||
| @end | ||
|
|
||
| @implementation TransparencyViewRect | ||
|
|
||
| - (void)drawRect:(CGRect)rect { | ||
| CGContextRef context = UIGraphicsGetCurrentContext(); | ||
| CGFloat maxWidth = rect.size.width; | ||
| CGFloat maxHeight = rect.size.height; | ||
|
|
||
| // White background | ||
| CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); | ||
| CGContextFillRect(context, rect); | ||
|
|
||
| // Rect Size | ||
| CGFloat rectWidth = maxWidth / 2.0; | ||
| CGFloat rectHeight = rectWidth; | ||
|
|
||
| // Draw background rect | ||
| CGContextSetFillColorWithColor(context, [UIColor yellowColor].CGColor); | ||
| CGRect aRect = CGRectMake(rectWidth / 2 - 25, maxHeight / 2 - rectHeight / 2 - 25, rectWidth + 25, rectHeight + 25); | ||
| CGContextFillRect(context, aRect); | ||
|
|
||
| // Note: Shadow or Alpha would be better test samples for this, but are not fully implemented yet in the bridge. | ||
| // TODO: Use Shadow or Alpha instead of BlendMode when supported by the bridge | ||
| // Enable shadow | ||
|
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. Can you please file a GitHub issue to track this, and reference it here?
Collaborator
Author
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. Issue #584 |
||
| /*CGSize shadowOffset = CGSizeMake(10, 20); | ||
| CGContextSetShadow(context, shadowOffset, 10);*/ | ||
| // Set composite alpha of the transparency layer | ||
| // CGContextSetAlpha(context, 0.5); | ||
|
|
||
| CGContextSetBlendMode(context, kCGBlendModeHue); | ||
|
|
||
| // Begin Transparency | ||
| CGRect bRect = CGRectInset(aRect, 10, 10); | ||
| CGContextBeginTransparencyLayerWithRect(context, bRect, NULL); | ||
|
|
||
| CGContextSetFillColorWithColor(context, [UIColor redColor].CGColor); | ||
| CGRect cRect = CGRectMake(rectWidth / 2 + 25, maxHeight / 2 - rectHeight / 2 - 50, rectWidth, rectHeight); | ||
| CGContextFillRect(context, cRect); | ||
| CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor); | ||
| CGRect dRect = CGRectMake(rectWidth / 2 - 25, maxHeight / 2 - rectHeight / 2 + 25, rectWidth, rectHeight); | ||
| CGContextFillRect(context, dRect); | ||
| CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); | ||
| CGRect eRect = CGRectMake(rectWidth / 2 - 50, maxHeight / 2 - rectHeight / 2, rectWidth, rectHeight); | ||
| CGContextFillRect(context, eRect); | ||
|
|
||
| // End Transparency | ||
| CGContextEndTransparencyLayer(context); | ||
| } | ||
|
|
||
| @end | ||
|
|
||
| @interface CGCCGContextBeginTransparencyLayerWithRect () | ||
|
|
||
| @property (strong, nonatomic, nullable) TransparencyViewRect* customView; | ||
|
|
||
| @end | ||
|
|
||
| @implementation CGCCGContextBeginTransparencyLayerWithRect | ||
|
|
||
| - (void)viewDidLoad { | ||
| [super viewDidLoad]; | ||
|
|
||
| self.view.backgroundColor = [UIColor whiteColor]; | ||
|
|
||
| self.customView = [[TransparencyViewRect alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; | ||
| [self.view addSubview:self.customView]; | ||
| } | ||
|
|
||
| @end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
same here regarding referencing the GitHub issue. We should probably also delete the commented out code for now. Can you please add it to the GitHub issue, so we know to add the code back to these tests when the issue is fixed?
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.
I just tested again after the final implementation of the transparency APIs, and this issue no longer exists; it seems to use the Alpha like it should. I'll remove this one, as it's not much different than using SetHue as a test.