Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawAdditionalGraphics draw icon in wrong slice. #28

Open
tuanph3012 opened this issue Jul 8, 2019 · 3 comments
Open

drawAdditionalGraphics draw icon in wrong slice. #28

tuanph3012 opened this issue Jul 8, 2019 · 3 comments

Comments

@tuanph3012
Copy link

tuanph3012 commented Jul 8, 2019

@EfraimB : I did implement drawAdditionalGraphics as below:

public func drawAdditionalGraphics(in context: CGContext, circularSegmentHeight: CGFloat, radius: CGFloat, sliceDegree: CGFloat) {

let iconSize = CGSize(width: 32, height: 32)
let iconPadding: CGFloat = 50

let icon = UIImage //	my icon
let centerOffset = CGPoint(x: -(radius - iconPadding) , y: -iconSize.height/2)
let additionalGraphicRect = CGRect(x: centerOffset.x, y: centerOffset.y, width: iconSize.width, height: iconSize.height)
        
let additionalGraphicPath = UIBezierPath(rect: additionalGraphicRect)
context.saveGState()
additionalGraphicPath.addClip()
context.scaleBy(x: 1, y: -1)
context.draw(icon.cgImage!, in: CGRect(x: additionalGraphicRect.minX, y: -additionalGraphicRect.minY, width: iconSize.width, height: iconSize.height), byTiling: true)
        context.restoreGState()

}

Result:

Icon is drawing in wrong slice

The issue is my icon is showing in wrong slice. Could you please help me to fix it.
Thank you

@ain1712
Copy link

ain1712 commented Dec 31, 2019

hi. did you manage to solve it?

@HimanshuParashar
Copy link

Hey, There is an issue in this file FortuneWheelLayer, you can update your code with my solution and solve this issue.

Provided by library

//// Aditional graphics drwings
        parent.slices.enumerated().forEach { (index,element) in
            self.drawAdditionalGraphics(in: context, rotation: rotation, for: element)
            let previousSlice:FortuneWheelSliceProtocol = parent.slices[safe:(index - 1)] ?? element
            rotation += degree(of:previousSlice)
        }

Edited Solution

//// Aditional graphics drwings
        parent.slices.enumerated().forEach { (index,element) in
            self.drawAdditionalGraphics(in: context, rotation: rotation, for: parent.slices[safe:(index - 1)] ?? element)
            let previousSlice:FortuneWheelSliceProtocol = parent.slices[safe:(index - 1)] ?? element
            rotation += degree(of:previousSlice)
        }

@EfraimB EfraimB reopened this Aug 19, 2020
@EfraimB
Copy link
Collaborator

EfraimB commented Nov 11, 2022

Can you please make a PR with this fix? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants