Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions Ports/iOSPort/nativeSources/DrawGradient.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ -(void)execute {

case GRADIENT_TYPE_HORIZONTAL:
CGContextDrawLinearGradient(context, myGradient,
CGPointMake(0, 0), CGPointMake(0, width), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGPointMake(0, 0), CGPointMake(width, 0), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
break;

case GRADIENT_TYPE_VERTICAL:
CGContextDrawLinearGradient(context, myGradient,
CGPointMake(0, 0), CGPointMake(height, 0), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGPointMake(0, 0), CGPointMake(0, height), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
break;
}
UIGraphicsPopContext();
Expand All @@ -215,21 +215,24 @@ -(void)execute {

GLfloat vertexes[] = {
x, y,
x + p2w, y,
x, y + p2h,
x + p2w, y + p2h
x + width, y,
x, y + height,
x + width, y + height
};

//static const GLshort textureCoordinates[] = {
// 0, 1,
// 1, 1,
// 0, 0,
// 1, 0,
//};
float maxS = (float)width / p2w;
float maxT = (float)height / p2h;

GLfloat textureCoordinates[] = {
0, maxT,
maxS, maxT,
0, 0,
maxS, 0,
};

//_glTexCoordPointer(2, GL_SHORT, 0, textureCoordinates);
//GLErrorLog;
glVertexAttribPointer(textureCoordAtt, 2, GL_SHORT, 0, 0, textureCoordinates);
glVertexAttribPointer(textureCoordAtt, 2, GL_FLOAT, 0, 0, textureCoordinates);
GLErrorLog;
//_glVertexPointer(2, GL_FLOAT, 0, vertexes);
//GLErrorLog;
Expand Down Expand Up @@ -324,12 +327,12 @@ -(void)execute {

case GRADIENT_TYPE_HORIZONTAL:
CGContextDrawLinearGradient(context, myGradient,
CGPointMake(0, 0), CGPointMake(0, width), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGPointMake(0, 0), CGPointMake(width, 0), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
break;

case GRADIENT_TYPE_VERTICAL:
CGContextDrawLinearGradient(context, myGradient,
CGPointMake(0, 0), CGPointMake(height, 0), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
CGPointMake(0, 0), CGPointMake(0, height), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
break;
}
UIGraphicsPopContext();
Expand All @@ -351,19 +354,22 @@ -(void)execute {

GLfloat vertexes[] = {
x, y,
x + p2w, y,
x, y + p2h,
x + p2w, y + p2h
x + width, y,
x, y + height,
x + width, y + height
};

static const GLshort textureCoordinates[] = {
0, 1,
1, 1,
float maxS = (float)width / p2w;
float maxT = (float)height / p2h;

GLfloat textureCoordinates[] = {
0, maxT,
maxS, maxT,
0, 0,
1, 0,
maxS, 0,
};

_glTexCoordPointer(2, GL_SHORT, 0, textureCoordinates);
_glTexCoordPointer(2, GL_FLOAT, 0, textureCoordinates);
GLErrorLog;
_glVertexPointer(2, GL_FLOAT, 0, vertexes);
GLErrorLog;
Expand Down
8 changes: 6 additions & 2 deletions Ports/iOSPort/nativeSources/IOSNative.m
Original file line number Diff line number Diff line change
Expand Up @@ -2348,12 +2348,16 @@ void com_codename1_impl_ios_IOSNative_fillRectRadialGradientMutable___int_int_in
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGGradientRef myGradient = CGGradientCreateWithColorComponents (colorSpace, components, locations, num_locations);
[UIColorFromRGB(n2, 255) set];
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, width, height));
CGPoint myCentrePoint = CGPointMake(relativeX * width, relativeY * height);
CGContextSaveGState(UIGraphicsGetCurrentContext());
CGContextClipToRect(UIGraphicsGetCurrentContext(), CGRectMake(n3, n4, width, height));
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(n3, n4, width, height));
CGPoint myCentrePoint = CGPointMake(n3 + relativeX * width, n4 + relativeY * height);
float myRadius = MIN(width, height) * relativeSize;
CGContextDrawRadialGradient (UIGraphicsGetCurrentContext(), myGradient, myCentrePoint,
0, myCentrePoint, myRadius,
kCGGradientDrawsAfterEndLocation);
CGGradientRelease(myGradient);
CGContextRestoreGState(UIGraphicsGetCurrentContext());
CGColorSpaceRelease(colorSpace);
POOL_END();
}
Expand Down
Loading