<commit_before>define [
    'app/draw',
    'leaflet',
    'leaflet.markercluster',
    'underscore',
    'jquery',
    'backbone',
    'app/jade'
], (
    draw,
    leaflet,
    markercluster,
    _,
    $,
    Backbone,
    jade
) ->

    anchor = (size) ->
        x = size.x/3 + 5
        y = size.y/2 + 16
        new L.Point x, y

    SMMarker = L.Marker
    REDUCED_OPACITY = 1

    initializer = ->
        # BEGIN hack to enable transparent markers
        REDUCED_OPACITY = 0.5
        OriginalMarkerCluster = L.MarkerCluster
        SMMarkerCluster = L.MarkerCluster.extend
            setOpacity: (opacity) ->
                children = @getAllChildMarkers()
                reducedProminence = false
                if children.length
                    reducedProminence = children[0].unit?.collection?.hasReducedPriority()
                if reducedProminence and opacity == 1
                    opacity = REDUCED_OPACITY
                OriginalMarkerCluster::setOpacity.call @, opacity
        L.MarkerCluster = SMMarkerCluster

        SMMarker = L.Marker.extend
            setOpacity: (opacity) ->
                if @options.reducedProminence and opacity == 1
                    opacity = REDUCED_OPACITY
                L.Marker::setOpacity.call @, opacity
        # END hack
    createMarker = (args...) ->
        new SMMarker args...

    CanvasIcon = L.Icon.extend
        initialize: (@dimension, options) ->
            @options.iconSize = new L.Point @dimension, @dimension
            @options.iconAnchor = @iconAnchor()
            @options.reducedProminence = options.reducedProminence
        options:
            className: 'leaflet-canvas-icon'
        setupCanvas: ->
            el = document.createElement 'canvas'
            # If the IE Canvas polyfill is installed, the element needs to be specially
            # initialized.
            if G_vmlCanvasManager?
                G_vmlCanvasManager.initElement el
            @_setIconStyles el, 'icon'
            s = @options.iconSize
            el.width = s.x
            el.height = s.y
            if @options.reducedProminence
                L.DomUtil.setOpacity el, REDUCED_OPACITY
            el
        createIcon: ->
            el = @setupCanvas()
            @draw el.getContext('2d')
            el
        createShadow: -><commit_msg>Add high-DPI-support for map-markers. Fixes #282.<commit_after>define [
    'app/draw',
    'leaflet',
    'leaflet.markercluster',
    'underscore',
    'jquery',
    'backbone',
    'app/jade'
], (
    draw,
    leaflet,
    markercluster,
    _,
    $,
    Backbone,
    jade
) ->

    anchor = (size) ->
        x = size.x/3 + 5
        y = size.y/2 + 16
        new L.Point x, y

    SMMarker = L.Marker
    REDUCED_OPACITY = 1

    initializer = ->
        # BEGIN hack to enable transparent markers
        REDUCED_OPACITY = 0.5
        OriginalMarkerCluster = L.MarkerCluster
        SMMarkerCluster = L.MarkerCluster.extend
            setOpacity: (opacity) ->
                children = @getAllChildMarkers()
                reducedProminence = false
                if children.length
                    reducedProminence = children[0].unit?.collection?.hasReducedPriority()
                if reducedProminence and opacity == 1
                    opacity = REDUCED_OPACITY
                OriginalMarkerCluster::setOpacity.call @, opacity
        L.MarkerCluster = SMMarkerCluster

        SMMarker = L.Marker.extend
            setOpacity: (opacity) ->
                if @options.reducedProminence and opacity == 1
                    opacity = REDUCED_OPACITY
                L.Marker::setOpacity.call @, opacity
        # END hack
    createMarker = (args...) ->
        new SMMarker args...

    CanvasIcon = L.Icon.extend
        initialize: (@dimension, options) ->
            @options.iconSize = new L.Point @dimension, @dimension
            @options.iconAnchor = @iconAnchor()
            @options.reducedProminence = options.reducedProminence
            @options.pixelRatio = (el) ->
                context = el.getContext('2d')
                devicePixelRatio = window.devicePixelRatio || 1
                backingStoreRatio = context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1
                return devicePixelRatio / backingStoreRatio
        options:
            className: 'leaflet-canvas-icon'
        setupCanvas: ->
            el = document.createElement 'canvas'
            context = el.getContext('2d')
            # Set ratio based on device dpi
            ratio = @options.pixelRatio(el)
            # If the IE Canvas polyfill is installed, the element needs to be specially
            # initialized.
            if G_vmlCanvasManager?
                G_vmlCanvasManager.initElement el
            @_setIconStyles el, 'icon'
            s = @options.iconSize
            # Set el width based on device dpi
            el.width = s.x * ratio
            el.height = s.y * ratio
            el.style.width = s.x + 'px'
            el.style.height = s.y + 'px'
            # Scale down to normal
            context.scale(ratio, ratio)
            if @options.reducedProminence
                L.DomUtil.setOpacity el, REDUCED_OPACITY
            el
        createIcon: ->
            el = @setupCanvas()
            @draw el.getContext('2d')
            el
        createShadow: ->
{'fraction_non_alphanumeric': 0.0901654244682785, 'fraction_numerical': 0.005635339029267406, 'mean_word_length': 1.651566265060241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5067351', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1465, 'n_words': 341}